Browse Source

Merge branch 'dev_oper_role' into develop

dev_shibei_match
sunyuchao 4 years ago
parent
commit
c4362e7375
  1. 5
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/GovStaffRoleDTO.java
  2. 10
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/GovStaffRoleTemplateDTO.java
  3. 5
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/GovStaffRoleEntity.java
  4. 10
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/GovStaffRoleTemplateEntity.java
  5. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/GovStaffRoleDTO.java
  6. 30
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UpGovRoleFormDTO.java
  7. 17
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleResultDTO.java
  8. 10
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleTemplateDTO.java
  9. 42
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GovStaffRoleController.java
  10. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java
  11. 22
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleTemplateDao.java
  12. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/GovStaffRoleEntity.java
  13. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/GovStaffRoleTemplateEntity.java
  14. 23
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java
  15. 65
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java
  16. 9
      epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.13__alter_gov_staff_role.sql
  17. 29
      epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml
  18. 48
      epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleTemplateDao.xml

5
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/GovStaffRoleDTO.java

@ -93,6 +93,11 @@ public class GovStaffRoleDTO implements Serializable {
*/
private Integer fullTimeOnly;
/**
* 角色对应的职责说明
*/
private String description;
/**
* 排序
*/

10
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/GovStaffRoleTemplateDTO.java

@ -58,6 +58,16 @@ public class GovStaffRoleTemplateDTO implements Serializable {
*/
private Integer fullTimeOnly;
/**
* 角色对应的职责说明
*/
private String description;
/**
* 排序
*/
private String sort;
/**
*
*/

5
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/GovStaffRoleEntity.java

@ -63,6 +63,11 @@ public class GovStaffRoleEntity extends BaseEpmetEntity {
*/
private Integer fullTimeOnly;
/**
* 角色对应的职责说明
*/
private String description;
/**
* 排序
*/

10
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/GovStaffRoleTemplateEntity.java

@ -58,4 +58,14 @@ public class GovStaffRoleTemplateEntity extends BaseEpmetEntity {
*/
private Integer fullTimeOnly;
/**
* 角色对应的职责说明
*/
private String description;
/**
* 排序
*/
private String sort;
}

5
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/GovStaffRoleDTO.java

@ -63,6 +63,11 @@ public class GovStaffRoleDTO implements Serializable {
* */
private Boolean fullTimeOnly;
/**
* 角色对应的职责说明
*/
private String description;
/**
* 排序
* */

30
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UpGovRoleFormDTO.java

@ -0,0 +1,30 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@Data
public class UpGovRoleFormDTO {
/**
* 角色表id
*/
@NotEmpty(message = "角色Id不能为空", groups = {Update.class})
private String roleId;
/**
* 角色名称
*/
private String roleName;
/**
* 职责描述
*/
private String description;
/**
* token中userId
*/
private String userId;
public interface Update extends CustomerClientShowGroup {}
}

17
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleResultDTO.java

@ -64,4 +64,21 @@ public class GovStaffRoleResultDTO implements Serializable {
private String mobile;
private String gender;
/**
* 职责描述
*/
private String description;
/**
* 角色key[默认值]
*/
private String defRoleKey;
/**
* 角色名称[默认值]
*/
private String defRoleName;
/**
* 职责描述[默认值]
*/
private String defDescription;
}

10
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleTemplateDTO.java

@ -58,6 +58,16 @@ public class GovStaffRoleTemplateDTO implements Serializable {
* */
private Boolean fullTimeOnly;
/**
* 角色对应的职责说明
*/
private String description;
/**
* 排序
*/
private String sort;
/**
*
*/

42
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GovStaffRoleController.java

@ -6,6 +6,7 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.GovStaffRoleFormDTO;
import com.epmet.dto.form.UpGovRoleFormDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.dto.result.GovStaffRoleTemplateDTO;
import com.epmet.dto.result.ResiGovRoleListResultDTO;
@ -76,15 +77,14 @@ public class GovStaffRoleController {
/**
* 更新客户的指定角色
* @param form
* @param formDTO
* @return
*/
@PostMapping("update-role")
public Result updateRole(@RequestBody GovStaffRoleFormDTO form) {
ValidatorUtils.validateEntity(form, GovStaffRoleFormDTO.UpdateRoleGroup.class);
if (govStaffRoleService.updateRole(form.getRoleId(), form.getRoleName()) == 0) {
throw new RenException("修改角色信息失败");
}
public Result updateRole(@LoginUser TokenDto tokenDTO, @RequestBody UpGovRoleFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, UpGovRoleFormDTO.Update.class);
formDTO.setUserId(tokenDTO.getUserId());
govStaffRoleService.updateCustomerRole(formDTO);
return new Result();
}
@ -94,10 +94,9 @@ public class GovStaffRoleController {
* @return
*/
@PostMapping("save-sortorder")
public Result saveSortOrder(@RequestBody GovStaffRoleFormDTO form) {
public Result saveSortOrder(@LoginUser TokenDto tokenDTO, @RequestBody GovStaffRoleFormDTO form) {
ValidatorUtils.validateEntity(form, GovStaffRoleFormDTO.SaveRoleOrderGroup.class);
List<String> roleIdList = form.getRoleIdList();
govStaffRoleService.saveSortOrder(roleIdList);
govStaffRoleService.saveSortOrder(tokenDTO.getUserId(), form.getRoleIdList());
return new Result();
}
@ -124,4 +123,29 @@ public class GovStaffRoleController {
Result<List<RoleInfoResultDTO>> queryCustomerGovRoleList(@PathVariable("customerId") String customerId){
return new Result<List<RoleInfoResultDTO>>().ok(govStaffRoleService.queryCustomerGovRoleList(customerId));
}
/**
* @param formDTO
* @Description 默认权限保存排序
* @Author sun
**/
@PostMapping("savedefaultsort")
public Result saveDefaultSort(@LoginUser TokenDto tokenDTO, @RequestBody GovStaffRoleFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, GovStaffRoleFormDTO.SaveRoleOrderGroup.class);
govStaffRoleService.saveDefaultSort(tokenDTO.getUserId(), formDTO.getRoleIdList());
return new Result();
}
/**
* @param formDTO
* @Description 修改角色名称或职责描述
* @Author sun
**/
@PostMapping("updatedefaultrole")
public Result updateDefaultRole(@LoginUser TokenDto tokenDTO, @RequestBody UpGovRoleFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, UpGovRoleFormDTO.Update.class);
formDTO.setUserId(tokenDTO.getUserId());
govStaffRoleService.updateDefaultRole(formDTO);
return new Result();
}
}

10
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java

@ -19,6 +19,7 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.form.UpGovRoleFormDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.dto.result.RoleInfoResultDTO;
import com.epmet.dto.result.RoleKeyValueResultDTO;
@ -75,7 +76,7 @@ public interface GovStaffRoleDao extends BaseDao<GovStaffRoleEntity> {
int updateColumnsById(@Param("roleId") String roleId, @Param("roleName") String roleName);
int updateSortById(@Param("roleId") String roleId, @Param("sort") int sort);
int updateSortById(@Param("roleId") String roleId, @Param("sort") int sort, @Param("userId") String userId);
List<GovStaffRoleResultDTO> listRolesByRoleKey(@Param("roleKey") String roleKey);
@ -88,4 +89,11 @@ public interface GovStaffRoleDao extends BaseDao<GovStaffRoleEntity> {
* @date 2021/6/15 2:35 下午
*/
List<RoleKeyValueResultDTO> selectRoleKeyName(@Param("roleIds")List<String> roleIds);
/**
* @param formDTO
* @Description 修改客户角色名称或职责描述
* @Author sun
**/
int upNameOrDescription(UpGovRoleFormDTO formDTO);
}

22
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleTemplateDao.java

@ -18,10 +18,13 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.UpGovRoleFormDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.dto.result.GovStaffRoleTemplateDTO;
import com.epmet.dto.result.ResiGovRoleResultDTO;
import com.epmet.entity.GovStaffRoleTemplateEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -45,4 +48,23 @@ public interface GovStaffRoleTemplateDao extends BaseDao<GovStaffRoleTemplateEnt
* @Description 获取工作端角色列表
*/
List<ResiGovRoleResultDTO> selectGovRoleList();
/**
* @author sun
* @Description 获取工作端默认角色列表
*/
List<GovStaffRoleResultDTO> defaultRoleList();
/**
* @author sun
* @Description 修改默认权限排序
*/
int updateSortById(@Param("roleId") String roleId, @Param("sort") int sort, @Param("userId") String userId);
/**
* @param formDTO
* @Description 修改角色名称或职责描述
* @Author sun
**/
int upNameOrDescription(UpGovRoleFormDTO formDTO);
}

5
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/GovStaffRoleEntity.java

@ -63,6 +63,11 @@ public class GovStaffRoleEntity extends BaseEpmetEntity {
* */
private Boolean fullTimeOnly;
/**
* 角色对应的职责说明
*/
private String description;
/**
* 排序
* */

10
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/GovStaffRoleTemplateEntity.java

@ -58,4 +58,14 @@ public class GovStaffRoleTemplateEntity extends BaseEpmetEntity {
* */
private Boolean fullTimeOnly;
/**
* 角色对应的职责说明
*/
private String description;
/**
* 排序
*/
private String sort;
}

23
epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java

@ -20,6 +20,7 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.form.UpGovRoleFormDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.dto.result.GovStaffRoleTemplateDTO;
import com.epmet.dto.result.ResiGovRoleListResultDTO;
@ -138,7 +139,7 @@ public interface GovStaffRoleService extends BaseService<GovStaffRoleEntity> {
int updateRole(String roleId, String roleName);
void saveSortOrder(List<String> roleIdList);
void saveSortOrder(String userId, List<String> roleIdList);
List<GovStaffRoleResultDTO> listRolesByRoleKey(String roleKey);
@ -150,4 +151,24 @@ public interface GovStaffRoleService extends BaseService<GovStaffRoleEntity> {
* @Date 2021/3/29 15:37
**/
List<RoleInfoResultDTO> queryCustomerGovRoleList(String customerId);
/**
* @Description 默认权限保存排序
* @Author sun
**/
void saveDefaultSort(String userId, List<String> roleIdList);
/**
* @param formDTO
* @Description 修改角色名称或职责描述
* @Author sun
**/
void updateDefaultRole(UpGovRoleFormDTO formDTO);
/**
* @param formDTO
* @Description 修改客户角色名称或职责描述
* @Author sun
**/
void updateCustomerRole(UpGovRoleFormDTO formDTO);
}

65
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java

@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
@ -30,6 +31,7 @@ import com.epmet.dao.GovStaffRoleTemplateDao;
import com.epmet.dao.RoleDao;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.form.InitDefaultOperationsFormDTO;
import com.epmet.dto.form.UpGovRoleFormDTO;
import com.epmet.dto.result.*;
import com.epmet.entity.GovStaffRoleEntity;
import com.epmet.feign.GovAccessFeignClient;
@ -182,7 +184,24 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl<GovStaffRoleDao, Go
@Override
public List<GovStaffRoleResultDTO> listRolesByCustomer(String customerId) {
return govStaffRoleDao.listRolesByCustomer(customerId);
List<GovStaffRoleResultDTO> resultList = new ArrayList<>();
//1.查询系统默认角色列表数据
resultList = govStaffRoleTemplateDao.defaultRoleList();
//2.查询客户角色权限列表数据
List<GovStaffRoleResultDTO> cuList = govStaffRoleDao.listRolesByCustomer(customerId);
//3.封装数据并返回
resultList.forEach(re -> {
cuList.forEach(cu -> {
if (re.getDefRoleKey().equals(cu.getRoleKey())) {
re.setCustomerId(cu.getCustomerId());
re.setRoleId(cu.getRoleId());
re.setRoleKey(cu.getRoleKey());
re.setRoleName(cu.getRoleName());
re.setDescription(cu.getDescription());
}
});
});
return resultList;
}
@Override
@ -221,12 +240,11 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl<GovStaffRoleDao, Go
return govStaffRoleDao.updateColumnsById(roleId, roleName);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void saveSortOrder(List<String> roleIdList) {
@Transactional(rollbackFor = Exception.class)
public void saveSortOrder(String userId, List<String> roleIdList) {
for (int i = 0 ; i < roleIdList.size() ; i++) {
int r = govStaffRoleDao.updateSortById(roleIdList.get(i), i);
System.out.println(r);
int r = govStaffRoleDao.updateSortById(roleIdList.get(i), i, userId);
}
}
@ -264,4 +282,41 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl<GovStaffRoleDao, Go
});
return resultList;
}
/**
* @Description 默认权限保存排序
* @Author sun
**/
@Override
@Transactional(rollbackFor = Exception.class)
public void saveDefaultSort(String userId, List<String> roleIdList) {
for (int i = 0; i < roleIdList.size(); i++) {
govStaffRoleTemplateDao.updateSortById(roleIdList.get(i), i, userId);
}
}
/**
* @param formDTO
* @Description 修改角色名称或职责描述
* @Author sun
**/
@Override
public void updateDefaultRole(UpGovRoleFormDTO formDTO) {
if (govStaffRoleTemplateDao.upNameOrDescription(formDTO) < NumConstant.ONE) {
throw new RenException("修改角色信息失败");
}
}
/**
* @param formDTO
* @Description 修改客户角色名称或职责描述
* @Author sun
**/
@Override
public void updateCustomerRole(UpGovRoleFormDTO formDTO) {
if (govStaffRoleDao.upNameOrDescription(formDTO) < NumConstant.ONE) {
throw new RenException("修改角色信息失败");
}
}
}

9
epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.13__alter_gov_staff_role.sql

@ -0,0 +1,9 @@
ALTER TABLE `gov_staff_role_template`
ADD COLUMN `DESCRIPTION` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色对应的职责说明' AFTER `FULL_TIME_ONLY`,
ADD COLUMN `SORT` int(11) NULL DEFAULT NULL COMMENT '排序' AFTER `DESCRIPTION`;
ALTER TABLE `gov_staff_role`
MODIFY COLUMN `FULL_TIME_ONLY` tinyint(1) NULL DEFAULT 1 COMMENT '是否只有全职 1对应true 0对应false' AFTER `ORG_TYPE`,
MODIFY COLUMN `SORT` int(11) NULL DEFAULT NULL COMMENT '排序' AFTER `FULL_TIME_ONLY`,
ADD COLUMN `DESCRIPTION` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色对应的职责说明' AFTER `FULL_TIME_ONLY`;

29
epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml

@ -25,9 +25,12 @@
<!--更新排序序号-->
<update id="updateSortById">
update gov_staff_role
set SORT = #{sort}
where ID = #{roleId}
UPDATE gov_staff_role
SET sort = #{sort},
updated_by = #{userId},
updated_time = NOW()
WHERE
id = #{roleId}
</update>
<!--根据staffId查询具有的角色列表-->
@ -69,7 +72,8 @@
r.CUSTOMER_ID AS customerId,
r.ROLE_KEY AS roleKey,
r.ROLE_NAME AS roleName,
r.ORG_TYPE AS orgType
r.ORG_TYPE AS orgType,
r.DESCRIPTION AS description
FROM gov_staff_role r
WHERE r.CUSTOMER_ID = #{customerId}
ORDER BY r.SORT asc
@ -133,4 +137,21 @@
</foreach>
)
</select>
<update id="upNameOrDescription">
UPDATE gov_staff_role
<set>
<if test='null != roleName'>
role_name = #{roleName},
</if>
<if test='null != description'>
description = #{description},
</if>
updated_by = #{userId},
updated_time = NOW()
</set>
WHERE
id = #{roleId}
</update>
</mapper>

48
epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleTemplateDao.xml

@ -18,9 +18,14 @@
<!--列出有效的角色字典-->
<select id="listValidateRoles" resultType="com.epmet.dto.result.GovStaffRoleTemplateDTO">
SELECT *
FROM gov_staff_role_template
WHERE DEL_FLAG = 0
SELECT
*
FROM
gov_staff_role_template
WHERE
del_flag = '0'
ORDER BY
sort ASC
</select>
<select id="selectGovRoleList" resultType="com.epmet.dto.result.ResiGovRoleResultDTO">
@ -32,5 +37,42 @@
ORDER BY full_time_only DESC
</select>
<select id="defaultRoleList" resultType="com.epmet.dto.result.GovStaffRoleResultDTO">
SELECT
role_key AS "defRoleKey",
role_name AS "defRoleName",
description AS "defDescription"
FROM
gov_staff_role_template
WHERE
del_flag = '0'
ORDER BY
sort ASC
</select>
<update id="updateSortById">
UPDATE gov_staff_role_template
SET sort = #{sort},
updated_by = #{userId},
updated_time = NOW()
WHERE
id = #{roleId}
</update>
<update id="upNameOrDescription">
UPDATE gov_staff_role_template
<set>
<if test='null != roleName'>
role_name = #{roleName},
</if>
<if test='null != description'>
description = #{description},
</if>
updated_by = #{userId},
updated_time = NOW()
</set>
WHERE
id = #{roleId}
</update>
</mapper>
Loading…
Cancel
Save