Commit f9c1cf9db5b863d743b05e35a985084dc0f93039

Authored by chenjunyu_1481036421
1 parent ab87b586

fix:产品品类超级管理员禁用后 租户不能查询到 2.应用配置返回组织名称

... ... @@ -40,16 +40,7 @@ public class TkDeviceProfileCategoryController extends BaseController {
40 40 @RequestParam(value = ORDER_FILED, required = false) String orderBy,
41 41 @RequestParam(value = "dictItemId", required = false) String dictItemId) throws ThingsboardException {
42 42
43   - HashMap<String, Object> queryMap = new HashMap<>();
44   - queryMap.put(PAGE_SIZE, pageSize);
45   - queryMap.put(PAGE, page);
46   - queryMap.put(ORDER_FILED, orderBy);
47   - queryMap.put("name", name);
48   - queryMap.put("status", status);
49   - queryMap.put("dictItemId", dictItemId);
50   - queryMap.put("isSysAdmin", getCurrentUser().isSystemAdmin());
51   - queryMap.put("tenantId", getCurrentUser().getTenantId());
52   - return service.page(queryMap);
  43 + return service.page(getCurrentUser().getTenantId().toString(),page,pageSize,getCurrentUser().isSystemAdmin(), null!=status?Integer.valueOf(status):null,dictItemId,name);
53 44 }
54 45
55 46 @PostMapping
... ...
1 1 package org.thingsboard.server.dao.yunteng.entities;
2 2
  3 +import com.baomidou.mybatisplus.annotation.TableField;
3 4 import com.baomidou.mybatisplus.annotation.TableName;
4 5 import lombok.Data;
5 6 import lombok.EqualsAndHashCode;
... ... @@ -27,4 +28,9 @@ public class TkApplicationEntity extends TenantBaseEntity {
27 28 /**组织id*/
28 29 private String organizationId;
29 30
  31 +
  32 + /**组织名称*/
  33 + @TableField(exist = false)
  34 + private String organizationName;
  35 +
30 36 }
... ...
... ... @@ -14,9 +14,11 @@ import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils;
14 14 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
15 15 import org.thingsboard.server.dao.yunteng.entities.TkApplicationApiEntity;
16 16 import org.thingsboard.server.dao.yunteng.entities.TkApplicationEntity;
  17 +import org.thingsboard.server.dao.yunteng.entities.TkOrganizationEntity;
17 18 import org.thingsboard.server.dao.yunteng.mapper.ApplicationApiMapper;
18 19 import org.thingsboard.server.dao.yunteng.mapper.ApplicationMapper;
19 20 import org.thingsboard.server.dao.yunteng.mapper.OpenApiRecordMapper;
  21 +import org.thingsboard.server.dao.yunteng.mapper.OrganizationMapper;
20 22 import org.thingsboard.server.dao.yunteng.service.AbstractBaseService;
21 23 import org.thingsboard.server.dao.yunteng.service.ApplicationService;
22 24
... ... @@ -35,6 +37,7 @@ public class ApplicationServiceImpl extends AbstractBaseService<ApplicationMappe
35 37 private static final SecureRandom secureRandom = new SecureRandom();
36 38 private static final Base64.Encoder base64Encoder = Base64.getUrlEncoder().withoutPadding();
37 39 private final OpenApiRecordMapper openApiRecordMapper;
  40 + private final OrganizationMapper organizationMapper;
38 41
39 42 @Override
40 43 public ApplicationDTO getDto(String id) {
... ... @@ -69,6 +72,13 @@ public class ApplicationServiceImpl extends AbstractBaseService<ApplicationMappe
69 72 queryMap.get("organizationIds") != null,
70 73 TkApplicationEntity::getOrganizationId,
71 74 (List<String>)queryMap.get("organizationIds")));
  75 + List<TkApplicationEntity> list = iPage.getRecords();
  76 + list.stream().forEach(e->{
  77 + TkOrganizationEntity org = organizationMapper.selectById(e.getOrganizationId());
  78 + if(null!=org){
  79 + e.setOrganizationName(org.getName());
  80 + }
  81 + });
