Commit f72fcce9 authored by frank.xa.zhang's avatar frank.xa.zhang

fixed role module -- frank

parent a5aa64e4
...@@ -19,10 +19,12 @@ import pwc.taxtech.atms.dto.role.*; ...@@ -19,10 +19,12 @@ import pwc.taxtech.atms.dto.role.*;
import pwc.taxtech.atms.dto.user.*; import pwc.taxtech.atms.dto.user.*;
import pwc.taxtech.atms.entity.*; import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.entity.UserRoleExample.Criteria; import pwc.taxtech.atms.entity.UserRoleExample.Criteria;
import pwc.taxtech.atms.organization.dao.OrganizationHKMapper;
import pwc.taxtech.atms.organization.dpo.UserRoleHKInfo; import pwc.taxtech.atms.organization.dpo.UserRoleHKInfo;
import pwc.taxtech.atms.organization.entity.OrganizationHK; import pwc.taxtech.atms.organization.entity.OrganizationHK;
import pwc.taxtech.atms.security.JwtAuthenticationService; import pwc.taxtech.atms.security.JwtAuthenticationService;
import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -806,6 +808,9 @@ public class RoleServiceImpl extends AbstractService { ...@@ -806,6 +808,9 @@ public class RoleServiceImpl extends AbstractService {
return one; return one;
} }
@Resource
private OrganizationHKMapper organizationHKMapper;
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
...@@ -835,7 +840,7 @@ public class RoleServiceImpl extends AbstractService { ...@@ -835,7 +840,7 @@ public class RoleServiceImpl extends AbstractService {
if (user != null) { if (user != null) {
userRole.setUserName(user.getUserName()); userRole.setUserName(user.getUserName());
if (user.getOrganizationId() != null && !user.getOrganizationId().isEmpty()) { if (user.getOrganizationId() != null && !user.getOrganizationId().isEmpty()) {
Organization organization = organizationMapper.selectByPrimaryKey(user.getOrganizationId()); OrganizationHK organization = organizationHKMapper.selectByPrimaryKey(Long.valueOf(user.getOrganizationId()));
userRole.setOrgId(user.getOrganizationId()); userRole.setOrgId(user.getOrganizationId());
userRole.setOrgName(organization == null ? "" : organization.getName()); userRole.setOrgName(organization == null ? "" : organization.getName());
} }
......
<?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="pwc.taxtech.atms.dao.RolePermissionMapper">
<select id="selectByRoleId" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
role_permission
WHERE
role_id = #{roleId,jdbcType=VARCHAR}
</select>
<resultMap extends="BaseResultMap" id="ResultMapWithAssociation" type="pwc.taxtech.atms.entity.RolePermission">
<association column="ROLE_ID" javaType="pwc.taxtech.atms.entity.Role" property="role">
<id column="ROLE_ID" property="id"/>
<result column="ROLE_NAME" property="name"/>
<result column="ROLE_DESCRIPTION" property="description"/>
<result column="ROLE_CATEGORY_ID" property="roleCategoryId"/>
<result column="ROLE_SERVICE_TYPE" property="serviceTypeId"/>
<result column="ROLE_CREATE_TIME" property="createTime"/>
<result column="ROLE_UPDATE_TIME" property="updateTime"/>
</association>
<association column="PERMISSION_ID" javaType="pwc.taxtech.atms.entity.Permission" property="permission">
<id column="PERMISSION_ID" property="id"/>
<result column="PERMISSION_NAME" property="name"/>
<result column="PERMISSION_CODE" property="code"/>
<result column="PERMISSION_PARENT_ID" property="parentId"/>
<result column="PERMISSION_IS_ACTIVE" property="isActive"/>
<result column="PERMISSION_P_LEVEL" property="pLevel"/>
<result column="PERMISSION_RELY_ON_CODES" property="relyOnCodes"/>
<result column="PERMISSION_MENU_ID" property="menuId"/>
<result column="PERMISSION_SERVICE_TYPE_ID" property="serviceTypeId"/>
<result column="PERMISSION_CREATE_TIME" property="createTime"/>
<result column="PERMISSION_UPDATE_TIME" property="updateTime"/>
</association>
</resultMap>
<select id="selectByRoleAndServiceTypeWithAssociation" resultMap="ResultMapWithAssociation">
SELECT
rp.id AS ID,
rp.role_id AS ROLE_ID,
rp.permission_id AS PERMISSION_ID,
r.id AS ROLE_ID,
r.name AS ROLE_NAME,
r.description AS ROLE_DESCRIPTION,
r.role_category_id AS ROLE_CATEGORY_ID,
r.service_type_id AS ROLE_SERVICE_TYPE,
r.create_time AS ROLE_CREATE_TIME,
r.update_time AS ROLE_UPDATE_TIME,
p.id AS PERMISSION_ID,
p.name AS PERMISSION_NAME,
p.code AS PERMISSION_CODE,
p.parent_id AS PERMISSION_PARENT_ID,
p.is_active AS PERMISSION_IS_ACTIVE,
p.p_level AS PERMISSION_P_LEVEL,
p.rely_on_codes AS PERMISSION_RELY_ON_CODES,
p.menu_id AS PERMISSION_MENU_ID,
p.service_type_id AS PERMISSION_SERVICE_TYPE_ID,
p.create_time AS PERMISSION_CREATE_TIME,
p.update_time AS PERMISSION_UPDATE_TIME
FROM
role_permission rp
JOIN
role r
on
r.id = rp.role_id
JOIN
permission p
on
p.id = rp.permission_id
where
rp.role_id= #{roleId,jdbcType=VARCHAR}
AND r.service_type_id= #{serviceTypeId,jdbcType=VARCHAR}
</select>
<select id="selectByRoleListAndServiceTypeWithAssociation" resultMap="ResultMapWithAssociation">
SELECT
rp.id AS ID,
rp.role_id as ROLE_ID,
rp.permission_id as PERMISSION_ID,
r.id AS ROLE_ID,
r.name AS ROLE_NAME,
r.description AS ROLE_DESCRIPTION,
r.role_category_id AS ROLE_CATEGORY_ID,
r.service_type_id AS ROLE_SERVICE_TYPE,
r.create_time AS ROLE_CREATE_TIME,
r.update_time AS ROLE_UPDATE_TIME,
p.id AS PERMISSION_ID,
p.name AS PERMISSION_NAME,
p.code AS PERMISSION_CODE,
p.parent_id AS PERMISSION_PARENT_ID,
p.is_active AS PERMISSION_IS_ACTIVE,
p.p_level AS PERMISSION_P_LEVEL,
p.rely_on_codes AS PERMISSION_RELY_ON_CODES,
p.menu_id AS PERMISSION_MENU_ID,
p.service_type_id AS PERMISSION_SERVICE_TYPE_ID,
p.create_time AS PERMISSION_CREATE_TIME,
p.update_time AS PERMISSION_UPDATE_TIME
FROM
role_permission rp
JOIN
role r
on
r.id = rp.role_id
JOIN
permission p
on
p.id = rp.permission_id
where
r.service_type_id= #{serviceTypeId,jdbcType=VARCHAR}
AND rp.role_id in
<foreach close=")" collection="roleList" index="index" item="roleID" open="(" separator=",">
#{roleID}
</foreach>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment