Bläddra i källkod

培训登机主持人默认值处理

jingyuanchao 2 år sedan
förälder
incheckning
cc471f0cb2

+ 3 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteRoleService.java

@@ -6,6 +6,7 @@ import com.xunmei.common.core.domain.IdName;
 import com.xunmei.common.core.vo.IdNameVo;
 import com.xunmei.system.api.Eto.RoleConditionEto;
 import com.xunmei.system.api.domain.SysRole;
+import com.xunmei.system.api.domain.SysUser;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -28,4 +29,6 @@ public interface RemoteRoleService {
     @GetMapping("/role/getNames")
     List<IdNameVo> getNames(RoleConditionEto condition);
 
+    @GetMapping("/role/selectUserByRoleNameAndOrgId")
+    List<SysUser> selectUserByRoleNameAndOrgId(@RequestParam(value = "roleName") String roleName,@RequestParam(value = "orgId")  Long orgId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
 }

+ 1 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/domain/SysUser.java

@@ -75,6 +75,7 @@ public class SysUser extends BaseEntity {
     /**
      * 机构
      */
+    @JsonSerialize(using = ToStringSerializer.class)
     @ApiModelProperty(value = "机构")
     private Long orgId;
 

+ 6 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteRoleFallbackFactory.java

@@ -6,6 +6,7 @@ import com.xunmei.common.core.vo.IdNameVo;
 import com.xunmei.system.api.Eto.RoleConditionEto;
 import com.xunmei.system.api.RemoteRoleService;
 import com.xunmei.system.api.domain.SysRole;
+import com.xunmei.system.api.domain.SysUser;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.cloud.openfeign.FallbackFactory;
@@ -37,6 +38,11 @@ public class RemoteRoleFallbackFactory implements FallbackFactory<RemoteRoleServ
                 return null;
             }
 
+            @Override
+            public List<SysUser> selectUserByRoleNameAndOrgId(String roleName, Long orgId, String inner) {
+                return null;
+            }
         };
+
     }
 }

+ 2 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/vo/SysOrgVO.java

@@ -22,10 +22,12 @@ public class SysOrgVO {
     private Long id;
     private String name;
     private String path;
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long parentId;
     private Integer type;
     private String shortName;
     private String treeShowPath;
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long treeShowParentId;
     private List<SysOrgVO> children = new ArrayList<SysOrgVO>();
 

+ 1 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/constant/ErrorMsgConstants.java

@@ -14,4 +14,5 @@ public class ErrorMsgConstants {
     public static final String QUERY_STATICS_SAVE_PATH_ERROR = "获取静态存储路径失败!";
 
     public static final String CUR_USER_ORT_TYPE_ERROR = "当前用户所在机构类型无法确认!";
+    public static final String QUERY_USER_DATA_ERROR = "获取用户信息失败!";
 }

+ 1 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/drill/service/impl/CoreDrillDictionaryServiceImpl.java

@@ -86,7 +86,7 @@ public class CoreDrillDictionaryServiceImpl extends ServiceImpl<CoreDrillDiction
         BeanUtils.copyProperties(request, dictionary);
         final List<SysDictData> drillTypeDictList = DictUtils.getDictCache(DictConstants.CORE_DRILL_TYPE);
         if (null != drillTypeDictList && ObjectUtil.isNotEmpty(drillTypeDictList)) {
-            drillTypeDictList.stream().filter(dict -> ObjectUtil.equal(dict.getDictValue(), request.getDrillType())).findFirst().ifPresent(dict -> dictionary.setDrillTypeName(dict.getDictValue()));
+            drillTypeDictList.stream().filter(dict -> ObjectUtil.equal(dict.getDictValue(), request.getDrillType())).findFirst().ifPresent(dict -> dictionary.setDrillTypeName(dict.getDictLabel()));
         }
         dictionary.setCreateBy(SecurityUtils.getUserId().toString());
         dictionary.setUpdateBy(SecurityUtils.getUserId().toString());

+ 17 - 2
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/impl/CoreEduTrainingTaskServiceImpl.java

@@ -40,6 +40,7 @@ import com.xunmei.core.edu.service.ICoreEduTrainingTaskToRoleService;
 import com.xunmei.core.edu.service.ICoreEduTrainingTaskToUserService;
 import com.xunmei.system.api.RemoteFileService;
 import com.xunmei.system.api.RemoteOrgService;
+import com.xunmei.system.api.RemoteRoleService;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.domain.SysUser;
 import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
@@ -74,6 +75,8 @@ public class CoreEduTrainingTaskServiceImpl extends ServiceImpl<CoreEduTrainingT
     @Autowired
     private RemoteFileService fileService;
     @Autowired
+    private RemoteRoleService roleService;
+    @Autowired
     private ICoreEduTrainingTaskToRoleService coreEduTrainingTaskToRoleService;
     @Autowired
     private CoreEduTrainingTaskToRoleMapper taskToRoleMapper;
@@ -191,6 +194,7 @@ public class CoreEduTrainingTaskServiceImpl extends ServiceImpl<CoreEduTrainingT
      * @return 结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int insertCoreEduTrainingTask(CoreEduTrainingTask coreEduTrainingTask) {
         coreEduTrainingTask.setCreateTime(DateUtils.getNowDate());
         return coreEduTrainingTaskMapper.insert(coreEduTrainingTask);
@@ -203,6 +207,7 @@ public class CoreEduTrainingTaskServiceImpl extends ServiceImpl<CoreEduTrainingT
      * @return 结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int updateCoreEduTrainingTask(CoreEduTrainingTaskEditDto request) {
         CoreEduTrainingTask coreEduTrainingTask = coreEduTrainingTaskMapper.selectById(request.getId());
         taskToUserMapper.deleteByMap(MapUtil.of("edu_training_task_id", request.getId()));
@@ -213,8 +218,13 @@ public class CoreEduTrainingTaskServiceImpl extends ServiceImpl<CoreEduTrainingT
         coreEduTrainingTask.setNote(request.getNote());
         coreEduTrainingTask.setRecorderId(SecurityUtils.getUserId());
         coreEduTrainingTask.setImageList(request.getImageList());
-        //主持人默认取网点负责人,具体还没落实,暂时处理成这样   TODO
-        coreEduTrainingTask.setHostId(SecurityUtils.getUserId());
+        List<SysUser> userList = RemoteCallHandlerExecutor.executeRemoteCall(() ->
+                roleService.selectUserByRoleNameAndOrgId("网点负责人", coreEduTrainingTask.getOrgId(), SecurityConstants.INNER), ErrorMsgConstants.QUERY_USER_DATA_ERROR);
+        if (ObjectUtil.isNotEmpty(userList)) {
+            coreEduTrainingTask.setHostId(userList.get(0).getId());
+        }else {
+            coreEduTrainingTask.setRecorderId(SecurityUtils.getUserId());
+        }
         List<CoreEduTrainingTaskToUser> taskUserList = request.getTaskUserList();
         if (ObjectUtil.isNotEmpty(taskUserList)) {
             checkTheSameUser(taskUserList);
@@ -254,6 +264,7 @@ public class CoreEduTrainingTaskServiceImpl extends ServiceImpl<CoreEduTrainingT
      * @return 结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int deleteCoreEduTrainingTaskByIds(Long[] ids) {
         return coreEduTrainingTaskMapper.deleteBatchIds(Arrays.asList((ids)));
     }
@@ -265,6 +276,7 @@ public class CoreEduTrainingTaskServiceImpl extends ServiceImpl<CoreEduTrainingT
      * @return 结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int deleteCoreEduTrainingTaskById(Long id) {
         return coreEduTrainingTaskMapper.deleteById(id);
     }
@@ -397,6 +409,7 @@ public class CoreEduTrainingTaskServiceImpl extends ServiceImpl<CoreEduTrainingT
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Integer sign(CoreEduTrainingTaskSignDto request) {
         CoreEduTrainingTask eduTrainingTask = getById(request.getId());
         SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
@@ -436,6 +449,7 @@ public class CoreEduTrainingTaskServiceImpl extends ServiceImpl<CoreEduTrainingT
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public AjaxResult buildEduPdf(Long id) {
         CoreEduTrainingTaskDetailVo task = this.selectCoreEduTrainingTaskById(id);
         if (ObjectUtil.isNotEmpty(task.getPdfUrl())) {
@@ -528,6 +542,7 @@ public class CoreEduTrainingTaskServiceImpl extends ServiceImpl<CoreEduTrainingT
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public String buildEduTask(Integer cycle, Date date) {
         if (ObjectUtil.isNull(date)) {
             date = new Date();

+ 5 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysRoleController.java

@@ -13,6 +13,7 @@ import com.xunmei.common.security.utils.SecurityUtils;
 import com.xunmei.system.api.Eto.RoleConditionEto;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.domain.SysRole;
+import com.xunmei.system.api.domain.SysUser;
 import com.xunmei.system.domain.SysUserRole;
 import com.xunmei.system.domain.vo.SysUserVO;
 import com.xunmei.system.service.ISysDeptService;
@@ -230,4 +231,8 @@ public class SysRoleController extends BaseController {
         List<IdName<Long, String>> r = roleService.selectSimpleRoleAll(condition, null);
         return r.stream().map(i -> new IdNameVo(i.getId(), i.getName(), null)).collect(Collectors.toList());
     }
+    @GetMapping("/selectUserByRoleNameAndOrgId")
+    public List<SysUser> selectUserByRoleNameAndOrgId(@RequestParam(value = "roleName") String roleName,@RequestParam(value = "orgId")  Long orgId) {
+        return roleService.selectUserByRoleNameAndOrgId(roleName,orgId);
+    }
 }

+ 4 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/mapper/SysRoleMapper.java

@@ -2,7 +2,9 @@ package com.xunmei.system.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.xunmei.system.api.domain.SysRole;
+import com.xunmei.system.api.domain.SysUser;
 import com.xunmei.system.domain.SysRoleDept;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -108,4 +110,6 @@ String selectRoleNameByUserId(Long userId);
      * @return 结果
      */
      int deleteRoleByIds(Long[] roleIds);
+
+    List<SysUser> selectUserByRoleNameAndOrgId(@Param("roleName") String roleName, @Param("orgId") Long orgId);
 }

+ 3 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysRoleService.java

@@ -5,6 +5,7 @@ import com.xunmei.common.core.domain.IdName;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.system.api.Eto.RoleConditionEto;
 import com.xunmei.system.api.domain.SysRole;
+import com.xunmei.system.api.domain.SysUser;
 import com.xunmei.system.domain.SysUserRole;
 
 import java.util.List;
@@ -186,4 +187,6 @@ String selectRoleNameByUserId(Long userId);
     List<IdName<Long, String>> selectSimpleRoleAll(RoleConditionEto conditionEto, Integer orgType);
 
     List<SysRole> getRoleByType(String type) ;
+
+    List<SysUser> selectUserByRoleNameAndOrgId(String roleName, Long orgId);
 }

+ 5 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysRoleServiceImpl.java

@@ -444,4 +444,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
         queryWrapper.eq("org_type",type);
         return baseMapper.selectList(queryWrapper);
     }
+
+    @Override
+    public List<SysUser> selectUserByRoleNameAndOrgId(String roleName, Long orgId) {
+        return roleMapper.selectUserByRoleNameAndOrgId(roleName,orgId);
+    }
 }

+ 244 - 164
soc-modules/soc-modules-system/src/main/resources/mapper/system/SysRoleMapper.xml

@@ -1,174 +1,254 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.xunmei.system.mapper.SysRoleMapper">
+    <resultMap type="com.xunmei.system.api.domain.SysRole" id="SysRoleResult">
+        <id property="id" column="id"/>
+        <result property="roleName" column="role_name"/>
+        <result property="roleKey" column="role_key"/>
+        <result property="roleSort" column="role_sort"/>
+        <result property="dataScope" column="data_scope"/>
+        <result property="menuCheckStrictly" column="menu_check_strictly"/>
+        <result property="deptCheckStrictly" column="dept_check_strictly"/>
+        <result property="status" column="status"/>
+        <result property="delFlag" column="del_flag"/>
+        <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>
 
-	<resultMap type="com.xunmei.system.api.domain.SysRole" id="SysRoleResult">
-		<id     property="id"             column="id"               />
-		<result property="roleName"           column="role_name"             />
-		<result property="roleKey"            column="role_key"              />
-		<result property="roleSort"           column="role_sort"             />
-		<result property="dataScope"          column="data_scope"            />
-		<result property="menuCheckStrictly"  column="menu_check_strictly"   />
-		<result property="deptCheckStrictly"  column="dept_check_strictly"   />
-		<result property="status"             column="status"                />
-		<result property="delFlag"            column="del_flag"              />
-		<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="selectRoleVo">
-	    select distinct r.id,r.org_type, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
-            r.status, r.del_flag, r.create_time, r.remark 
+    <sql id="selectRoleVo">
+        select distinct r.id,
+                        r.org_type,
+                        r.role_name,
+                        r.role_key,
+                        r.role_sort,
+                        r.data_scope,
+                        r.menu_check_strictly,
+                        r.dept_check_strictly,
+                        r.status,
+                        r.del_flag,
+                        r.create_time,
+                        r.remark
         from sys_role r
-	        left join sys_user_role ur on ur.role_id = r.id
-	        left join sys_user u on u.id = ur.user_id
-	        left join sys_dept d on u.dept_id = d.dept_id
+                 left join sys_user_role ur on ur.role_id = r.id
+                 left join sys_user u on u.id = ur.user_id
+                 left join sys_dept d on u.dept_id = d.dept_id
     </sql>
-    
+
     <select id="selectRoleList" parameterType="com.xunmei.system.api.domain.SysRole" resultMap="SysRoleResult">
-		<include refid="selectRoleVo"/>
-		where r.del_flag = '0'
-		<if test="roleId != null and roleId != 0">
-			AND r.role_id = #{roleId}
-		</if>
-		<if test="roleName != null and roleName != ''">
-			AND r.role_name like concat('%', #{roleName}, '%')
-		</if>
-		<if test="status != null and status != ''">
-			AND r.status = #{status}
-		</if>
-		<if test="roleKey != null and roleKey != ''">
-			AND r.role_key like concat('%', #{roleKey}, '%')
-		</if>
-		<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
-			and date_format(r.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(r.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
-		</if>
-		<!-- 数据范围过滤 -->
-		${params.dataScope}
-		order by r.role_sort
-	</select>
-    
-	<select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">
-		<include refid="selectRoleVo"/>
-		WHERE r.del_flag = '0' and ur.user_id = #{userId}
-	</select>
-	
-	<select id="selectRoleAll" resultMap="SysRoleResult">
-		<include refid="selectRoleVo"/>
-	</select>
-	
-	<select id="selectRoleListByUserId" parameterType="Long" resultType="Long">
-		select r.role_id
+        <include refid="selectRoleVo"/>
+        where r.del_flag = '0'
+        <if test="roleId != null and roleId != 0">
+            AND r.role_id = #{roleId}
+        </if>
+        <if test="roleName != null and roleName != ''">
+            AND r.role_name like concat('%', #{roleName}, '%')
+        </if>
+        <if test="status != null and status != ''">
+            AND r.status = #{status}
+        </if>
+        <if test="roleKey != null and roleKey != ''">
+            AND r.role_key like concat('%', #{roleKey}, '%')
+        </if>
+        <if test="params.beginTime != null and params.beginTime != ''">
+            <!-- 开始时间检索 -->
+            and date_format(r.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(r.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
+        </if>
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
+        order by r.role_sort
+    </select>
+
+    <select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">
+        <include refid="selectRoleVo"/>
+        WHERE r.del_flag = '0' and ur.user_id = #{userId}
+    </select>
+
+    <select id="selectRoleAll" resultMap="SysRoleResult">
+        <include refid="selectRoleVo"/>
+    </select>
+
+    <select id="selectRoleListByUserId" parameterType="Long" resultType="Long">
+        select r.role_id
         from sys_role r
-	        left join sys_user_role ur on ur.role_id = r.role_id
-	        left join sys_user u on u.user_id = ur.user_id
-	    where u.user_id = #{userId}
-	</select>
-	
-	<select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult">
-		<include refid="selectRoleVo"/>
-		where r.id = #{roleId}
-	</select>
-	
-	<select id="selectRolesByUserName" parameterType="String" resultMap="SysRoleResult">
-		<include refid="selectRoleVo"/>
-		WHERE r.del_flag = '0' and u.username = #{userName}
-	</select>
-	
-	<select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult">
-		<include refid="selectRoleVo"/>
-		 where r.role_name=#{roleName} and r.del_flag = '0' limit 1
-	</select>
-	
-	<select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult">
-		<include refid="selectRoleVo"/>
-		 where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
-	</select>
-	<select id="getRoleNameByUserId" resultType="java.lang.String">
-		SELECT
-			GROUP_CONCAT( sr.role_name ) as roleName
-		FROM
-			sys_role sr
-				LEFT JOIN sys_user_role sur ON sur.role_id = sr.id
-		WHERE
-			sur.user_id =  #{userId}
-	</select>
+                 left join sys_user_role ur on ur.role_id = r.role_id
+                 left join sys_user u on u.user_id = ur.user_id
+        where u.user_id = #{userId}
+    </select>
+
+    <select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult">
+        <include refid="selectRoleVo"/>
+        where r.id = #{roleId}
+    </select>
+
+    <select id="selectRolesByUserName" parameterType="String" resultMap="SysRoleResult">
+        <include refid="selectRoleVo"/>
+        WHERE r.del_flag = '0' and u.username = #{userName}
+    </select>
+
+    <select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult">
+        <include refid="selectRoleVo"/>
+        where r.role_name=#{roleName} and r.del_flag = '0' limit 1
+    </select>
+
+    <select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult">
+        <include refid="selectRoleVo"/>
+        where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
+    </select>
+    <select id="getRoleNameByUserId" resultType="java.lang.String">
+        SELECT GROUP_CONCAT(sr.role_name) as roleName
+        FROM sys_role sr
+                 LEFT JOIN sys_user_role sur ON sur.role_id = sr.id
+        WHERE sur.user_id = #{userId}
+    </select>
     <select id="selectRoleNameByUserId" resultType="java.lang.String">
-		SELECT DISTINCT
-			GROUP_CONCAT( sr.role_name )
-		FROM
-			sys_user su
-				LEFT JOIN sys_user_role sur ON su.id = sur.user_id
-				LEFT JOIN sys_role sr ON sur.role_id = sr.id
-		WHERE
-			su.id = #{userId}
-	</select>
+        SELECT DISTINCT GROUP_CONCAT(sr.role_name)
+        FROM sys_user su
+                 LEFT JOIN sys_user_role sur ON su.id = sur.user_id
+                 LEFT JOIN sys_role sr ON sur.role_id = sr.id
+        WHERE su.id = #{userId}
+    </select>
+
+    <insert id="insertRole" parameterType="com.xunmei.system.api.domain.SysRole" useGeneratedKeys="true"
+            keyProperty="id">
+        insert into sys_role(
+        <if test="id != null and id != 0">
+            id,
+        </if>
+        <if test="orgType !=null and orgType != ''">
+            org_type,
+        </if>
+        <if test="roleName != null and roleName != ''">
+            role_name,
+        </if>
+        <if test="roleKey != null and roleKey != ''">
+            role_key,
+        </if>
+        <if test="roleSort != null">
+            role_sort,
+        </if>
+        <if test="dataScope != null and dataScope != ''">
+            data_scope,
+        </if>
+        <if test="menuCheckStrictly != null">
+            menu_check_strictly,
+        </if>
+        <if test="deptCheckStrictly != null">
+            dept_check_strictly,
+        </if>
+        <if test="status != null and status != ''">
+            status,
+        </if>
+        <if test="remark != null and remark != ''">
+            remark,
+        </if>
+        <if test="createBy != null and createBy != ''">
+            create_by,
+        </if>
+        create_time
+        )values(
+        <if test="id != null and id != 0">
+            #{id},
+        </if>
+        <if test="orgType !=null and orgType != ''">
+            #{orgType},
+        </if>
+        <if test="roleName != null and roleName != ''">
+            #{roleName},
+        </if>
+        <if test="roleKey != null and roleKey != ''">
+            #{roleKey},
+        </if>
+        <if test="roleSort != null">
+            #{roleSort},
+        </if>
+        <if test="dataScope != null and dataScope != ''">
+            #{dataScope},
+        </if>
+        <if test="menuCheckStrictly != null">
+            #{menuCheckStrictly},
+        </if>
+        <if test="deptCheckStrictly != null">
+            #{deptCheckStrictly},
+        </if>
+        <if test="status != null and status != ''">
+            #{status},
+        </if>
+        <if test="remark != null and remark != ''">
+            #{remark},
+        </if>
+        <if test="createBy != null and createBy != ''">
+            #{createBy},
+        </if>
+        sysdate()
+        )
+    </insert>
+
+    <update id="updateRole" parameterType="com.xunmei.system.api.domain.SysRole">
+        update sys_role
+        <set>
+            <if test="roleName != null and roleName != ''">
+                role_name = #{roleName},
+            </if>
+            <if test="orgType !=null and orgType != ''">
+                org_type =#{orgType},
+            </if>
+            <if test="roleKey != null and roleKey != ''">
+                role_key = #{roleKey},
+            </if>
+            <if test="roleSort != null">
+                role_sort = #{roleSort},
+            </if>
+            <if test="dataScope != null and dataScope != ''">
+                data_scope = #{dataScope},
+            </if>
+            <if test="menuCheckStrictly != null">
+                menu_check_strictly = #{menuCheckStrictly},
+            </if>
+            <if test="deptCheckStrictly != null">
+                dept_check_strictly = #{deptCheckStrictly},
+            </if>
+            <if test="status != null and status != ''">
+                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 id = #{id}
+    </update>
+
+    <delete id="deleteRoleById" parameterType="Long">
+        update sys_role
+        set del_flag = '2'
+        where role_id = #{roleId}
+    </delete>
+
+    <delete id="deleteRoleByIds" parameterType="Long">
+        update sys_role set del_flag = '2' where id in
+        <foreach collection="array" item="roleId" open="(" separator="," close=")">
+            #{roleId}
+        </foreach>
+    </delete>
 
-    <insert id="insertRole" parameterType="com.xunmei.system.api.domain.SysRole" useGeneratedKeys="true" keyProperty="id">
- 		insert into sys_role(
- 			<if test="id != null and id != 0">id,</if>
-		<if test="orgType !=null and orgType != ''"> org_type,</if>
- 			<if test="roleName != null and roleName != ''">role_name,</if>
- 			<if test="roleKey != null and roleKey != ''">role_key,</if>
- 			<if test="roleSort != null">role_sort,</if>
- 			<if test="dataScope != null and dataScope != ''">data_scope,</if>
- 			<if test="menuCheckStrictly != null">menu_check_strictly,</if>
- 			<if test="deptCheckStrictly != null">dept_check_strictly,</if>
- 			<if test="status != null and status != ''">status,</if>
- 			<if test="remark != null and remark != ''">remark,</if>
- 			<if test="createBy != null and createBy != ''">create_by,</if>
- 			create_time
- 		)values(
- 			<if test="id != null and id != 0">#{id},</if>
-		<if test="orgType !=null and orgType != ''"> #{orgType},</if>
- 			<if test="roleName != null and roleName != ''">#{roleName},</if>
- 			<if test="roleKey != null and roleKey != ''">#{roleKey},</if>
- 			<if test="roleSort != null">#{roleSort},</if>
- 			<if test="dataScope != null and dataScope != ''">#{dataScope},</if>
- 			<if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
- 			<if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
- 			<if test="status != null and status != ''">#{status},</if>
- 			<if test="remark != null and remark != ''">#{remark},</if>
- 			<if test="createBy != null and createBy != ''">#{createBy},</if>
- 			sysdate()
- 		)
-	</insert>
-	
-	<update id="updateRole" parameterType="com.xunmei.system.api.domain.SysRole">
- 		update sys_role
- 		<set>
- 			<if test="roleName != null and roleName != ''">role_name = #{roleName},</if>
- 		    <if test="orgType !=null and orgType != ''"> org_type =#{orgType},</if>
- 			<if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if>
- 			<if test="roleSort != null">role_sort = #{roleSort},</if>
- 			<if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if>
- 			<if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if>
- 			<if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
- 			<if test="status != null and status != ''">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 id = #{id}
-	</update>
-	
-	<delete id="deleteRoleById" parameterType="Long">
- 		update sys_role set del_flag = '2' where role_id = #{roleId}
- 	</delete>
- 	
- 	<delete id="deleteRoleByIds" parameterType="Long">
- 	    update sys_role set del_flag = '2' where id in
- 		<foreach collection="array" item="roleId" open="(" separator="," close=")">
- 			#{roleId}
-        </foreach> 
- 	</delete>
- 	
-</mapper> 
+    <select id="selectUserByRoleNameAndOrgId" resultType="com.xunmei.system.api.domain.SysUser">
+        select u.id, u.username
+        from sys_user u
+                 inner join sys_org o on u.org_id = o.id
+                 inner join sys_user_role ur on u.id = ur.user_id
+                 inner join sys_role r on ur.role_id = r.id
+        where r.role_name = #{roleName}
+          and o.id = #{orgId}
+    </select>
+</mapper>