master
wxy 2024-05-24 14:58:52 +08:00
parent 4b54b2db31
commit 985eab407b
10 changed files with 1493 additions and 0 deletions

View File

@ -0,0 +1,133 @@
package com.jing.system.controller;
import java.util.List;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jing.common.core.constant.UserConstants;
import com.jing.common.core.utils.StringUtils;
import com.jing.common.core.web.controller.BaseController;
import com.jing.common.core.web.domain.AjaxResult;
import com.jing.common.log.annotation.Log;
import com.jing.common.log.enums.BusinessType;
import com.jing.common.security.annotation.RequiresPermissions;
import com.jing.common.security.utils.SecurityUtils;
import com.jing.system.api.domain.SysDept;
import com.jing.system.service.ISysDeptService;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/dept")
public class SysDeptController extends BaseController
{
@Autowired
private ISysDeptService deptService;
/**
*
*/
@RequiresPermissions("system:dept:list")
@GetMapping("/list")
public AjaxResult list(SysDept dept)
{
List<SysDept> depts = deptService.selectDeptList(dept);
return success(depts);
}
/**
*
*/
@RequiresPermissions("system:dept:list")
@GetMapping("/list/exclude/{deptId}")
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
{
List<SysDept> depts = deptService.selectDeptList(new SysDept());
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
return success(depts);
}
/**
*
*/
@RequiresPermissions("system:dept:query")
@GetMapping(value = "/{deptId}")
public AjaxResult getInfo(@PathVariable Long deptId)
{
deptService.checkDeptDataScope(deptId);
return success(deptService.selectDeptById(deptId));
}
/**
*
*/
@RequiresPermissions("system:dept:add")
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDept dept)
{
if (!deptService.checkDeptNameUnique(dept))
{
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
dept.setCreateBy(SecurityUtils.getUsername());
return toAjax(deptService.insertDept(dept));
}
/**
*
*/
@RequiresPermissions("system:dept:edit")
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDept dept)
{
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId);
if (!deptService.checkDeptNameUnique(dept))
{
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
else if (dept.getParentId().equals(deptId))
{
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
}
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
{
return error("该部门包含未停用的子部门!");
}
dept.setUpdateBy(SecurityUtils.getUsername());
return toAjax(deptService.updateDept(dept));
}
/**
*
*/
@RequiresPermissions("system:dept:remove")
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}")
public AjaxResult remove(@PathVariable Long deptId)
{
if (deptService.hasChildByDeptId(deptId))
{
return warn("存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId))
{
return warn("部门存在用户,不允许删除");
}
deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(deptId));
}
}

View File

@ -0,0 +1,122 @@
package com.jing.system.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jing.common.core.utils.StringUtils;
import com.jing.common.core.utils.poi.ExcelUtil;
import com.jing.common.core.web.controller.BaseController;
import com.jing.common.core.web.domain.AjaxResult;
import com.jing.common.core.web.page.TableDataInfo;
import com.jing.common.log.annotation.Log;
import com.jing.common.log.enums.BusinessType;
import com.jing.common.security.annotation.RequiresPermissions;
import com.jing.common.security.utils.SecurityUtils;
import com.jing.system.api.domain.SysDictData;
import com.jing.system.service.ISysDictDataService;
import com.jing.system.service.ISysDictTypeService;
/**
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/dict/data")
public class SysDictDataController extends BaseController
{
@Autowired
private ISysDictDataService dictDataService;
@Autowired
private ISysDictTypeService dictTypeService;
@RequiresPermissions("system:dict:list")
@GetMapping("/list")
public TableDataInfo list(SysDictData dictData)
{
startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list);
}
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:dict:export")
@PostMapping("/export")
public void export(HttpServletResponse response, SysDictData dictData)
{
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
util.exportExcel(response, list, "字典数据");
}
/**
*
*/
@RequiresPermissions("system:dict:query")
@GetMapping(value = "/{dictCode}")
public AjaxResult getInfo(@PathVariable Long dictCode)
{
return success(dictDataService.selectDictDataById(dictCode));
}
/**
*
*/
@GetMapping(value = "/type/{dictType}")
public AjaxResult dictType(@PathVariable String dictType)
{
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
if (StringUtils.isNull(data))
{
data = new ArrayList<SysDictData>();
}
return success(data);
}
/**
*
*/
@RequiresPermissions("system:dict:add")
@Log(title = "字典数据", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDictData dict)
{
dict.setCreateBy(SecurityUtils.getUsername());
return toAjax(dictDataService.insertDictData(dict));
}
/**
*
*/
@RequiresPermissions("system:dict:edit")
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
{
dict.setUpdateBy(SecurityUtils.getUsername());
return toAjax(dictDataService.updateDictData(dict));
}
/**
*
*/
@RequiresPermissions("system:dict:remove")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictCodes}")
public AjaxResult remove(@PathVariable Long[] dictCodes)
{
dictDataService.deleteDictDataByIds(dictCodes);
return success();
}
}