72 82 return getPageData(iPage, ApplicationDTO.class);
73 83 }
74 84
... ...
... ... @@ -47,38 +47,16 @@ public class TkDeviceProfileCategoryServiceImpl extends AbstractBaseService<TkDe
47 47 private final TkEdgeSyncService tkEdgeSyncService;
48 48
49 49 @Override
50   - public TkPageData<TkDeviceProfileCategoryDTO> page(Map<String, Object> queryMap) {
51   - Integer status =
52   - queryMap.get("status") != null ? Integer.valueOf(queryMap.get("status").toString()) : null;
53   - List<String> tenantIds = null;
54   - if(!(boolean)queryMap.get("isSysAdmin")){
55   - tenantIds = new ArrayList<>();
56   - tenantIds.add(queryMap.get("tenantId").toString());
57   - tenantIds.add(TenantId.SYS_TENANT_ID.toString());
58   - }
59   - IPage<TkDeviceProfileCategoryEntity> iPage =
60   - baseMapper.selectPage(
61   - getPage(queryMap, "create_time", false),
62   - new QueryWrapper<TkDeviceProfileCategoryEntity>()
63   - .lambda()
64   - .eq(
65   - status != null,
66   - TkDeviceProfileCategoryEntity::getStatus,
67   - status)
68   - .eq(
69   - queryMap.get("dictItemId") != null,
70   - TkDeviceProfileCategoryEntity::getDictItemId,
71   - String.valueOf(queryMap.get("dictItemId")))
72   - .in(
73   - tenantIds!=null,
74   - TkDeviceProfileCategoryEntity::getTenantId,
75   - tenantIds)
76   - .like(
77   - queryMap.get("name") != null,
78   - TkDeviceProfileCategoryEntity::getName,
79   - String.valueOf(queryMap.get("name")))
80   - );
81   - return getPageData(iPage, TkDeviceProfileCategoryDTO.class);
  50 + public TkPageData<TkDeviceProfileCategoryDTO> page(String tenantId,
  51 + Integer page,
  52 + Integer pageSize,
  53 + boolean isSysAdmin,
  54 + Integer status,
  55 + String dictItemId,
  56 + String name) {
  57 + List<TkDeviceProfileCategoryDTO> pageEntity = baseMapper.getPage(tenantId,page-1,pageSize,isSysAdmin,status,dictItemId,name);
  58 + Long pageCount = baseMapper.getPageSize(tenantId,isSysAdmin,status,dictItemId,name);
  59 + return new TkPageData<>(pageEntity, pageCount);
82 60 }
83 61
84 62 @Override
... ...
... ... @@ -2,9 +2,28 @@ package org.thingsboard.server.dao.yunteng.mapper;
2 2
3 3 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4 import org.apache.ibatis.annotations.Mapper;
  5 +import org.apache.ibatis.annotations.Param;
  6 +import org.thingsboard.server.common.data.yunteng.dto.TkDeviceProfileCategoryDTO;
5 7 import org.thingsboard.server.dao.yunteng.entities.TkDeviceProfileCategoryEntity;
6 8
  9 +import java.util.List;
  10 +
7 11 @Mapper
8 12 public interface TkDeviceProfileCategoryMapper extends BaseMapper<TkDeviceProfileCategoryEntity> {
9 13
  14 + List<TkDeviceProfileCategoryDTO> getPage(@Param("tenantId") String tenantId,
  15 + @Param("page")Integer page,
  16 + @Param("pageSize")Integer pageSize,
  17 + @Param("isSysAdmin")boolean isSysAdmin,
  18 + @Param("status")Integer status,
  19 + @Param("dictItemId")String dictItemId,
  20 + @Param("name")String name
  21 + );
  22 + Long getPageSize(@Param("tenantId") String tenantId,
  23 + @Param("isSysAdmin")boolean isSysAdmin,
  24 + @Param("status")Integer status,
  25 + @Param("dictItemId")String dictItemId,
  26 + @Param("name")String name
  27 + );
  28 +
10 29 }
... ...
1 1 package org.thingsboard.server.dao.yunteng.service;
2 2
  3 +import org.apache.ibatis.annotations.Param;
3 4 import org.thingsboard.server.common.data.yunteng.dto.SysDictDTO;
4 5 import org.thingsboard.server.common.data.yunteng.dto.TkDeviceProfileCategoryDTO;
5 6 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
... ... @@ -9,7 +10,13 @@ import java.util.Set;
9 10
10 11 public interface TkDeviceProfileCategoryService {
11 12
12   - TkPageData<TkDeviceProfileCategoryDTO> page(Map<String, Object> queryMap);
  13 + TkPageData<TkDeviceProfileCategoryDTO> page(String tenantId,
  14 + Integer page,
  15 + Integer pageSize,
  16 + boolean isSysAdmin,
  17 + Integer status,
  18 + String dictItemId,
  19 + String name);
13 20
14 21 TkDeviceProfileCategoryDTO saveOrUpdate(TkDeviceProfileCategoryDTO sysDictDTO,boolean isSysAdmin ,String tenantId);
15 22
... ...
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +
  4 +<mapper namespace="org.thingsboard.server.dao.yunteng.mapper.TkDeviceProfileCategoryMapper">
  5 + <resultMap type="org.thingsboard.server.common.data.yunteng.dto.TkDeviceProfileCategoryDTO" id="DTOMap">
  6 + <result property="id" column="id"/>
  7 + <result property="name" column="name"/>
  8 + <result property="dictItemId" column="dict_item_id"/>
  9 + <result property="dictItemName" column="dict_item_name"/>
  10 + <result property="status" column="status"/>
  11 + <result property="tenantId" column="tenant_id"/>
  12 + <result property="createTime" column="create_time"/>
  13 + <result property="creator" column="creator"/>
  14 + <result property="updateTime" column="update_time"/>
  15 + <result property="updater" column="updater"/>
  16 + </resultMap>
  17 +
  18 + <select id="getPage" resultMap="DTOMap">
  19 + SELECT id,name,dict_item_id,dict_item_name,status,tenant_id,create_time,creator,update_time,updater
  20 + FROM tk_device_profile_category
  21 + WHERE 1=1
  22 + <if test="isSysAdmin == false ">
  23 + AND tenant_id = '13814000-1dd2-11b2-8080-808080808080' AND status = 1
  24 + OR tenant_id = #{tenantId}
  25 + </if>
  26 + <if test="status !=null and status !=''">
  27 + AND status = #{status}
  28 + </if>
  29 + <if test="dictItemId !=null and dictItemId !=''">
  30 + AND dict_item_id = #{dictItemId}
  31 + </if>
  32 + <if test="name !=null and name !=''">
  33 + AND name = #{name}
  34 + </if>
  35 + ORDER BY create_time desc
  36 + <if test="page != null">
  37 + LIMIT #{pageSize} OFFSET #{page}
  38 + </if>
  39 + </select>
  40 +
  41 + <select id="getPageSize" resultType="java.lang.Long">
  42 + SELECT COUNT(1)
  43 + FROM tk_device_profile_category
  44 + WHERE 1=1
  45 + <if test="isSysAdmin == false ">
  46 + AND tenant_id = '13814000-1dd2-11b2-8080-808080808080' AND status = 1
  47 + OR tenant_id = #{tenantId}
  48 + </if>
  49 + <if test="status !=null and status !=''">
  50 + AND status = #{status}
  51 + </if>
  52 + <if test="dictItemId !=null and dictItemId !=''">
  53 + AND dict_item_id = #{dictItemId}
  54 + </if>
  55 + <if test="name !=null and name !=''">
  56 + AND name = #{name}
  57 + </if>
  58 + </select>
  59 +
  60 +
  61 +
  62 +</mapper>
... ...