Showing
4 changed files
with
16 additions
and
10 deletions
... | ... | @@ -228,7 +228,7 @@ public class YtDeviceScriptController extends BaseController { |
228 | 228 | DeviceProfileDTO deviceProfileDTO, String scriptId, String scriptText) { |
229 | 229 | DeviceProfile tbDeviceProfile = new DeviceProfile(); |
230 | 230 | if (StringUtils.isNotBlank(deviceProfileDTO.getId())) { |
231 | - UUID profileId = UUID.fromString(deviceProfileDTO.getId()); | |
231 | + UUID profileId = UUID.fromString(deviceProfileDTO.getTbProfileId()); | |
232 | 232 | tbDeviceProfile.setId(new DeviceProfileId(profileId)); |
233 | 233 | tbDeviceProfile.setCreatedTime( |
234 | 234 | deviceProfileDTO.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli()); | ... | ... |
... | ... | @@ -169,15 +169,7 @@ public class YtDeviceProfileServiceImpl |
169 | 169 | |
170 | 170 | @Override |
171 | 171 | public List<DeviceProfileDTO> findDeviceProfile(String tenantId, String scriptId) { |
172 | - LambdaQueryWrapper<YtDeviceProfileEntity> queryWrapper = | |
173 | - new QueryWrapper<YtDeviceProfileEntity>() | |
174 | - .lambda() | |
175 | - .eq(YtDeviceProfileEntity::getTenantId, tenantId) | |
176 | - .eq(StringUtils.isNotEmpty(scriptId), YtDeviceProfileEntity::getScriptId, scriptId); | |
177 | - List<DeviceProfileDTO> results = | |
178 | - baseMapper.selectList(queryWrapper).stream() | |
179 | - .map(item -> item.getDTO(DeviceProfileDTO.class)) | |
180 | - .collect(Collectors.toList()); | |
172 | + List<DeviceProfileDTO> results = baseMapper.profileByScriptId(tenantId,scriptId); | |
181 | 173 | return results; |
182 | 174 | } |
183 | 175 | } | ... | ... |
... | ... | @@ -22,4 +22,6 @@ public interface YtDeviceProfileMapper extends BaseMapper<YtDeviceProfileEntity> |
22 | 22 | |
23 | 23 | IPage<DeviceProfileDTO> getProfilePage(IPage<?> page, @Param("tenantId") String tenantId, @Param("profileName") String profileName, @Param("transportType") String transportType); |
24 | 24 | |
25 | + | |
26 | + List<DeviceProfileDTO> profileByScriptId( @Param("tenantId") String tenantId, @Param("scriptId") String scriptId); | |
25 | 27 | } | ... | ... |
... | ... | @@ -63,4 +63,16 @@ |
63 | 63 | </if> |
64 | 64 | </where> |
65 | 65 | </select> |
66 | + <select id="profileByScriptId" resultMap="detail"> | |
67 | + SELECT | |
68 | + <include refid="basicColumns"/> | |
69 | + FROM device_profile base | |
70 | + LEFT JOIN iotfs_device_profile iot ON iot.tb_profile_id = base.id::TEXT | |
71 | + <where> | |
72 | + iot.tenant_id = #{tenantId} | |
73 | + <if test="scriptId !=null and scriptId !=''"> | |
74 | + AND iot.script_id = #{scriptId} | |
75 | + </if> | |
76 | + </where> | |
77 | + </select> | |
66 | 78 | </mapper> | ... | ... |