Browse Source

Merge branch 'dev' into dev_temp

master
wxz 5 years ago
parent
commit
9ee9fa04b9
  1. 18
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/GovStaffRoleFormDTO.java
  2. 34
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GovStaffRoleController.java
  3. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java
  4. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java
  5. 14
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java
  6. 15
      epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml

18
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/GovStaffRoleFormDTO.java

@ -1,12 +1,30 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class GovStaffRoleFormDTO {
public interface SaveRoleOrderGroup extends CustomerClientShowGroup {}
public interface UpdateRoleGroup extends CustomerClientShowGroup {}
/**
* 角色id列表
*/
@NotEmpty(message = "角色ID列表为空", groups = { SaveRoleOrderGroup.class })
private List<String> roleIdList;
/**
* 角色id
*/
@NotNull(message = "缺少角色ID", groups = { UpdateRoleGroup.class })
private String roleId;
@NotNull(message = "缺少角色名称", groups = { UpdateRoleGroup.class })
private String roleName;
}

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

@ -1,17 +1,14 @@
package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.RoleDTO;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.GovStaffRoleFormDTO;
import com.epmet.dto.form.IssueInitiatorFormDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.dto.result.GovStaffRoleTemplateDTO;
import com.epmet.dto.result.IssueInitiatorResultDTO;
import com.epmet.dto.result.ResiGovRoleListResultDTO;
import com.epmet.entity.GovStaffRoleEntity;
import com.epmet.service.GovStaffRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
@ -76,4 +73,31 @@ public class GovStaffRoleController {
return new Result<ResiGovRoleListResultDTO>().ok(govStaffRoleService.resiGovRoleList());
}
/**
* 更新客户的指定角色
* @param form
* @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("修改角色信息失败");
}
return new Result();
}
/**
* 更新排序序号
* @param form
* @return
*/
@PostMapping("save-sortorder")
public Result saveSortOrder(@RequestBody GovStaffRoleFormDTO form) {
ValidatorUtils.validateEntity(form, GovStaffRoleFormDTO.SaveRoleOrderGroup.class);
List<String> roleIdList = form.getRoleIdList();
govStaffRoleService.saveSortOrder(roleIdList);
return new Result();
}
}

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

@ -71,4 +71,8 @@ public interface GovStaffRoleDao extends BaseDao<GovStaffRoleEntity> {
* @date 2020/8/13 2:14 下午
*/
List<RoleResultDTO> getRoleInfoList(@Param("userIds")List<String> userIds);
int updateColumnsById(@Param("roleId") String roleId, @Param("roleName") String roleName);
int updateSortById(@Param("roleId") String roleId, @Param("sort") int sort);
}

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

@ -134,4 +134,8 @@ public interface GovStaffRoleService extends BaseService<GovStaffRoleEntity> {
* @Description 获取居民端工作端人员角色列表
*/
ResiGovRoleListResultDTO resiGovRoleList();
int updateRole(String roleId, String roleName);
void saveSortOrder(List<String> roleIdList);
}

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

@ -208,4 +208,18 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl<GovStaffRoleDao, Go
resultDTO.setGovRoleList(govRoleList);
return resultDTO;
}
@Override
public int updateRole(String roleId, String roleName) {
return govStaffRoleDao.updateColumnsById(roleId, roleName);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void saveSortOrder(List<String> roleIdList) {
for (int i = 0 ; i < roleIdList.size() ; i++) {
int r = govStaffRoleDao.updateSortById(roleIdList.get(i), i);
System.out.println(r);
}
}
}

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

@ -17,6 +17,19 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<update id="updateColumnsById">
update gov_staff_role
set ROLE_NAME = #{roleName}
where ID = #{roleId}
</update>
<!--更新排序序号-->
<update id="updateSortById">
update gov_staff_role
set SORT = #{sort}
where ID = #{roleId}
</update>
<!--根据staffId查询具有的角色列表-->
<select id="listRolesByStaffId" resultType="com.epmet.entity.GovStaffRoleEntity">
SELECT
@ -29,6 +42,7 @@
AND sr.ORG_ID = #{orgId}
AND sr.DEL_FLAG = '0'
AND r.DEL_FLAG = '0'
ORDER BY r.SORT asc
</select>
<select id="selectGovStaffRoleList" resultType="com.epmet.dto.GovStaffRoleDTO" parameterType="com.epmet.dto.GovStaffRoleDTO">
select
@ -58,6 +72,7 @@
r.ORG_TYPE AS orgType
FROM gov_staff_role r
WHERE r.CUSTOMER_ID = #{customerId}
ORDER BY r.SORT asc
</select>
<select id="getDTOById" resultType="com.epmet.dto.result.GovStaffRoleResultDTO">

Loading…
Cancel
Save