View File

@ -0,0 +1,76 @@
package com.jing.system.mapper;
import java.util.List;
import com.jing.system.domain.SysConfig;
/**
*
*
* @author ruoyi
*/
public interface SysConfigMapper
{
/**
*
*
* @param config
* @return
*/
public SysConfig selectConfig(SysConfig config);
/**
* ID
*
* @param configId ID
* @return
*/
public SysConfig selectConfigById(Long configId);
/**
*
*
* @param config
* @return
*/
public List<SysConfig> selectConfigList(SysConfig config);
/**
*
*
* @param configKey
* @return
*/
public SysConfig checkConfigKeyUnique(String configKey);
/**
*
*
* @param config
* @return
*/
public int insertConfig(SysConfig config);
/**
*
*
* @param config
* @return
*/
public int updateConfig(SysConfig config);
/**
*
*
* @param configId ID
* @return
*/
public int deleteConfigById(Long configId);
/**
*
*
* @param configIds ID
* @return
*/
public int deleteConfigByIds(Long[] configIds);
}

View File

@ -0,0 +1,118 @@
package com.jing.system.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.jing.system.api.domain.SysDept;
/**
*
*
* @author ruoyi
*/
public interface SysDeptMapper
{
/**
*
*
* @param dept
* @return
*/
public List<SysDept> selectDeptList(SysDept dept);
/**
* ID
*
* @param roleId ID
* @param deptCheckStrictly
* @return
*/
public List<Long> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);
/**
* ID
*
* @param deptId ID
* @return
*/
public SysDept selectDeptById(Long deptId);
/**
* ID
*
* @param deptId ID
* @return
*/
public List<SysDept> selectChildrenDeptById(Long deptId);
/**
* ID
*
* @param deptId ID
* @return
*/
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 dept
* @return
*/
public int insertDept(SysDept dept);
/**
*
*
* @param dept
* @return
*/
public int updateDept(SysDept dept);
/**
*
*
* @param deptIds ID
*/
public void updateDeptStatusNormal(Long[] deptIds);
/**
*
*
* @param depts
* @return
*/
public int updateDeptChildren(@Param("depts") List<SysDept> depts);
/**
*
*
* @param deptId ID
* @return
*/
public int deleteDeptById(Long deptId);
}

View File

