Showing
3 changed files
with
27 additions
and
12 deletions
... | ... | @@ -43,12 +43,17 @@ public class ThingsModelController extends BaseController { |
43 | 43 | params = {PAGE_SIZE, PAGE}) |
44 | 44 | @ApiOperation(value = "分页") |
45 | 45 | public YtPageData<ThingsModelDTO> page( |
46 | + @RequestParam("deviceProfileId") String deviceProfileId, | |
46 | 47 | @RequestParam(PAGE_SIZE) int pageSize, |
47 | 48 | @RequestParam(PAGE) int page, |
48 | 49 | @RequestParam(value = "nameOrIdentifier", required = false) String nameOrIdentifier, |
50 | + @RequestParam(value = "functionType", required = false) FunctionTypeEnum functionType, | |
49 | 51 | @RequestParam(value = ORDER_FILED, required = false) String orderBy, |
50 | 52 | @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType) |
51 | 53 | throws ThingsboardException { |
54 | + if(StringUtils.isEmpty(deviceProfileId)){ | |
55 | + throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | |
56 | + } | |
52 | 57 | HashMap<String, Object> queryMap = new HashMap<>(); |
53 | 58 | queryMap.put("nameOrIdentifier", nameOrIdentifier); |
54 | 59 | queryMap.put(PAGE_SIZE, pageSize); |
... | ... | @@ -57,7 +62,11 @@ public class ThingsModelController extends BaseController { |
57 | 62 | if (orderType != null) { |
58 | 63 | queryMap.put(ORDER_TYPE, orderType.name()); |
59 | 64 | } |
60 | - return thingsModelService.page(queryMap, getCurrentUser().getCurrentTenantId()); | |
65 | + if (functionType != null) { | |
66 | + queryMap.put("functionType", functionType); | |
67 | + } | |
68 | + return thingsModelService.page( | |
69 | + queryMap, getCurrentUser().getCurrentTenantId(), deviceProfileId); | |
61 | 70 | } |
62 | 71 | |
63 | 72 | @PostMapping() | ... | ... |
... | ... | @@ -37,23 +37,28 @@ public class ThingsModelServiceImpl |
37 | 37 | private final YtDeviceProfileService ytDeviceProfileService; |
38 | 38 | |
39 | 39 | @Override |
40 | - public YtPageData<ThingsModelDTO> page(Map<String, Object> queryMap, String tenantId) { | |
40 | + public YtPageData<ThingsModelDTO> page( | |
41 | + Map<String, Object> queryMap, String tenantId, String deviceProfileId) { | |
41 | 42 | String nameOrIdentifier = |
42 | 43 | null != queryMap.get("nameOrIdentifier") ? (String) queryMap.get("nameOrIdentifier") : null; |
44 | + String functionType = | |
45 | + null != queryMap.get("functionType") ? queryMap.get("functionType").toString() : null; | |
43 | 46 | IPage<TkThingsModelEntity> iPage = |
44 | 47 | baseMapper.selectPage( |
45 | 48 | getPage(queryMap, FastIotConstants.DefaultOrder.CREATE_TIME, false), |
46 | 49 | new LambdaQueryWrapper<TkThingsModelEntity>() |
47 | 50 | .eq(TkThingsModelEntity::getTenantId, tenantId) |
48 | - .like( | |
49 | - StringUtils.isNotEmpty(nameOrIdentifier), | |
50 | - TkThingsModelEntity::getFunctionName, | |
51 | - nameOrIdentifier) | |
52 | - .or() | |
53 | - .like( | |
51 | + .eq(TkThingsModelEntity::getDeviceProfileId, deviceProfileId) | |
52 | + .eq( | |
53 | + StringUtils.isNotEmpty(functionType), | |
54 | + TkThingsModelEntity::getFunctionType, | |
55 | + functionType) | |
56 | + .and( | |
54 | 57 | StringUtils.isNotEmpty(nameOrIdentifier), |
55 | - TkThingsModelEntity::getIdentifier, | |
56 | - nameOrIdentifier)); | |
58 | + qr -> | |
59 | + qr.like(TkThingsModelEntity::getFunctionName, nameOrIdentifier) | |
60 | + .or() | |
61 | + .like(TkThingsModelEntity::getIdentifier, nameOrIdentifier))); | |
57 | 62 | return getPageData(iPage, ThingsModelDTO.class); |
58 | 63 | } |
59 | 64 | ... | ... |
... | ... | @@ -10,7 +10,8 @@ import java.util.List; |
10 | 10 | import java.util.Map; |
11 | 11 | |
12 | 12 | public interface ThingsModelService { |
13 | - YtPageData<ThingsModelDTO> page(Map<String, Object> queryMap, String tenantId); | |
13 | + YtPageData<ThingsModelDTO> page( | |
14 | + Map<String, Object> queryMap, String tenantId, String deviceProfileId); | |
14 | 15 | |
15 | 16 | ThingsModelDTO saveOrUpdate(ThingsModelDTO thingsModelDTO); |
16 | 17 | |
... | ... | @@ -25,5 +26,5 @@ public interface ThingsModelService { |
25 | 26 | |
26 | 27 | JsonNode getTingsModelTSL(FunctionTypeEnum typeEnum, String tenantId, String deviceProfileId); |
27 | 28 | |
28 | - boolean changeTSLStatus(String deviceProfileId,String tenantId,Integer status); | |
29 | + boolean changeTSLStatus(String deviceProfileId, String tenantId, Integer status); | |
29 | 30 | } | ... | ... |