给租户模块接口增加租户角色的查询参数
This commit is contained in:
parent
bd1d96b58d
commit
d4d8fce641
@ -10,6 +10,7 @@ public interface TenantMapperEx {
|
||||
|
||||
List<TenantEx> selectByConditionTenant(
|
||||
@Param("loginName") String loginName,
|
||||
@Param("roleId") Long roleId,
|
||||
@Param("type") String type,
|
||||
@Param("enabled") String enabled,
|
||||
@Param("remark") String remark,
|
||||
@ -18,6 +19,7 @@ public interface TenantMapperEx {
|
||||
|
||||
Long countsByTenant(
|
||||
@Param("loginName") String loginName,
|
||||
@Param("roleId") Long roleId,
|
||||
@Param("type") String type,
|
||||
@Param("enabled") String enabled,
|
||||
@Param("remark") String remark);
|
||||
|
||||
@ -34,20 +34,22 @@ public class TenantComponent implements ICommonQuery {
|
||||
private List<?> getTenantList(Map<String, String> map)throws Exception {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String loginName = StringUtil.getInfo(search, "loginName");
|
||||
Long roleId = StringUtil.parseStrLong(StringUtil.getInfo(search, "roleId"));
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String enabled = StringUtil.getInfo(search, "enabled");
|
||||
String remark = StringUtil.getInfo(search, "remark");
|
||||
return tenantService.select(loginName, type, enabled, remark, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
return tenantService.select(loginName, roleId, type, enabled, remark, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long counts(Map<String, String> map)throws Exception {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String loginName = StringUtil.getInfo(search, "loginName");
|
||||
Long roleId = StringUtil.parseStrLong(StringUtil.getInfo(search, "roleId"));
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String enabled = StringUtil.getInfo(search, "enabled");
|
||||
String remark = StringUtil.getInfo(search, "remark");
|
||||
return tenantService.countTenant(loginName, type, enabled, remark);
|
||||
return tenantService.countTenant(loginName, roleId, type, enabled, remark);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -75,11 +75,11 @@ public class TenantService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<TenantEx> select(String loginName, String type, String enabled, String remark, int offset, int rows)throws Exception {
|
||||
public List<TenantEx> select(String loginName, Long roleId, String type, String enabled, String remark, int offset, int rows)throws Exception {
|
||||
List<TenantEx> list= new ArrayList<>();
|
||||
try{
|
||||
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
|
||||
list = tenantMapperEx.selectByConditionTenant(loginName, type, enabled, remark, offset, rows);
|
||||
list = tenantMapperEx.selectByConditionTenant(loginName, roleId, type, enabled, remark, offset, rows);
|
||||
if (null != list) {
|
||||
for (TenantEx tenantEx : list) {
|
||||
tenantEx.setCreateTimeStr(Tools.getCenternTime(tenantEx.getCreateTime()));
|
||||
@ -93,11 +93,11 @@ public class TenantService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public Long countTenant(String loginName, String type, String enabled, String remark)throws Exception {
|
||||
public Long countTenant(String loginName, Long roleId, String type, String enabled, String remark)throws Exception {
|
||||
Long result=null;
|
||||
try{
|
||||
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
|
||||
result = tenantMapperEx.countsByTenant(loginName, type, enabled, remark);
|
||||
result = tenantMapperEx.countsByTenant(loginName, roleId, type, enabled, remark);
|
||||
}
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
|
||||
@ -9,55 +9,60 @@
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByConditionTenant" parameterType="com.jsh.erp.datasource.entities.TenantExample" resultMap="ResultMapEx">
|
||||
select jsh_tenant.*,
|
||||
(select r.id from jsh_user_business ub
|
||||
select t.*, r.id roleId, r.name roleName,
|
||||
(select count(jsh_user.id) from jsh_user where jsh_user.status='0' and jsh_user.delete_flag=0 and jsh_user.tenant_id=t.tenant_id) userCount
|
||||
from jsh_tenant t
|
||||
left join jsh_user_business ub on ub.key_id = t.tenant_id and ifnull(ub.delete_flag,'0') !='1'
|
||||
left join jsh_role r on ub.value=concat("[",r.id,"]") and ifnull(r.delete_flag,'0') !='1'
|
||||
where ub.type='UserRole' and ub.key_id=jsh_tenant.tenant_id limit 0,1) roleId,
|
||||
(select r.name from jsh_user_business ub
|
||||
left join jsh_role r on ub.value=concat("[",r.id,"]") and ifnull(r.delete_flag,'0') !='1'
|
||||
where ub.type='UserRole' and ub.key_id=jsh_tenant.tenant_id limit 0,1) roleName,
|
||||
(select count(jsh_user.id) from jsh_user where jsh_user.status='0' and jsh_user.delete_flag=0 and jsh_user.tenant_id=jsh_tenant.tenant_id) userCount
|
||||
FROM jsh_tenant
|
||||
where 1=1
|
||||
where ub.type='UserRole'
|
||||
<if test="loginName != null">
|
||||
<bind name="bindLoginName" value="'%'+loginName+'%'"/>
|
||||
and login_name like #{bindLoginName}
|
||||
and t.login_name like #{bindLoginName}
|
||||
</if>
|
||||
<if test="roleId != null and roleId != ''">
|
||||
and r.id = #{roleId}
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
and type = #{type}
|
||||
and t.type = #{type}
|
||||
</if>
|
||||
<if test="enabled != null and enabled != ''">
|
||||
and enabled = #{enabled}
|
||||
and t.enabled = #{enabled}
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
<bind name="bindRemark" value="'%'+remark+'%'"/>
|
||||
and remark like #{bindRemark}
|
||||
and t.remark like #{bindRemark}
|
||||
</if>
|
||||
and ifnull(delete_flag,'0') !='1'
|
||||
order by id desc
|
||||
and ifnull(t.delete_flag,'0') !='1'
|
||||
order by t.id desc
|
||||
<if test="offset != null and rows != null">
|
||||
limit #{offset},#{rows}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="countsByTenant" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT(id)
|
||||
FROM jsh_tenant
|
||||
WHERE 1=1
|
||||
select
|
||||
count(t.id)
|
||||
from jsh_tenant t
|
||||
left join jsh_user_business ub on ub.key_id = t.tenant_id and ifnull(ub.delete_flag,'0') !='1'
|
||||
left join jsh_role r on ub.value=concat("[",r.id,"]") and ifnull(r.delete_flag,'0') !='1'
|
||||
where ub.type='UserRole'
|
||||
<if test="loginName != null">
|
||||
<bind name="bindLoginName" value="'%'+loginName+'%'"/>
|
||||
and login_name like #{bindLoginName}
|
||||
and t.login_name like #{bindLoginName}
|
||||
</if>
|
||||
<if test="roleId != null and roleId != ''">
|
||||
and r.id = #{roleId}
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
and type = #{type}
|
||||
and t.type = #{type}
|
||||
</if>
|
||||
<if test="enabled != null and enabled != ''">
|
||||
and enabled = #{enabled}
|
||||
and t.enabled = #{enabled}
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
<bind name="bindRemark" value="'%'+remark+'%'"/>
|
||||
and remark like #{bindRemark}
|
||||
and t.remark like #{bindRemark}
|
||||
</if>
|
||||
and ifnull(delete_flag,'0') !='1'
|
||||
and ifnull(t.delete_flag,'0') !='1'
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user