|
@@ -1,28 +1,67 @@
|
|
|
package com.xy.service;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.xy.config.XyMqttConfig;
|
|
|
import com.xy.dto.MqttAclDto;
|
|
|
import com.xy.entity.MqttAcl;
|
|
|
import com.xy.mapper.MqttAclMapper;
|
|
|
-import com.xy.service.MqttAclService;
|
|
|
-import com.xy.utils.Beans;
|
|
|
import com.xy.utils.MybatisPlusQuery;
|
|
|
+import com.xy.utils.PageBean;
|
|
|
import com.xy.utils.R;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+
|
|
|
+import static com.xy.utils.Beans.copy;
|
|
|
+import static com.xy.utils.PlusBeans.toIPage;
|
|
|
+import static com.xy.utils.PlusBeans.toPageBean;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
- * mqtt授权 接口实现
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author lijin
|
|
|
+ * @since 2023-01-10
|
|
|
*/
|
|
|
@Service
|
|
|
-@Api(tags = "mqtt授权")
|
|
|
+@AllArgsConstructor
|
|
|
+@Api(tags = "")
|
|
|
public class MqttAclServiceImpl extends ServiceImpl<MqttAclMapper, MqttAcl> implements MqttAclService {
|
|
|
|
|
|
- @Override
|
|
|
- @ApiOperation("获取mqtt信息")
|
|
|
- public R<MqttAclDto.Vo> get(MqttAclDto.Vo vo) {
|
|
|
- MqttAcl mqttAclInfo = getOne(new MybatisPlusQuery().eqWrapper(vo, MqttAcl.class).build());
|
|
|
- return R.ok(Beans.copy(MqttAclDto.Vo.class, mqttAclInfo));
|
|
|
+ private XyMqttConfig xyMqttConfig;
|
|
|
+
|
|
|
+ @PostMapping("page")
|
|
|
+ @ApiOperation("分页查询")
|
|
|
+ private R<PageBean<MqttAclDto.Vo>> page(@RequestBody MqttAclDto.Page page) {
|
|
|
+ PageBean pageBean = page.getPage();
|
|
|
+ LambdaQueryWrapper<MqttAcl> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(page, MqttAcl.class).build();
|
|
|
+ IPage<MqttAcl> iPage = page(toIPage(pageBean), lambdaQueryWrapper);
|
|
|
+ return R.ok(toPageBean(MqttAclDto.Vo.class, iPage));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("save")
|
|
|
+ @ApiOperation("添加")
|
|
|
+ public R save(@RequestBody @Validated MqttAclDto.Save save) {
|
|
|
+ MqttAcl saveInfo = copy(MqttAcl.class, save)
|
|
|
+ .setIpaddress(xyMqttConfig.getUrl())
|
|
|
+ .setTopic(save.getClientid() + "-CMD");
|
|
|
+ save(saveInfo);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("update")
|
|
|
+ @ApiOperation("修改")
|
|
|
+ public R update(@RequestBody @Validated MqttAclDto.Update update) {
|
|
|
+ MqttAcl updateInfo = copy(MqttAcl.class, update);
|
|
|
+ updateById(updateInfo);
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
-}
|
|
|
+}
|