@ -0,0 +1,95 @@
package com.jing.system.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.jing.system.api.domain.SysDictData;
/**
*
*
* @author ruoyi
*/
public interface SysDictDataMapper
{
/**
*
*
* @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);
}

View File

@ -0,0 +1,213 @@
package com.jing.system.service.impl;
import java.util.Collection;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jing.common.core.constant.CacheConstants;
import com.jing.common.core.constant.UserConstants;
import com.jing.common.core.exception.ServiceException;
import com.jing.common.core.text.Convert;
import com.jing.common.core.utils.StringUtils;
import com.jing.common.redis.service.RedisService;
import com.jing.system.domain.SysConfig;
import com.jing.system.mapper.SysConfigMapper;
import com.jing.system.service.ISysConfigService;
/**
*
*
* @author ruoyi
*/
@Service
public class SysConfigServiceImpl implements ISysConfigService
{
@Autowired
private SysConfigMapper configMapper;
@Autowired
private RedisService redisService;
/**
*
*/
@PostConstruct
public void init()
{
loadingConfigCache();
}
/**
*
*
* @param configId ID
* @return
*/
@Override
public SysConfig selectConfigById(Long configId)
{
SysConfig config = new SysConfig();
config.setConfigId(configId);
return configMapper.selectConfig(config);
}
/**
*
*
* @param configKey key
* @return
*/
@Override
public String selectConfigByKey(String configKey)
{
String configValue = Convert.toStr(redisService.getCacheObject(getCacheKey(configKey)));
if (StringUtils.isNotEmpty(configValue))
{
return configValue;
}
SysConfig config = new SysConfig();
config.setConfigKey(configKey);
SysConfig retConfig = configMapper.selectConfig(config);
if (StringUtils.isNotNull(retConfig))
{
redisService.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
return retConfig.getConfigValue();
}
return StringUtils.EMPTY;
}
/**
*
*
* @param config
* @return
*/
@Override
public List<SysConfig> selectConfigList(SysConfig config)
{
return configMapper.selectConfigList(config);
}
/**
*
*
* @param config
* @return
*/
@Override
public int insertConfig(SysConfig config)
{
int row = configMapper.insertConfig(config);
if (row > 0)
{
redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
}
return row;
}
/**
*
*
* @param config
* @return
*/
@Override
public int updateConfig(SysConfig config)
{
SysConfig temp = configMapper.selectConfigById(config.getConfigId());
if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey()))
{
redisService.deleteObject(getCacheKey(temp.getConfigKey()));
}
int row = configMapper.updateConfig(config);
if (row > 0)
{
redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
}
return row;
}
/**
*
*
* @param configIds ID
*/
@Override
public void deleteConfigByIds(Long[] configIds)
{
for (Long configId : configIds)
{
SysConfig config = selectConfigById(configId);
if (StringUtils.equals(UserConstants.YES, config.getConfigType()))
{
throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
}
configMapper.deleteConfigById(configId);
redisService.deleteObject(getCacheKey(config.getConfigKey()));
}
}
/**
*
*/
@Override
public void loadingConfigCache()
{
List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
for (SysConfig config : configsList)
{
redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
}
}
/**
*
*/
@Override
public void clearConfigCache()
{
Collection<String> keys = redisService.keys(CacheConstants.SYS_CONFIG_KEY + "*");
redisService.deleteObject(keys);
}
/**
*
*/
@Override
public void resetConfigCache()
{
clearConfigCache();
loadingConfigCache();
}
/**
*
*
* @param config
* @return
*/
@Override
public boolean checkConfigKeyUnique(SysConfig config)
{
Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId();
SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey());
if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue())
{
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/**
* cache key
*
* @param configKey
* @return key
*/
private String getCacheKey(String configKey)
{
return CacheConstants.SYS_CONFIG_KEY + configKey;
}
}

View File

@ -0,0 +1,338 @@
package com.jing.system.service.impl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jing.common.core.constant.UserConstants;
import com.jing.common.core.exception.ServiceException;
import com.jing.common.core.text.Convert;
import com.jing.common.core.utils.SpringUtils;
import com.jing.common.core.utils.StringUtils;
import com.jing.common.datascope.annotation.DataScope;
import com.jing.common.security.utils.SecurityUtils;
import com.jing.system.api.domain.SysDept;
import com.jing.system.api.domain.SysRole;
import com.jing.system.api.domain.SysUser;
import com.jing.system.domain.vo.TreeSelect;
import com.jing.system.mapper.SysDeptMapper;
import com.jing.system.mapper.SysRoleMapper;
import com.jing.system.service.ISysDeptService;
/**
*
*
* @author ruoyi
*/
@Service
public class SysDeptServiceImpl implements ISysDeptService
{
@Autowired
private SysDeptMapper deptMapper;
@Autowired
private SysRoleMapper roleMapper;
/**
*
*
* @param dept
* @return
*/
@Override
@DataScope(deptAlias = "d")
public List<SysDept> selectDeptList(SysDept dept)
{
return deptMapper.selectDeptList(dept);
}
/**
*
*
* @param dept
* @return
*/
@Override
public List<TreeSelect> selectDeptTreeList(SysDept dept)
{
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
return buildDeptTreeSelect(depts);
}
/**
*
*
* @param depts
* @return
*/
@Override
public List<SysDept> buildDeptTree(List<SysDept> depts)
{
List<SysDept> returnList = new ArrayList<SysDept>();
List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
for (SysDept dept : depts)
{
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(dept.getParentId()))
{
recursionFn(depts, dept);
returnList.add(dept);
}
}
if (returnList.isEmpty())
{
returnList = depts;
}
return returnList;
}
/**
*
*
* @param depts
* @return
*/
@Override
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts)
{
List<SysDept> deptTrees = buildDeptTree(depts);
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
}
/**
* ID
*
* @param roleId ID
* @return
*/
@Override
public List<Long> selectDeptListByRoleId(Long roleId)
{
SysRole role = roleMapper.selectRoleById(roleId);
return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
}
/**
* ID
*
* @param deptId ID
* @return
*/
@Override
public SysDept selectDeptById(Long deptId)
{
return deptMapper.selectDeptById(deptId);
}
/**
* ID
*
* @param deptId ID
* @return
*/
@Override
public int selectNormalChildrenDeptById(Long deptId)
{
return deptMapper.selectNormalChildrenDeptById(deptId);
}
/**
*
*
* @param deptId ID
* @return
*/
@Override
public boolean hasChildByDeptId(Long deptId)
{
int result = deptMapper.hasChildByDeptId(deptId);
return result > 0;
}
/**
*
*
* @param deptId ID
* @return true false
*/
@Override
public boolean checkDeptExistUser(Long deptId)
{
int result = deptMapper.checkDeptExistUser(deptId);
return result > 0;
}
/**
*
*
* @param dept
* @return
*/
@Override
public boolean checkDeptNameUnique(SysDept dept)
{
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
{
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/**
*
*
* @param deptId id
*/
@Override
public void checkDeptDataScope(Long deptId)
{
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
{
SysDept dept = new SysDept();
dept.setDeptId(deptId);
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
if (StringUtils.isEmpty(depts))
{
throw new ServiceException("没有权限访问部门数据!");
}
}
}
/**
*
*
* @param dept
* @return
*/
@Override
public int insertDept(SysDept dept)
{
SysDept info = deptMapper.selectDeptById(dept.getParentId());
// 如果父节点不为正常状态,则不允许新增子节点
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
{
throw new ServiceException("部门停用,不允许新增");
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept);
}
/**
*
*
* @param dept
* @return
*/
@Override
public int updateDept(SysDept dept)
{
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
{
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
String oldAncestors = oldDept.getAncestors();
dept.setAncestors(newAncestors);
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
}
int result = deptMapper.updateDept(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
&& !StringUtils.equals("0", dept.getAncestors()))
{
// 如果该部门是启用状态,则启用该部门的所有上级部门
updateParentDeptStatusNormal(dept);
}
return result;
}
/**
*
*
* @param dept
*/
private void updateParentDeptStatusNormal(SysDept dept)
{
String ancestors = dept.getAncestors();
Long[] deptIds = Convert.toLongArray(ancestors);
deptMapper.updateDeptStatusNormal(deptIds);
}
/**
*
*
* @param deptId ID
* @param newAncestors ID
* @param oldAncestors ID
*/
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors)
{
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
for (SysDept child : children)
{
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
}
if (children.size() > 0)
{
deptMapper.updateDeptChildren(children);
}
}
/**
*
*
* @param deptId ID
* @return
*/
@Override
public int deleteDeptById(Long deptId)
{
return deptMapper.deleteDeptById(deptId);
}
/**
*
*/
private void recursionFn(List<SysDept> list, SysDept t)
{
// 得到子节点列表
List<SysDept> childList = getChildList(list, t);
t.setChildren(childList);
for (SysDept tChild : childList)
{
if (hasChild(list, tChild))
{
recursionFn(list, tChild);
}
}
}
/**
*
*/
private List<SysDept> getChildList(List<SysDept> list, SysDept t)
{
List<SysDept> tlist = new ArrayList<SysDept>();
Iterator<SysDept> it = list.iterator();
while (it.hasNext())
{
SysDept n = (SysDept) it.next();
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
{
tlist.add(n);
}
}
return tlist;
}
/**
*
*/
private boolean hasChild(List<SysDept> list, SysDept t)
{
return getChildList(list, t).size() > 0 ? true : false;
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jing.system.mapper.SysConfigMapper">
<resultMap type="com.jing.system.domain.SysConfig" id="SysConfigResult">
<id property="configId" column="config_id" />
<result property="configName" column="config_name" />
<result property="configKey" column="config_key" />
<result property="configValue" column="config_value" />
<result property="configType" column="config_type" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectConfigVo">
select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark
from sys_config
</sql>
<!-- 查询条件 -->
<sql id="sqlwhereSearch">
<where>
<if test="configId !=null">
and config_id = #{configId}
</if>
<if test="configKey !=null and configKey != ''">
and config_key = #{configKey}
</if>
</where>
</sql>
<select id="selectConfig" parameterType="com.jing.system.domain.SysConfig" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
<include refid="sqlwhereSearch"/>
</select>
<select id="selectConfigList" parameterType="com.jing.system.domain.SysConfig" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
<where>
<if test="configName != null and configName != ''">
AND config_name like concat('%', #{configName}, '%')
</if>
<if test="configType != null and configType != ''">
AND config_type = #{configType}
</if>
<if test="configKey != null and configKey != ''">
AND config_key like concat('%', #{configKey}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
</select>
<select id="selectConfigById" parameterType="Long" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
where config_id = #{configId}
</select>
<select id="checkConfigKeyUnique" parameterType="String" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
where config_key = #{configKey} limit 1
</select>
<insert id="insertConfig" parameterType="com.jing.system.domain.SysConfig">
insert into sys_config (
<if test="configName != null and configName != '' ">config_name,</if>
<if test="configKey != null and configKey != '' ">config_key,</if>
<if test="configValue != null and configValue != '' ">config_value,</if>
<if test="configType != null and configType != '' ">config_type,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
create_time
)values(
<if test="configName != null and configName != ''">#{configName},</if>
<if test="configKey != null and configKey != ''">#{configKey},</if>
<if test="configValue != null and configValue != ''">#{configValue},</if>
<if test="configType != null and configType != ''">#{configType},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if>
sysdate()
)
</insert>
<update id="updateConfig" parameterType="com.jing.system.domain.SysConfig">
update sys_config
<set>
<if test="configName != null and configName != ''">config_name = #{configName},</if>
<if test="configKey != null and configKey != ''">config_key = #{configKey},</if>
<if test="configValue != null and configValue != ''">config_value = #{configValue},</if>
<if test="configType != null and configType != ''">config_type = #{configType},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
update_time = sysdate()
</set>
where config_id = #{configId}
</update>
<delete id="deleteConfigById" parameterType="Long">
delete from sys_config where config_id = #{configId}
</delete>
<delete id="deleteConfigByIds" parameterType="Long">
delete from sys_config where config_id in
<foreach item="configId" collection="array" open="(" separator="," close=")">
#{configId}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jing.system.mapper.SysDeptMapper">
<resultMap type="SysDept" id="SysDeptResult">
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="deptName" column="dept_name" />
<result property="orderNum" column="order_num" />
<result property="leader" column="leader" />
<result property="phone" column="phone" />
<result property="email" column="email" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="parentName" column="parent_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
from sys_dept d
</sql>
<select id="selectDeptList" parameterType="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
left join sys_role_dept rd on d.dept_id = rd.dept_id
where rd.role_id = #{roleId}
<if test="deptCheckStrictly">
and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
</if>
order by d.parent_id, d.order_num
</select>
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
<include refid="selectDeptVo"/>
where dept_id = #{deptId}
</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="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
select * from sys_dept where find_in_set(#{deptId}, ancestors)
</select>
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
select count(*) from sys_dept where status = 0 and del_flag = '0' 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>
<insert id="insertDept" parameterType="SysDept">
insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if>
<if test="deptName != null and deptName != ''">dept_name,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="orderNum != null">order_num,</if>
<if test="leader != null and leader != ''">leader,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="deptId != null and deptId != 0">#{deptId},</if>
<if test="parentId != null and parentId != 0">#{parentId},</if>
<if test="deptName != null and deptName != ''">#{deptName},</if>
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="leader != null and leader != ''">#{leader},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateDept" parameterType="SysDept">
update sys_dept
<set>
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="leader != null">leader = #{leader},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="email != null">email = #{email},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where dept_id = #{deptId}
</update>
<update id="updateDeptChildren" parameterType="java.util.List">
update sys_dept set ancestors =
<foreach collection="depts" item="item" index="index"
separator=" " open="case dept_id" close="end">
when #{item.deptId} then #{item.ancestors}
</foreach>
where dept_id in
<foreach collection="depts" item="item" index="index"
separator="," open="(" close=")">
#{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>

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jing.system.mapper.SysDictDataMapper">
<resultMap type="SysDictData" id="SysDictDataResult">
<id property="dictCode" column="dict_code" />
<result property="dictSort" column="dict_sort" />
<result property="dictLabel" column="dict_label" />
<result property="dictValue" column="dict_value" />
<result property="dictType" column="dict_type" />
<result property="cssClass" column="css_class" />
<result property="listClass" column="list_class" />
<result property="isDefault" column="is_default" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDictDataVo">
select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark
from sys_dict_data
</sql>
<select id="selectDictDataList" parameterType="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="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="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="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>