feat: 管理后台添加项目、apikey并加解密
This commit is contained in:
parent
dc56530d47
commit
4ea4d009a6
|
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.ruoyi.common.EncryptionService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.common.annotation.DataScope;
|
import com.ruoyi.common.annotation.DataScope;
|
||||||
|
|
@ -21,6 +23,8 @@ import com.ruoyi.system.mapper.SysDeptMapper;
|
||||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门管理 服务实现
|
* 部门管理 服务实现
|
||||||
*
|
*
|
||||||
|
|
@ -34,6 +38,8 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysRoleMapper roleMapper;
|
private SysRoleMapper roleMapper;
|
||||||
|
@Resource
|
||||||
|
private EncryptionService encryptionService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门管理数据
|
* 查询部门管理数据
|
||||||
|
|
@ -123,7 +129,14 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
@Override
|
@Override
|
||||||
public SysDept selectDeptById(Long deptId)
|
public SysDept selectDeptById(Long deptId)
|
||||||
{
|
{
|
||||||
return deptMapper.selectDeptById(deptId);
|
SysDept sysDept = deptMapper.selectDeptById(deptId);
|
||||||
|
if (sysDept.getByteApiKey() != null && !sysDept.getByteApiKey().isEmpty()) {
|
||||||
|
sysDept.setByteApiKey(encryptionService.decode(sysDept.getByteApiKey()));
|
||||||
|
}
|
||||||
|
if (sysDept.getProject() != null && !sysDept.getProject().isEmpty()) {
|
||||||
|
sysDept.setProject(encryptionService.decode(sysDept.getProject()));
|
||||||
|
}
|
||||||
|
return sysDept;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -218,6 +231,12 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
throw new ServiceException("部门停用,不允许新增");
|
throw new ServiceException("部门停用,不允许新增");
|
||||||
}
|
}
|
||||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||||
|
if (StringUtils.isNotEmpty(dept.getByteApiKey())) {
|
||||||
|
dept.setByteApiKey(encryptionService.encode(dept.getByteApiKey()));
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(dept.getProject())) {
|
||||||
|
dept.setProject(encryptionService.encode(dept.getProject()));
|
||||||
|
}
|
||||||
return deptMapper.insertDept(dept);
|
return deptMapper.insertDept(dept);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,6 +258,12 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
dept.setAncestors(newAncestors);
|
dept.setAncestors(newAncestors);
|
||||||
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
||||||
}
|
}
|
||||||
|
if (StringUtils.isNotEmpty(dept.getByteApiKey())) {
|
||||||
|
dept.setByteApiKey(encryptionService.encode(dept.getByteApiKey()));
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(dept.getProject())) {
|
||||||
|
dept.setProject(encryptionService.encode(dept.getProject()));
|
||||||
|
}
|
||||||
int result = deptMapper.updateDept(dept);
|
int result = deptMapper.updateDept(dept);
|
||||||
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
||||||
&& !StringUtils.equals("0", dept.getAncestors()))
|
&& !StringUtils.equals("0", dept.getAncestors()))
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="project" column="project" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectDeptVo">
|
<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.byte_api_key, d.status, d.del_flag, d.create_by, d.create_time
|
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.byte_api_key, d.status, d.del_flag, d.create_by, d.create_time, d.project
|
||||||
from sys_dept d
|
from sys_dept d
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
@ -103,6 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="phone != null and phone != ''">phone,</if>
|
<if test="phone != null and phone != ''">phone,</if>
|
||||||
<if test="email != null and email != ''">email,</if>
|
<if test="email != null and email != ''">email,</if>
|
||||||
<if test="byteApiKey != null">byte_api_key,</if>
|
<if test="byteApiKey != null">byte_api_key,</if>
|
||||||
|
<if test="project != null">project,</if>
|
||||||
<if test="status != null">status,</if>
|
<if test="status != null">status,</if>
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
create_time
|
create_time
|
||||||
|
|
@ -116,6 +118,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="phone != null and phone != ''">#{phone},</if>
|
<if test="phone != null and phone != ''">#{phone},</if>
|
||||||
<if test="email != null and email != ''">#{email},</if>
|
<if test="email != null and email != ''">#{email},</if>
|
||||||
<if test="byteApiKey != null">#{byteApiKey},</if>
|
<if test="byteApiKey != null">#{byteApiKey},</if>
|
||||||
|
<if test="project != null">#{project},</if>
|
||||||
<if test="status != null">#{status},</if>
|
<if test="status != null">#{status},</if>
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
sysdate()
|
sysdate()
|
||||||
|
|
@ -133,6 +136,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="phone != null">phone = #{phone},</if>
|
<if test="phone != null">phone = #{phone},</if>
|
||||||
<if test="email != null">email = #{email},</if>
|
<if test="email != null">email = #{email},</if>
|
||||||
<if test="byteApiKey != null">byte_api_key = #{byteApiKey},</if>
|
<if test="byteApiKey != null">byte_api_key = #{byteApiKey},</if>
|
||||||
|
<if test="project != null">project = #{project},</if>
|
||||||
<if test="status != null and status != ''">status = #{status},</if>
|
<if test="status != null and status != ''">status = #{status},</if>
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
update_time = sysdate()
|
update_time = sysdate()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue