| | |
| | | private Integer light2Percent; |
| | | |
| | | /** |
| | | * 功率 |
| | | */ |
| | | private Integer power1; |
| | | |
| | | private Integer power2; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private LocalDateTime createTime; |
| | |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | List<String> listCode(/*int start, int end,*/ Long userId); |
| | | List<String> listCode( Long userId); |
| | | } |
| | | |
| | | |
| | |
| | | <result property="remark" column="remark" jdbcType="VARCHAR"/> |
| | | <result property="lightPercent" column="light_percent" jdbcType="INTEGER"/> |
| | | <result property="light2Percent" column="light2_percent" jdbcType="INTEGER"/> |
| | | <result property="power1" column="power1" jdbcType="INTEGER"/> |
| | | <result property="power2" column="power2" jdbcType="INTEGER"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | |
| | | public ResponseVO<Object> controlEnergySaving() { |
| | | return ResponseUtil.success(lightService.controlEnergySaving()); |
| | | } |
| | | |
| | | /** |
| | | * 获取设备码 |
| | | */ |
| | | @GetMapping("/deviceCode") |
| | | public ResponseVO<Object> getDeviceCode(BaseConditionVO baseConditionVO) { |
| | | return ResponseUtil.success(lightService.listDeviceCode(baseConditionVO.getPageNo() , baseConditionVO.getPageSize())); |
| | | } |
| | | |
| | | /** |
| | | * 设置功率 |
| | | */ |
| | | @PostMapping("/setPower/{power1}/{power2}") |
| | | public ResponseVO<Object> setPower(@RequestBody List<Long> ids, @PathVariable Integer power1,@PathVariable Integer power2) { |
| | | if(ids.isEmpty()||power1==null||power2==null){ |
| | | return ResponseUtil.fail("id为空或者功率为空"); |
| | | } |
| | | boolean resule= lightService.setPower(ids,power1,power2); |
| | | return ResponseUtil.success(resule); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 获取用户所有的设备码 |
| | | */ |
| | | public List<String> listDeviceCode(/*int start, int end*/) { |
| | | return baseMapper.listCode(/*start,end,*/SecurityUtils.getClientId()); |
| | | public List<String> listDeviceCode(int start, int end) { |
| | | if (SecurityUtils.getClientId() != null) { |
| | | PageHelper.startPage(start, end); |
| | | return baseMapper.listCode(SecurityUtils.getUserId()); |
| | | } |
| | | PageHelper.startPage(start, end); |
| | | return baseMapper.listCode(null); |
| | | } |
| | | |
| | | public boolean setPower(List<Long> ids, Integer power1, Integer power2) { |
| | | List<Light> lights = listByIds(ids); |
| | | lights.forEach(light -> { |
| | | light.setPower1(power1); |
| | | light.setPower2(power2); |
| | | } |
| | | ); |
| | | return updateBatchById(lights); |
| | | } |
| | | } |