feat():字典、部门、用户等业务使用MyBatis-Plus重构
parent
52ce95f63b
commit
133ad7830f
|
@ -5,11 +5,14 @@ import com.muyu.common.core.utils.poi.ExcelUtil;
|
|||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.DataPageResp;
|
||||
import com.muyu.common.core.web.page.PageQueryModel;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.SysDictData;
|
||||
import com.muyu.system.domain.model.SysDictDataPageQueryModel;
|
||||
import com.muyu.system.domain.rep.SysDictDataListReq;
|
||||
import com.muyu.system.service.SysDictDataService;
|
||||
import com.muyu.system.service.SysDictTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -36,18 +39,21 @@ public class SysDictDataController extends BaseController {
|
|||
|
||||
@RequiresPermissions("system:dict:list")
|
||||
@PostMapping("/list")
|
||||
public Result<DataPageResp<SysDictData>> list (@RequestBody SysDictData dictData) {
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
return Result.success(new DataPageResp<>(0,list));
|
||||
public Result<DataPageResp<SysDictData>> list (@RequestBody SysDictDataListReq sysDictDataListReq) {
|
||||
PageQueryModel<SysDictData> sysDictDataPageQueryModel = dictDataService.selectDictDataList(SysDictDataPageQueryModel.reqBuild(sysDictDataListReq));
|
||||
return Result.success(
|
||||
DataPageResp.of(sysDictDataPageQueryModel)
|
||||
);
|
||||
}
|
||||
|
||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||
@RequiresPermissions("system:dict:export")
|
||||
@PostMapping("/export")
|
||||
public void export (HttpServletResponse response, SysDictData dictData) {
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
public void export (HttpServletResponse response, SysDictDataListReq sysDictDataListReq) {
|
||||
// TODO 需要重写导出查询
|
||||
PageQueryModel<SysDictData> list = dictDataService.selectDictDataList(SysDictDataPageQueryModel.reqBuild(sysDictDataListReq));
|
||||
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
||||
util.exportExcel(response, list, "字典数据");
|
||||
util.exportExcel(response, list.getDataList(), "字典数据");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,7 +62,7 @@ public class SysDictDataController extends BaseController {
|
|||
@RequiresPermissions("system:dict:query")
|
||||
@GetMapping(value = "/{dictCode}")
|
||||
public Result getInfo (@PathVariable("dictCode") Long dictCode) {
|
||||
return success(dictDataService.selectDictDataById(dictCode));
|
||||
return success(dictDataService.getOneById(dictCode));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,7 +85,8 @@ public class SysDictDataController extends BaseController {
|
|||
@PostMapping
|
||||
public Result add (@Validated @RequestBody SysDictData dict) {
|
||||
dict.setCreateBy(SecurityUtils.getUsername());
|
||||
return toAjax(dictDataService.insertDictData(dict));
|
||||
dictDataService.insertDictData(dict);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,7 +97,8 @@ public class SysDictDataController extends BaseController {
|
|||
@PutMapping
|
||||
public Result edit (@Validated @RequestBody SysDictData dict) {
|
||||
dict.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(dictDataService.updateDictData(dict));
|
||||
dictDataService.updateDictData(dict);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -64,7 +64,8 @@ public class SysDictTypeController extends BaseController {
|
|||
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dict.setCreateBy(SecurityUtils.getUsername());
|
||||
return toAjax(dictTypeService.insertDictType(dict));
|
||||
dictTypeService.insertDictType(dict);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,7 +79,8 @@ public class SysDictTypeController extends BaseController {
|
|||
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dict.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(dictTypeService.updateDictType(dict));
|
||||
dictTypeService.updateDictType(dict);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
import com.muyu.system.domain.SysConfig;
|
||||
|
||||
/**
|
||||
* 配置管理
|
||||
* @author DongZl
|
||||
* @description: 配置mybatis配置
|
||||
* @Date 2023-11-13 上午 10:05
|
||||
|
|
|
@ -13,14 +13,6 @@ import java.util.List;
|
|||
* @author muyu
|
||||
*/
|
||||
public interface SysDeptMapper extends BaseMapper<SysDept> {
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
*
|
||||
* @param dept 部门信息
|
||||
*
|
||||
* @return 部门信息集合
|
||||
*/
|
||||
public List<SysDept> selectDeptList (SysDept dept);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询部门树信息
|
||||
|
@ -42,41 +34,6 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
|
|||
*/
|
||||
public int selectNormalChildrenDeptById (Long deptId);
|
||||
|
||||
/**
|
||||
* 是否存在子节点
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int hasChildByDeptId (Long deptId);
|
||||
|
||||
/**
|
||||
* 查询部门是否存在用户
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int checkDeptExistUser (Long deptId);
|
||||
|
||||
/**
|
||||
* 校验部门名称是否唯一
|
||||
*
|
||||
* @param deptName 部门名称
|
||||
* @param parentId 父部门ID
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public SysDept checkDeptNameUnique (@Param("deptName") String deptName, @Param("parentId") Long parentId);
|
||||
|
||||
/**
|
||||
* 修改所在部门正常状态
|
||||
*
|
||||
* @param deptIds 部门ID组
|
||||
*/
|
||||
public void updateDeptStatusNormal (Long[] deptIds);
|
||||
|
||||
/**
|
||||
* 修改子元素关系
|
||||
*
|
||||
|
@ -86,12 +43,4 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
|
|||
*/
|
||||
public int updateDeptChildren (@Param("depts") List<SysDept> depts);
|
||||
|
||||
/**
|
||||
* 删除部门管理信息
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDeptById (Long deptId);
|
||||
}
|
||||
|
|
|
@ -12,95 +12,5 @@ import java.util.List;
|
|||
* @author muyu
|
||||
*/
|
||||
public interface SysDictDataMapper extends BaseMapper<SysDictData> {
|
||||
/**
|
||||
* 根据条件分页查询字典数据
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
*
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
public List<SysDictData> selectDictDataList (SysDictData dictData);
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
*
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
public List<SysDictData> selectDictDataByType (String dictType);
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典键值查询字典数据信息
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictValue 字典键值
|
||||
*
|
||||
* @return 字典标签
|
||||
*/
|
||||
public String selectDictLabel (@Param("dictType") String dictType, @Param("dictValue") String dictValue);
|
||||
|
||||
/**
|
||||
* 根据字典数据ID查询信息
|
||||
*
|
||||
* @param dictCode 字典数据ID
|
||||
*
|
||||
* @return 字典数据
|
||||
*/
|
||||
public SysDictData selectDictDataById (Long dictCode);
|
||||
|
||||
/**
|
||||
* 查询字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
*
|
||||
* @return 字典数据
|
||||
*/
|
||||
public int countDictDataByType (String dictType);
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典数据信息
|
||||
*
|
||||
* @param dictCode 字典数据ID
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDictDataById (Long dictCode);
|
||||
|
||||
/**
|
||||
* 批量删除字典数据信息
|
||||
*
|
||||
* @param dictCodes 需要删除的字典数据ID
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDictDataByIds (Long[] dictCodes);
|
||||
|
||||
/**
|
||||
* 新增字典数据信息
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDictData (SysDictData dictData);
|
||||
|
||||
/**
|
||||
* 修改字典数据信息
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDictData (SysDictData dictData);
|
||||
|
||||
/**
|
||||
* 同步修改字典类型
|
||||
*
|
||||
* @param oldDictType 旧字典类型
|
||||
* @param newDictType 新旧字典类型
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDictDataType (@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType);
|
||||
}
|
||||
|
|
|
@ -11,82 +11,5 @@ import java.util.List;
|
|||
* @author muyu
|
||||
*/
|
||||
public interface SysDictTypeMapper extends BaseMapper<SysDictType> {
|
||||
/**
|
||||
* 根据条件分页查询字典类型
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
*
|
||||
* @return 字典类型集合信息
|
||||
*/
|
||||
public List<SysDictType> selectDictTypeList (SysDictType dictType);
|
||||
|
||||
/**
|
||||
* 根据所有字典类型
|
||||
*
|
||||
* @return 字典类型集合信息
|
||||
*/
|
||||
public List<SysDictType> selectDictTypeAll ();
|
||||
|
||||
/**
|
||||
* 根据字典类型ID查询信息
|
||||
*
|
||||
* @param dictId 字典类型ID
|
||||
*
|
||||
* @return 字典类型
|
||||
*/
|
||||
public SysDictType selectDictTypeById (Long dictId);
|
||||
|
||||
/**
|
||||
* 根据字典类型查询信息
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
*
|
||||
* @return 字典类型
|
||||
*/
|
||||
public SysDictType selectDictTypeByType (String dictType);
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典信息
|
||||
*
|
||||
* @param dictId 字典ID
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDictTypeById (Long dictId);
|
||||
|
||||
/**
|
||||
* 批量删除字典类型信息
|
||||
*
|
||||
* @param dictIds 需要删除的字典ID
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDictTypeByIds (Long[] dictIds);
|
||||
|
||||
/**
|
||||
* 新增字典类型信息
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDictType (SysDictType dictType);
|
||||
|
||||
/**
|
||||
* 修改字典类型信息
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDictType (SysDictType dictType);
|
||||
|
||||
/**
|
||||
* 校验字典类型称是否唯一
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public SysDictType checkDictTypeUnique (String dictType);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,7 @@ package com.muyu.system.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.core.web.page.PageQueryModel;
|
||||
import com.muyu.common.system.domain.SysDictData;
|
||||
import com.muyu.common.system.domain.SysDictType;
|
||||
import com.muyu.system.domain.model.SysDictDataPageQueryModel;
|
||||
import com.muyu.system.domain.model.SysDictTypePageQueryModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -18,11 +16,11 @@ public interface SysDictDataService extends IService<SysDictData> {
|
|||
/**
|
||||
* 根据条件分页查询字典数据
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
* @param pageQueryModel 字典数据信息
|
||||
*
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
public List<SysDictData> selectDictDataList (SysDictData dictData);
|
||||
public PageQueryModel<SysDictData> selectDictDataList (SysDictDataPageQueryModel pageQueryModel);
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典键值查询字典数据信息
|
||||
|
@ -41,7 +39,7 @@ public interface SysDictDataService extends IService<SysDictData> {
|
|||
*
|
||||
* @return 字典数据
|
||||
*/
|
||||
public SysDictData selectDictDataById (Long dictCode);
|
||||
public SysDictData getOneById(Long dictCode);
|
||||
|
||||
/**
|
||||
* 批量删除字典数据信息
|
||||
|
@ -54,20 +52,48 @@ public interface SysDictDataService extends IService<SysDictData> {
|
|||
* 新增保存字典数据信息
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDictData (SysDictData dictData);
|
||||
public void insertDictData (SysDictData dictData);
|
||||
|
||||
/**
|
||||
* 修改保存字典数据信息
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDictData (SysDictData dictData);
|
||||
public void updateDictData (SysDictData dictData);
|
||||
|
||||
PageQueryModel<SysDictData> pageQuery(SysDictDataPageQueryModel sysDictDataPageQueryModel);
|
||||
|
||||
/**
|
||||
* 查询所有非禁用的字典
|
||||
* @return 非禁用字典集合
|
||||
*/
|
||||
List<SysDictData> findAllByEnable();
|
||||
|
||||
/**
|
||||
* 通过旧的字典类型修改为新字典类型
|
||||
* @param oldDictType 旧字典类型
|
||||
* @param newDictType 新字典类型
|
||||
*/
|
||||
void updateDictDataType(String oldDictType, String newDictType);
|
||||
|
||||
/**
|
||||
* 通过字典类型获取旗下所有字典值
|
||||
* @param dictType 字典类型
|
||||
* @return 所有字典值集合
|
||||
*/
|
||||
List<SysDictData> selectDictDataByType(String dictType);
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典下总数
|
||||
* @param dictType 字典类型
|
||||
* @return 总数
|
||||
*/
|
||||
long countDictDataByType(String dictType);
|
||||
/**
|
||||
* 根据字典类型查询是否有子集
|
||||
* @param dictType 字典类型
|
||||
* @return 含有:true 不含有:false
|
||||
*/
|
||||
boolean isChildByType(String dictType);
|
||||
}
|
||||
|
|
|
@ -86,16 +86,14 @@ public interface SysDictTypeService extends IService<SysDictType> {
|
|||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDictType (SysDictType dictType);
|
||||
public void insertDictType (SysDictType dictType);
|
||||
|
||||
/**
|
||||
* 修改保存字典类型信息
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDictType (SysDictType dictType);
|
||||
public void updateDictType (SysDictType dictType);
|
||||
|
||||
/**
|
||||
* 校验字典类型称是否唯一
|
||||
|
|
|
@ -229,4 +229,11 @@ public interface SysUserService extends IService<SysUser> {
|
|||
public String importUser (List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||
|
||||
PageQueryModel<SysUser> pageQuery(SysUserPageQueryModel sysUserPageQueryModel);
|
||||
|
||||
/**
|
||||
* 检查部门下是否含有用户
|
||||
* @param deptId 部门ID
|
||||
* @return 是:true 否:false
|
||||
*/
|
||||
boolean checkDeptExistUser(Long deptId);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.muyu.system.domain.vo.TreeSelect;
|
|||
import com.muyu.system.mapper.SysDeptMapper;
|
||||
import com.muyu.system.mapper.SysRoleMapper;
|
||||
import com.muyu.system.service.SysDeptService;
|
||||
import com.muyu.system.service.SysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
@ -44,6 +45,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
|
|||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<SysDept> queryList(SysDeptPageQueryModel sysDeptPageQueryModel) {
|
||||
|
@ -171,8 +175,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
|
|||
*/
|
||||
@Override
|
||||
public boolean hasChildByDeptId (Long deptId) {
|
||||
int result = deptMapper.hasChildByDeptId(deptId);
|
||||
return result > 0;
|
||||
LambdaQueryWrapper<SysDept> lambdaQueryWrapper = new LambdaQueryWrapper<SysDept>()
|
||||
.eq(SysDept::getDeptId, deptId)
|
||||
.eq(SysDept::getDelFlag, SysNormalDisableEnum.ENABLE.getCode());
|
||||
return this.count(lambdaQueryWrapper) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,8 +190,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
|
|||
*/
|
||||
@Override
|
||||
public boolean checkDeptExistUser (Long deptId) {
|
||||
int result = deptMapper.checkDeptExistUser(deptId);
|
||||
return result > 0;
|
||||
return sysUserService.checkDeptExistUser(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.enums.SysNormalDisableEnum;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.web.page.PageQueryModel;
|
||||
import com.muyu.common.security.utils.DictUtils;
|
||||
import com.muyu.common.system.domain.SysDictData;
|
||||
import com.muyu.common.system.domain.SysDictType;
|
||||
import com.muyu.system.domain.model.SysDictDataPageQueryModel;
|
||||
import com.muyu.system.domain.model.SysDictTypePageQueryModel;
|
||||
import com.muyu.system.mapper.SysDictDataMapper;
|
||||
import com.muyu.system.service.SysDictDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 字典 业务层处理
|
||||
|
@ -38,8 +38,14 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
|||
* @return 字典数据集合信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysDictData> selectDictDataList (SysDictData dictData) {
|
||||
return dictDataMapper.selectDictDataList(dictData);
|
||||
public PageQueryModel<SysDictData> selectDictDataList (SysDictDataPageQueryModel pageQueryModel) {
|
||||
LambdaQueryWrapper<SysDictData> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(StringUtils.isNotNull(pageQueryModel.getDictType()),SysDictData::getDictType, pageQueryModel.getDictType());
|
||||
lambdaQueryWrapper.like(StringUtils.isNotNull(pageQueryModel.getDictLabel()),SysDictData::getDictLabel, pageQueryModel.getDictLabel());
|
||||
lambdaQueryWrapper.eq(StringUtils.isNotNull(pageQueryModel.getStatus()),SysDictData::getStatus, pageQueryModel.getStatus());
|
||||
Page<SysDictData> sysDictDataPage = this.page(pageQueryModel.buildPage(), lambdaQueryWrapper);
|
||||
|
||||
return PageQueryModel.of(sysDictDataPage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +58,13 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
|||
*/
|
||||
@Override
|
||||
public String selectDictLabel (String dictType, String dictValue) {
|
||||
return dictDataMapper.selectDictLabel(dictType, dictValue);
|
||||
Assert.notNull(dictType, "字典类型 不可为空");
|
||||
Assert.notNull(dictValue, "字典键值 不可为空");
|
||||
LambdaQueryWrapper<SysDictData> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(SysDictData::getDictType, dictType);
|
||||
lambdaQueryWrapper.eq(SysDictData::getDictValue, dictValue);
|
||||
SysDictData sysDictData = this.getOne(lambdaQueryWrapper);
|
||||
return sysDictData.getDictLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,8 +75,10 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
|||
* @return 字典数据
|
||||
*/
|
||||
@Override
|
||||
public SysDictData selectDictDataById (Long dictCode) {
|
||||
return dictDataMapper.selectDictDataById(dictCode);
|
||||
public SysDictData getOneById(Long dictCode) {
|
||||
LambdaQueryWrapper<SysDictData> lambdaQueryWrapper = new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(SysDictData::getDictCode, dictCode);
|
||||
return this.getOne(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,10 +89,12 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
|||
@Override
|
||||
public void deleteDictDataByIds (Long[] dictCodes) {
|
||||
for (Long dictCode : dictCodes) {
|
||||
SysDictData data = selectDictDataById(dictCode);
|
||||
dictDataMapper.deleteDictDataById(dictCode);
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
|
||||
DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
SysDictData data = this.getOneById(dictCode);
|
||||
LambdaQueryWrapper<SysDictData> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(SysDictData::getDictCode, dictCode);
|
||||
this.remove(lambdaQueryWrapper);
|
||||
List<SysDictData> sysDictDataList = this.selectDictDataByType(data.getDictType());
|
||||
DictUtils.setDictCache(data.getDictType(), sysDictDataList);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,34 +102,26 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
|||
* 新增保存字典数据信息
|
||||
*
|
||||
* @param data 字典数据信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDictData (SysDictData data) {
|
||||
int row = dictDataMapper.insertDictData(data);
|
||||
if (row > 0) {
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
|
||||
DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
public void insertDictData (SysDictData data) {
|
||||
if (this.save(data)) {
|
||||
List<SysDictData> dictDataList = this.selectDictDataByType(data.getDictType());
|
||||
DictUtils.setDictCache(data.getDictType(), dictDataList);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存字典数据信息
|
||||
*
|
||||
* @param data 字典数据信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDictData (SysDictData data) {
|
||||
int row = dictDataMapper.updateDictData(data);
|
||||
if (row > 0) {
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
|
||||
DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
public void updateDictData (SysDictData data) {
|
||||
if (this.updateById(data)) {
|
||||
List<SysDictData> dictDataList = this.selectDictDataByType(data.getDictType());
|
||||
DictUtils.setDictCache(data.getDictType(), dictDataList);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -125,4 +133,71 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
|||
Page<SysDictData> page = this.page(sysDictdataPageQueryModel.buildPage(), queryWrapper);
|
||||
return PageQueryModel.of(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有非禁用的字典
|
||||
* @return 非禁用字典集合
|
||||
*/
|
||||
@Override
|
||||
public List<SysDictData> findAllByEnable() {
|
||||
LambdaQueryWrapper<SysDictData> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(SysDictData::getStatus, SysNormalDisableEnum.ENABLE.getCode());
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过旧的字典类型修改为新字典类型
|
||||
*
|
||||
* @param oldDictType 旧字典类型
|
||||
* @param newDictType 新字典类型
|
||||
*/
|
||||
@Override
|
||||
public void updateDictDataType(String oldDictType, String newDictType) {
|
||||
Assert.notNull(oldDictType, "旧字典类型不可为空");
|
||||
Assert.notNull(newDictType, "新字典类型不可为空");
|
||||
LambdaUpdateWrapper<SysDictData> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.set(SysDictData::getDictType, newDictType);
|
||||
lambdaUpdateWrapper.eq(SysDictData::getDictType, oldDictType);
|
||||
this.update(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过字典类型获取旗下所有字典值
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 所有字典值集合
|
||||
*/
|
||||
@Override
|
||||
public List<SysDictData> selectDictDataByType(String dictType) {
|
||||
LambdaQueryWrapper<SysDictData> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(SysDictData::getDictType, dictType);
|
||||
lambdaQueryWrapper.eq(SysDictData::getStatus, SysNormalDisableEnum.DISABLE.getCode());
|
||||
lambdaQueryWrapper.orderByAsc(SysDictData::getDictSort);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典下总数
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 总数
|
||||
*/
|
||||
@Override
|
||||
public long countDictDataByType(String dictType) {
|
||||
Assert.notNull(dictType, "字典类型不可为空");
|
||||
LambdaQueryWrapper<SysDictData> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(SysDictData::getDictType, dictType);
|
||||
return this.count(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询是否有子集
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 含有:true 不含有:false
|
||||
*/
|
||||
@Override
|
||||
public boolean isChildByType(String dictType) {
|
||||
return countDictDataByType(dictType) > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.constant.UserConstants;
|
||||
import com.muyu.common.core.enums.SysNormalDisableEnum;
|
||||
import com.muyu.common.core.enums.SysWhetherEnum;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.web.page.PageQueryModel;
|
||||
|
@ -13,16 +15,15 @@ import com.muyu.common.system.domain.SysDictType;
|
|||
import com.muyu.system.domain.model.SysDictTypePageQueryModel;
|
||||
import com.muyu.system.mapper.SysDictDataMapper;
|
||||
import com.muyu.system.mapper.SysDictTypeMapper;
|
||||
import com.muyu.system.service.SysDictDataService;
|
||||
import com.muyu.system.service.SysDictTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -36,7 +37,7 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
|
|||
private SysDictTypeMapper dictTypeMapper;
|
||||
|
||||
@Autowired
|
||||
private SysDictDataMapper dictDataMapper;
|
||||
private SysDictDataService sysDictDataService;
|
||||
|
||||
@Override
|
||||
public PageQueryModel<SysDictType> pageQuery(SysDictTypePageQueryModel sysDictDataPageQueryModel) {
|
||||
|
@ -67,7 +68,18 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
|
|||
*/
|
||||
@Override
|
||||
public List<SysDictType> selectDictTypeList (SysDictType dictType) {
|
||||
return dictTypeMapper.selectDictTypeList(dictType);
|
||||
LambdaQueryWrapper<SysDictType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.like(StringUtils.isNotEmpty(dictType.getDictName()),SysDictType::getDictName, dictType.getDictName());
|
||||
lambdaQueryWrapper.eq(StringUtils.isNotEmpty(dictType.getStatus()),SysDictType::getStatus, dictType.getStatus());
|
||||
lambdaQueryWrapper.like(StringUtils.isNotEmpty(dictType.getDictType()),SysDictType::getDictType, dictType.getDictType());
|
||||
Map<String, Object> params = dictType.getParams();
|
||||
Date beginTime = (Date) params.get("beginTime");
|
||||
Date endTime = (Date) params.get("endTime");
|
||||
lambdaQueryWrapper.between(
|
||||
beginTime != null && endTime != null,
|
||||
SysDictType::getCreateTime, beginTime, endTime
|
||||
);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,7 +89,7 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
|
|||
*/
|
||||
@Override
|
||||
public List<SysDictType> selectDictTypeAll () {
|
||||
return dictTypeMapper.selectDictTypeAll();
|
||||
return this.list();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,7 +105,7 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
|
|||
if (StringUtils.isNotEmpty(dictDatas)) {
|
||||
return dictDatas;
|
||||
}
|
||||
dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
||||
dictDatas = sysDictDataService.selectDictDataByType(dictType);
|
||||
if (StringUtils.isNotEmpty(dictDatas)) {
|
||||
DictUtils.setDictCache(dictType, dictDatas);
|
||||
return dictDatas;
|
||||
|
@ -110,7 +122,7 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
|
|||
*/
|
||||
@Override
|
||||
public SysDictType selectDictTypeById (Long dictId) {
|
||||
return dictTypeMapper.selectDictTypeById(dictId);
|
||||
return this.getById(dictId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,7 +134,9 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
|
|||
*/
|
||||
@Override
|
||||
public SysDictType selectDictTypeByType (String dictType) {
|
||||
return dictTypeMapper.selectDictTypeByType(dictType);
|
||||
LambdaQueryWrapper<SysDictType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(SysDictType::getDictType, dictType);
|
||||
return getOne(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,10 +148,10 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
|
|||
public void deleteDictTypeByIds (Long[] dictIds) {
|
||||
for (Long dictId : dictIds) {
|
||||
SysDictType dictType = selectDictTypeById(dictId);
|
||||
if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) {
|
||||
if (sysDictDataService.isChildByType(dictType.getDictType())) {
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
|
||||
}
|
||||
dictTypeMapper.deleteDictTypeById(dictId);
|
||||
this.removeById(dictId);
|
||||
DictUtils.removeDictCache(dictType.getDictType());
|
||||
}
|
||||
}
|
||||
|
@ -147,11 +161,16 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
|
|||
*/
|
||||
@Override
|
||||
public void loadingDictCache () {
|
||||
SysDictData dictData = new SysDictData();
|
||||
dictData.setStatus("0");
|
||||
Map<String, List<SysDictData>> dictDataMap = dictDataMapper.selectDictDataList(dictData).stream().collect(Collectors.groupingBy(SysDictData::getDictType));
|
||||
List<SysDictData> sysDictDataEnableList = sysDictDataService.findAllByEnable();
|
||||
Map<String, List<SysDictData>> dictDataMap = sysDictDataEnableList.stream()
|
||||
.collect(Collectors.groupingBy(SysDictData::getDictType));
|
||||
for (Map.Entry<String, List<SysDictData>> entry : dictDataMap.entrySet()) {
|
||||
DictUtils.setDictCache(entry.getKey(), entry.getValue().stream().sorted(Comparator.comparing(SysDictData::getDictSort)).collect(Collectors.toList()));
|
||||
DictUtils.setDictCache(
|
||||
entry.getKey(),
|
||||
entry.getValue().stream()
|
||||
.sorted(Comparator.comparing(SysDictData::getDictSort))
|
||||
.toList()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,32 +199,26 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDictType (SysDictType dict) {
|
||||
int row = dictTypeMapper.insertDictType(dict);
|
||||
if (row > 0) {
|
||||
public void insertDictType (SysDictType dict) {
|
||||
if (this.save(dict)) {
|
||||
DictUtils.setDictCache(dict.getDictType(), null);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存字典类型信息
|
||||
*
|
||||
* @param dict 字典类型信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateDictType (SysDictType dict) {
|
||||
SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId());
|
||||
dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType());
|
||||
int row = dictTypeMapper.updateDictType(dict);
|
||||
if (row > 0) {
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType());
|
||||
DictUtils.setDictCache(dict.getDictType(), dictDatas);
|
||||
public void updateDictType (SysDictType dict) {
|
||||
SysDictType oldDict = this.getById(dict.getDictId());
|
||||
sysDictDataService.updateDictDataType(oldDict.getDictType(), dict.getDictType());
|
||||
if (this.updateById(dict)) {
|
||||
List<SysDictData> dictDataList = sysDictDataService.selectDictDataByType(dict.getDictType());
|
||||
DictUtils.setDictCache(dict.getDictType(), dictDataList);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,9 +230,12 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
|
|||
*/
|
||||
@Override
|
||||
public boolean checkDictTypeUnique (SysDictType dict) {
|
||||
Assert.notNull(dict.getDictType(), "字典类型不可为空");
|
||||
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
|
||||
SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
|
||||
if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) {
|
||||
LambdaQueryWrapper<SysDictType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(SysDictType::getDictType, dict.getDictType());
|
||||
lambdaQueryWrapper.ne(dict.getDictId() != null, SysDictType::getDictId, dictId);
|
||||
if (this.count(lambdaQueryWrapper) > 0) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.constant.UserConstants;
|
||||
import com.muyu.common.core.enums.SysNormalDisableEnum;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
import com.muyu.common.core.utils.SpringUtils;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
|
@ -516,9 +517,18 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
Page<SysUser> page = this.page(sysUserPageQueryModel.buildPage(), queryWrapper);
|
||||
return PageQueryModel.of(page);
|
||||
}
|
||||
//nickName
|
||||
//phonenumber
|
||||
//status
|
||||
//beginTime
|
||||
//endTime
|
||||
|
||||
/**
|
||||
* 检查部门下是否含有用户
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 是:true 否:false
|
||||
*/
|
||||
@Override
|
||||
public boolean checkDeptExistUser(Long deptId) {
|
||||
LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getDeptId, deptId)
|
||||
.eq(SysUser::getDelFlag, SysNormalDisableEnum.ENABLE.getCode());
|
||||
return this.count(lambdaQueryWrapper) > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,26 +38,6 @@
|
|||
from sys_dept d
|
||||
</sql>
|
||||
|
||||
<select id="selectDeptList" parameterType="com.muyu.common.system.domain.SysDept" resultMap="SysDeptResult">
|
||||
<include refid="selectDeptVo"/>
|
||||
where d.del_flag = '0'
|
||||
<if test="deptId != null and deptId != 0">
|
||||
AND dept_id = #{deptId}
|
||||
</if>
|
||||
<if test="parentId != null and parentId != 0">
|
||||
AND parent_id = #{parentId}
|
||||
</if>
|
||||
<if test="deptName != null and deptName != ''">
|
||||
AND dept_name like concat('%', #{deptName}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectDeptListByRoleId" resultType="Long">
|
||||
select d.dept_id
|
||||
from sys_dept d
|
||||
|
@ -70,21 +50,6 @@
|
|||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
|
||||
select count(1)
|
||||
from sys_user
|
||||
where dept_id = #{deptId}
|
||||
and del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="hasChildByDeptId" parameterType="Long" resultType="int">
|
||||
select count(1)
|
||||
from sys_dept
|
||||
where del_flag = '0'
|
||||
and parent_id = #{deptId}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
|
||||
select count(*)
|
||||
from sys_dept
|
||||
|
@ -93,11 +58,6 @@
|
|||
and find_in_set(#{deptId}, ancestors)
|
||||
</select>
|
||||
|
||||
<select id="checkDeptNameUnique" resultMap="SysDeptResult">
|
||||
<include refid="selectDeptVo"/>
|
||||
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
<update id="updateDeptChildren" parameterType="java.util.List">
|
||||
update sys_dept set ancestors =
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
|
@ -110,18 +70,4 @@
|
|||
#{item.deptId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateDeptStatusNormal" parameterType="Long">
|
||||
update sys_dept set status = '0' where dept_id in
|
||||
<foreach collection="array" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteDeptById" parameterType="Long">
|
||||
update sys_dept
|
||||
set del_flag = '2'
|
||||
where dept_id = #{deptId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -36,108 +36,4 @@
|
|||
from sys_dict_data
|
||||
</sql>
|
||||
|
||||
<select id="selectDictDataList" parameterType="com.muyu.common.system.domain.SysDictData" resultMap="SysDictDataResult">
|
||||
<include refid="selectDictDataVo"/>
|
||||
<where>
|
||||
<if test="dictType != null and dictType != ''">
|
||||
AND dict_type = #{dictType}
|
||||
</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">
|
||||
AND dict_label like concat('%', #{dictLabel}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
order by dict_sort asc
|
||||
</select>
|
||||
|
||||
<select id="selectDictDataByType" parameterType="com.muyu.common.system.domain.SysDictData" resultMap="SysDictDataResult">
|
||||
<include refid="selectDictDataVo"/>
|
||||
where status = '0' and dict_type = #{dictType} order by dict_sort asc
|
||||
</select>
|
||||
|
||||
<select id="selectDictLabel" resultType="String">
|
||||
select dict_label
|
||||
from sys_dict_data
|
||||
where dict_type = #{dictType}
|
||||
and dict_value = #{dictValue}
|
||||
</select>
|
||||
|
||||
<select id="selectDictDataById" parameterType="Long" resultMap="SysDictDataResult">
|
||||
<include refid="selectDictDataVo"/>
|
||||
where dict_code = #{dictCode}
|
||||
</select>
|
||||
|
||||
<select id="countDictDataByType" resultType="Integer">
|
||||
select count(1)
|
||||
from sys_dict_data
|
||||
where dict_type = #{dictType}
|
||||
</select>
|
||||
|
||||
<delete id="deleteDictDataById" parameterType="Long">
|
||||
delete
|
||||
from sys_dict_data
|
||||
where dict_code = #{dictCode}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDictDataByIds" parameterType="Long">
|
||||
delete from sys_dict_data where dict_code in
|
||||
<foreach collection="array" item="dictCode" open="(" separator="," close=")">
|
||||
#{dictCode}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="updateDictData" parameterType="com.muyu.common.system.domain.SysDictData">
|
||||
update sys_dict_data
|
||||
<set>
|
||||
<if test="dictSort != null">dict_sort = #{dictSort},</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">dict_label = #{dictLabel},</if>
|
||||
<if test="dictValue != null and dictValue != ''">dict_value = #{dictValue},</if>
|
||||
<if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
|
||||
<if test="cssClass != null">css_class = #{cssClass},</if>
|
||||
<if test="listClass != null">list_class = #{listClass},</if>
|
||||
<if test="isDefault != null and isDefault != ''">is_default = #{isDefault},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where dict_code = #{dictCode}
|
||||
</update>
|
||||
|
||||
<update id="updateDictDataType" parameterType="String">
|
||||
update sys_dict_data
|
||||
set dict_type = #{newDictType}
|
||||
where dict_type = #{oldDictType}
|
||||
</update>
|
||||
|
||||
<insert id="insertDictData" parameterType="com.muyu.common.system.domain.SysDictData">
|
||||
insert into sys_dict_data(
|
||||
<if test="dictSort != null">dict_sort,</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">dict_label,</if>
|
||||
<if test="dictValue != null and dictValue != ''">dict_value,</if>
|
||||
<if test="dictType != null and dictType != ''">dict_type,</if>
|
||||
<if test="cssClass != null and cssClass != ''">css_class,</if>
|
||||
<if test="listClass != null and listClass != ''">list_class,</if>
|
||||
<if test="isDefault != null and isDefault != ''">is_default,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="dictSort != null">#{dictSort},</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">#{dictLabel},</if>
|
||||
<if test="dictValue != null and dictValue != ''">#{dictValue},</if>
|
||||
<if test="dictType != null and dictType != ''">#{dictType},</if>
|
||||
<if test="cssClass != null and cssClass != ''">#{cssClass},</if>
|
||||
<if test="listClass != null and listClass != ''">#{listClass},</if>
|
||||
<if test="isDefault != null and isDefault != ''">#{isDefault},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -19,89 +19,4 @@
|
|||
select dict_id, dict_name, dict_type, status, create_by, create_time, remark
|
||||
from sys_dict_type
|
||||
</sql>
|
||||
|
||||
<select id="selectDictTypeList" parameterType="com.muyu.common.system.domain.SysDictType" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
<where>
|
||||
<if test="dictName != null and dictName != ''">
|
||||
AND dict_name like concat('%', #{dictName}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="dictType != null and dictType != ''">
|
||||
AND dict_type like concat('%', #{dictType}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectDictTypeAll" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
</select>
|
||||
|
||||
<select id="selectDictTypeById" parameterType="Long" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
where dict_id = #{dictId}
|
||||
</select>
|
||||
|
||||
<select id="selectDictTypeByType" parameterType="String" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
where dict_type = #{dictType}
|
||||
</select>
|
||||
|
||||
<select id="checkDictTypeUnique" parameterType="String" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
where dict_type = #{dictType} limit 1
|
||||
</select>
|
||||
|
||||
<delete id="deleteDictTypeById" parameterType="Long">
|
||||
delete
|
||||
from sys_dict_type
|
||||
where dict_id = #{dictId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDictTypeByIds" parameterType="Long">
|
||||
delete from sys_dict_type where dict_id in
|
||||
<foreach collection="array" item="dictId" open="(" separator="," close=")">
|
||||
#{dictId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="updateDictType" parameterType="com.muyu.common.system.domain.SysDictType">
|
||||
update sys_dict_type
|
||||
<set>
|
||||
<if test="dictName != null and dictName != ''">dict_name = #{dictName},</if>
|
||||
<if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where dict_id = #{dictId}
|
||||
</update>
|
||||
|
||||
<insert id="insertDictType" parameterType="com.muyu.common.system.domain.SysDictType">
|
||||
insert into sys_dict_type(
|
||||
<if test="dictName != null and dictName != ''">dict_name,</if>
|
||||
<if test="dictType != null and dictType != ''">dict_type,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="dictName != null and dictName != ''">#{dictName},</if>
|
||||
<if test="dictType != null and dictType != ''">#{dictType},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue