解决选择用户列表 如何通过用户单位通过外键关联再选中单位然后选择用户的问题
首先这里数据库的organization和user通过外键outkey1相关联

where: {state: 1}, (所有单位)或者
where: {amUnitId: adminInfo.amUnitId, state: 1},(本单位) 也可以
因为orgId 已经插入到adminInfo.amUnitId里面了
修改AdminController selectUser功能

加入:

之后:

已经变成了orgId
修改IuserDao.xml:
select id="search" parameterType="com.greathack.homlin.pojo.user.UserSearchCriteria" resultMap="resultUser" >
select u.*,org.orgName as orgName,org.orgId as orgId,org.parentName as parentName from user u left join organization org on u.outKey1 = org.outKey1
where 1 = 1
<if test="appCode != null"> and u.appCode=#{appCode}</if>
<if test="outKey1 != null"> and u.outKey1=#{outKey1}</if>
<if test="outKey2 != null"> and u.outKey2=#{outKey2}</if>
<if test="name != null and name !=''"> and u.userName=#{name}</if>
<if test="orgName != null and orgName !=''"> and u.orgName=#{orgName}</if>
<if test="orgId != null and orgId !=''"> and u.orgId=#{orgId}</if>
<if test="parentName != null and parentName !=''"> and u.parentName=#{parentName}</if>
<if test="userStateList!=null and userStateList.size>0">
and u.userState in
<foreach collection="userStateList" item="userState" separator=" , " open="(" close=")">
#{userState}
</foreach>
</if>
<if test="kwFieldList!=null and kwFieldList.size>0 and keyword!=null">
and
<foreach collection="kwFieldList" item="kwField" separator=" or " open="(" close=")">
${kwField} LIKE concat('%',#{keyword},'%')
</foreach>
</if>
<if test="sortField == 1"> ORDER BY u.createTime DESC </if>
<if test="sortField == 2"> ORDER BY u.createTime ASC</if>
LIMIT #{startLine},#{pageSize}
</select>
<select id="getSearchResultCount" parameterType="com.greathack.homlin.pojo.user.UserSearchCriteria" resultType="long" >
select count(u.id) from user u left join organization org on u.outKey1 = org.outKey1
where 1 = 1
<if test="appCode != null"> and u.appCode=#{appCode}</if>
<if test="outKey1 != null"> and u.outKey1=#{outKey1}</if>
<if test="outKey2 != null"> and u.outKey2=#{outKey2}</if>
<if test="name != null and name !=''"> and u.userName=#{name}</if>
<if test="orgName != null and orgName !=''"> and u.orgName=#{orgName}</if>
<if test="orgId != null and orgId !=''"> and u.orgId=#{orgId}</if>
<if test="parentName != null and parentName !=''"> and u.parentName=#{parentName}</if>
<if test="userStateList!=null and userStateList.size>0">
and u.userState in
<foreach collection="userStateList" item="userState" separator=" , " open="(" close=")">
#{userState}
</foreach>
</if>
<if test="kwFieldList!=null and kwFieldList.size>0 and keyword!=null">
and
<foreach collection="kwFieldList" item="kwField" separator=" or " open="(" close=")">
${kwField} LIKE concat('%',#{keyword},'%')
</foreach>
</if>
</select>

需要注意的是!!!:

代替号一定要加上!!!同时:




浙公网安备 33010602011771号