diff --git a/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/MqttServerController.java b/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/MqttServerController.java new file mode 100644 index 0000000..8ab860b --- /dev/null +++ b/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/MqttServerController.java @@ -0,0 +1,68 @@ +package com.agileboot.admin.controller.cabinet; + +import com.agileboot.admin.customize.aop.accessLog.AccessLog; +import com.agileboot.common.core.base.BaseController; +import com.agileboot.common.core.dto.ResponseDTO; +import com.agileboot.common.core.page.PageDTO; +import com.agileboot.common.enums.common.BusinessTypeEnum; +import com.agileboot.domain.cabinet.mqtt.MqttServerApplicationService; +import com.agileboot.domain.cabinet.mqtt.command.AddMqttServerCommand; +import com.agileboot.domain.cabinet.mqtt.command.UpdateMqttServerCommand; +import com.agileboot.domain.cabinet.mqtt.db.MqttServerEntity; +import com.agileboot.domain.cabinet.mqtt.dto.MqttServerDTO; +import com.agileboot.domain.cabinet.mqtt.query.SearchMqttServerQuery; +import com.agileboot.domain.common.command.BulkOperationCommand; +import io.swagger.v3.oas.annotations.Operation; +import java.util.List; +import javax.validation.constraints.NotNull; +import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/cabinet/mqttServer") +@RequiredArgsConstructor +@Validated +public class MqttServerController extends BaseController { + + private final MqttServerApplicationService mqttServerApplicationService; + + @Operation(summary = "MQTT服务列表") + @GetMapping + public ResponseDTO> list(SearchMqttServerQuery query) { + PageDTO page = mqttServerApplicationService.getMqttServerList(query); + return ResponseDTO.ok(page); + } + + @Operation(summary = "新增MQTT服务") + @AccessLog(title = "MQTT服务管理", businessType = BusinessTypeEnum.ADD) + @PostMapping + public ResponseDTO add(@Validated @RequestBody AddMqttServerCommand command) { + mqttServerApplicationService.addMqttServer(command); + return ResponseDTO.ok(); + } + + @Operation(summary = "修改MQTT服务") + @AccessLog(title = "MQTT服务管理", businessType = BusinessTypeEnum.MODIFY) + @PutMapping("/{serverId}") + public ResponseDTO edit(@PathVariable Long serverId, @Validated @RequestBody UpdateMqttServerCommand command) { + command.setMqttServerId(serverId); + mqttServerApplicationService.updateMqttServer(command); + return ResponseDTO.ok(); + } + + @Operation(summary = "删除MQTT服务") + @AccessLog(title = "MQTT服务管理", businessType = BusinessTypeEnum.DELETE) + @DeleteMapping("/{ids}") + public ResponseDTO remove(@PathVariable @NotNull List ids) { + mqttServerApplicationService.deleteMqttServer(new BulkOperationCommand<>(ids)); + return ResponseDTO.ok(); + } +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/MqttServerApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/MqttServerApplicationService.java new file mode 100644 index 0000000..a3e8f54 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/MqttServerApplicationService.java @@ -0,0 +1,58 @@ +package com.agileboot.domain.cabinet.mqtt; + +import com.agileboot.common.core.page.PageDTO; +import com.agileboot.domain.common.command.BulkOperationCommand; +import com.agileboot.domain.cabinet.mqtt.command.AddMqttServerCommand; +import com.agileboot.domain.cabinet.mqtt.command.UpdateMqttServerCommand; +import com.agileboot.domain.cabinet.mqtt.db.MqttServerEntity; +import com.agileboot.domain.cabinet.mqtt.db.MqttServerService; +import com.agileboot.domain.cabinet.mqtt.dto.MqttServerDTO; +import com.agileboot.domain.cabinet.mqtt.model.MqttServerModel; +import com.agileboot.domain.cabinet.mqtt.model.MqttServerModelFactory; +import com.agileboot.domain.cabinet.mqtt.query.SearchMqttServerQuery; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.cache.annotation.Cacheable; +import java.util.List; +import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class MqttServerApplicationService { + private final MqttServerService mqttServerService; + private final MqttServerModelFactory mqttServerModelFactory; + + public PageDTO getMqttServerList(SearchMqttServerQuery query) { + Page page = mqttServerService.getServerList(query); + List dtoList = page.getRecords().stream() + .map(MqttServerDTO::new) + .collect(Collectors.toList()); + return new PageDTO<>(dtoList, page.getTotal()); + } + + public MqttServerEntity getByServerId(Long serverId) { + return mqttServerService.getById(serverId); + } + + public void addMqttServer(AddMqttServerCommand command) { + MqttServerModel model = mqttServerModelFactory.create(); + model.loadAddCommand(command); + model.insert(); + } + + public void updateMqttServer(UpdateMqttServerCommand command) { + MqttServerModel model = mqttServerModelFactory.loadById(command.getMqttServerId()); + model.loadUpdateCommand(command); + model.updateById(); + } + + public void deleteMqttServer(BulkOperationCommand command) { + for (Long id : command.getIds()) { + MqttServerModel model = mqttServerModelFactory.loadById(id); + model.deleteById(); + } + } +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/command/AddMqttServerCommand.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/command/AddMqttServerCommand.java new file mode 100644 index 0000000..a9cfedf --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/command/AddMqttServerCommand.java @@ -0,0 +1,11 @@ +package com.agileboot.domain.cabinet.mqtt.command; + +import com.agileboot.domain.cabinet.mqtt.db.MqttServerEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class AddMqttServerCommand extends MqttServerEntity { + +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/command/UpdateMqttServerCommand.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/command/UpdateMqttServerCommand.java new file mode 100644 index 0000000..20ed7c2 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/command/UpdateMqttServerCommand.java @@ -0,0 +1,16 @@ +package com.agileboot.domain.cabinet.mqtt.command; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.PositiveOrZero; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class UpdateMqttServerCommand extends AddMqttServerCommand { + + @NotNull + @PositiveOrZero + private Long mqttServerId; + +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/db/MqttServerEntity.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/db/MqttServerEntity.java new file mode 100644 index 0000000..e217f14 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/db/MqttServerEntity.java @@ -0,0 +1,60 @@ +package com.agileboot.domain.cabinet.mqtt.db; + +import com.agileboot.common.core.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +/** + *

+ * MQTT服务配置表 + *

+ * + * @author valarchie + * @since 2025-05-08 + */ +@Getter +@Setter +@TableName("mqtt_server") +@ApiModel(value = "MqttServerEntity对象", description = "MQTT服务配置表") +public class MqttServerEntity extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键ID") + @TableId(value = "mqtt_server_id", type = IdType.AUTO) + private Long mqttServerId; + + @ApiModelProperty("MQTT服务器地址") + @TableField("server_url") + private String serverUrl; + + @ApiModelProperty("连接账号") + @TableField("username") + private String username; + + @ApiModelProperty("连接密码") + @TableField("`password`") + private String password; + + @ApiModelProperty("订阅主题过滤器") + @TableField("topic_filter") + private String topicFilter; + + @ApiModelProperty("发布主题") + @TableField("publish_topic") + private String publishTopic; + + + @Override + public Serializable pkVal() { + return this.mqttServerId; + } + +} diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/db/MqttServerMapper.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/db/MqttServerMapper.java new file mode 100644 index 0000000..844cc79 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/db/MqttServerMapper.java @@ -0,0 +1,35 @@ +package com.agileboot.domain.cabinet.mqtt.db; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.util.List; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +/** + *

+ * MQTT服务配置表 Mapper 接口 + *

+ * + * @author valarchie + * @since 2025-05-08 + */ +public interface MqttServerMapper extends BaseMapper { + + @Select("SELECT mqtt_server_id, server_url, username, password, topic_filter, publish_topic " + + "FROM mqtt_server " + + "${ew.customSqlSegment}") + Page getMqttServerList( + Page page, + @Param(Constants.WRAPPER) Wrapper queryWrapper + ); + + @Select("SELECT * FROM mqtt_server WHERE server_url = #{serverUrl} LIMIT 1") + MqttServerEntity selectByServerUrl(String serverUrl); + + @Select("SELECT * FROM mqtt_server WHERE mqtt_server_id = #{id} LIMIT 1") + MqttServerEntity selectById(Long id); + +} diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/db/MqttServerService.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/db/MqttServerService.java new file mode 100644 index 0000000..57507f7 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/db/MqttServerService.java @@ -0,0 +1,21 @@ +package com.agileboot.domain.cabinet.mqtt.db; + +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * MQTT服务配置表 服务类 + *

+ * + * @author valarchie + * @since 2025-05-08 + */ +import com.agileboot.common.core.page.AbstractPageQuery; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.util.List; + +public interface MqttServerService extends IService { + Page getServerList(AbstractPageQuery query); + + List selectAll(); +} diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/db/MqttServerServiceImpl.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/db/MqttServerServiceImpl.java new file mode 100644 index 0000000..4bf8dc7 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/db/MqttServerServiceImpl.java @@ -0,0 +1,34 @@ +package com.agileboot.domain.cabinet.mqtt.db; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * MQTT服务配置表 服务实现类 + *

+ * + * @author valarchie + * @since 2025-05-08 + */ +import com.agileboot.common.core.page.AbstractPageQuery; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.util.List; + +@Service +public class MqttServerServiceImpl extends ServiceImpl implements MqttServerService { + @Override + public Page getServerList(AbstractPageQuery query) { + return this.page(query.toPage(), query.toQueryWrapper()); + } + + @Override + public List selectAll() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(MqttServerEntity::getDeleted, false) + .orderByDesc(MqttServerEntity::getCreateTime); + return this.list(wrapper); + } + +} diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/dto/MqttServerDTO.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/dto/MqttServerDTO.java new file mode 100644 index 0000000..c55996a --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/dto/MqttServerDTO.java @@ -0,0 +1,38 @@ +package com.agileboot.domain.cabinet.mqtt.dto; + +import cn.hutool.core.bean.BeanUtil; +import com.agileboot.common.annotation.ExcelColumn; +import com.agileboot.common.annotation.ExcelSheet; +import com.agileboot.domain.cabinet.mqtt.db.MqttServerEntity; +import com.agileboot.domain.common.cache.CacheCenter; +import com.agileboot.domain.system.user.db.SysUserEntity; +import lombok.Data; + +@ExcelSheet(name = "MQTT服务配置列表") +@Data +public class MqttServerDTO { + + public MqttServerDTO(MqttServerEntity entity) { + if (entity != null) { + BeanUtil.copyProperties(entity, this); + } + } + + @ExcelColumn(name = "服务ID") + private Long mqttServerId; + + @ExcelColumn(name = "服务器地址") + private String serverUrl; + + @ExcelColumn(name = "用户名") + private String username; + + @ExcelColumn(name = "密码") + private String password; + + @ExcelColumn(name = "订阅主题") + private String topicFilter; + + @ExcelColumn(name = "发布主题") + private String publishTopic; +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/model/MqttServerModel.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/model/MqttServerModel.java new file mode 100644 index 0000000..2035c09 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/model/MqttServerModel.java @@ -0,0 +1,39 @@ +package com.agileboot.domain.cabinet.mqtt.model; + +import cn.hutool.core.bean.BeanUtil; +import com.agileboot.domain.cabinet.mqtt.db.MqttServerEntity; +import com.agileboot.domain.cabinet.mqtt.command.AddMqttServerCommand; +import com.agileboot.domain.cabinet.mqtt.command.UpdateMqttServerCommand; +import com.agileboot.domain.cabinet.mqtt.db.MqttServerService; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class MqttServerModel extends MqttServerEntity { + + private MqttServerService mqttServerService; + + public MqttServerModel(MqttServerEntity entity, MqttServerService mqttServerService) { + this(mqttServerService); + if (entity != null) { + BeanUtil.copyProperties(entity, this); + } + } + + public MqttServerModel(MqttServerService mqttServerService) { + this.mqttServerService = mqttServerService; + } + + public void loadAddCommand(AddMqttServerCommand command) { + if (command != null) { + BeanUtil.copyProperties(command, this, "mqttServerId"); + } + } + + public void loadUpdateCommand(UpdateMqttServerCommand command) { + if (command != null) { + loadAddCommand(command); + } + } +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/model/MqttServerModelFactory.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/model/MqttServerModelFactory.java new file mode 100644 index 0000000..ba92580 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/model/MqttServerModelFactory.java @@ -0,0 +1,27 @@ +package com.agileboot.domain.cabinet.mqtt.model; + +import com.agileboot.common.exception.ApiException; +import com.agileboot.common.exception.error.ErrorCode; +import com.agileboot.domain.cabinet.mqtt.db.MqttServerEntity; +import com.agileboot.domain.cabinet.mqtt.db.MqttServerService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class MqttServerModelFactory { + + private final MqttServerService mqttServerService; + + public MqttServerModel loadById(Long mqttServerId) { + MqttServerEntity entity = mqttServerService.getById(mqttServerId); + if (entity == null) { + throw new ApiException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, mqttServerId, "MQTT服务器配置"); + } + return new MqttServerModel(entity, mqttServerService); + } + + public MqttServerModel create() { + return new MqttServerModel(mqttServerService); + } +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/query/SearchMqttServerQuery.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/query/SearchMqttServerQuery.java new file mode 100644 index 0000000..4591362 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/mqtt/query/SearchMqttServerQuery.java @@ -0,0 +1,40 @@ +package com.agileboot.domain.cabinet.mqtt.query; + +import cn.hutool.core.util.StrUtil; +import com.agileboot.common.core.page.AbstractPageQuery; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import java.util.Date; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class SearchMqttServerQuery extends AbstractPageQuery { + + private Long mqttServerId; + private String serverUrl; + private String username; + private String password; + private String topicFilter; + private String publishTopic; + private Date startTime; + private Date endTime; + + @Override + public QueryWrapper addQueryCondition() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + + queryWrapper + .eq(mqttServerId != null, "mqtt_server_id", mqttServerId) + .like(StrUtil.isNotEmpty(serverUrl), "server_url", serverUrl) + .eq(StrUtil.isNotEmpty(username), "username", username) + .eq(StrUtil.isNotEmpty(password), "password", password) + .like(StrUtil.isNotEmpty(topicFilter), "topic_filter", topicFilter) + .like(StrUtil.isNotEmpty(publishTopic), "publish_topic", publishTopic) + .between(startTime != null && endTime != null, "create_time", startTime, endTime); + + this.timeRangeColumn = "create_time"; + + return queryWrapper; + } +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/db/SmartCabinetEntity.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/db/SmartCabinetEntity.java index 2e69236..d377821 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/db/SmartCabinetEntity.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/db/SmartCabinetEntity.java @@ -39,6 +39,10 @@ public class SmartCabinetEntity extends BaseEntity { @TableField("cabinet_type") private Integer cabinetType; + @ApiModelProperty("MQTT服务ID") + @TableField("mqtt_server_id") + private Long mqttServerId; + @ApiModelProperty("柜机模版编号") @TableField("template_no") private String templateNo; diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/dto/SmartCabinetDTO.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/dto/SmartCabinetDTO.java index 99a8014..2167733 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/dto/SmartCabinetDTO.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/dto/SmartCabinetDTO.java @@ -6,6 +6,8 @@ import com.agileboot.common.annotation.ExcelSheet; import com.agileboot.domain.common.cache.CacheCenter; import com.agileboot.domain.cabinet.smartCabinet.db.SmartCabinetEntity; import com.agileboot.domain.system.user.db.SysUserEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; @ExcelSheet(name = "智能柜信息表") @@ -32,6 +34,9 @@ public class SmartCabinetDTO { @ExcelColumn(name = "柜机类型(0主柜 1副柜)") private Integer cabinetType; + @ExcelColumn(name = "MQTT服务ID") + private Long mqttServerId; + @ExcelColumn(name = "柜机模版编号") private String templateNo; diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/query/SearchSmartCabinetQuery.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/query/SearchSmartCabinetQuery.java index 9c665bf..9c8f2b7 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/query/SearchSmartCabinetQuery.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/query/SearchSmartCabinetQuery.java @@ -16,6 +16,7 @@ public class SearchSmartCabinetQuery extends AbstractPageQuery { private String templateNo; private Date startTime; private Date endTime; + private Long mqttServerId; @Override public QueryWrapper addQueryCondition() { @@ -24,6 +25,7 @@ public class SearchSmartCabinetQuery extends AbstractPageQuery { queryWrapper .like(StrUtil.isNotEmpty(cabinetName), "cabinet_name", cabinetName) .eq(cabinetType != null, "cabinet_type", cabinetType) + .eq(mqttServerId!= null, "mqtt_server_id", mqttServerId) .eq(StrUtil.isNotEmpty(templateNo), "template_no", templateNo) .eq("deleted", false) .between(startTime != null && endTime != null, "create_time", startTime, endTime); diff --git a/agileboot-domain/src/main/resources/mapper/cabinet/MqttServerMapper.xml b/agileboot-domain/src/main/resources/mapper/cabinet/MqttServerMapper.xml new file mode 100644 index 0000000..662f7e5 --- /dev/null +++ b/agileboot-domain/src/main/resources/mapper/cabinet/MqttServerMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/agileboot-infrastructure/src/main/java/com/agileboot/infrastructure/mybatisplus/CodeGenerator.java b/agileboot-infrastructure/src/main/java/com/agileboot/infrastructure/mybatisplus/CodeGenerator.java index 16b5f1b..5db8105 100644 --- a/agileboot-infrastructure/src/main/java/com/agileboot/infrastructure/mybatisplus/CodeGenerator.java +++ b/agileboot-infrastructure/src/main/java/com/agileboot/infrastructure/mybatisplus/CodeGenerator.java @@ -61,7 +61,7 @@ public class CodeGenerator { //生成的类 放在orm子模块下的/target/generated-code目录底下 .module("/agileboot-orm/target/generated-code") .parentPackage("com.agileboot") - .tableName("payment_operation_log") + .tableName("mqtt_server") // 决定是否继承基类 .isExtendsFromBaseEntity(true) .build(); diff --git a/sql/20250508_mqtt_server.sql b/sql/20250508_mqtt_server.sql new file mode 100644 index 0000000..d6794f9 --- /dev/null +++ b/sql/20250508_mqtt_server.sql @@ -0,0 +1,21 @@ +DROP TABLE IF EXISTS `mqtt_server`; + +CREATE TABLE `mqtt_server` ( + `mqtt_server_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `server_url` VARCHAR(200) NOT NULL COMMENT 'MQTT服务器地址', + `username` VARCHAR(100) NOT NULL COMMENT '连接账号', + `password` VARCHAR(200) NOT NULL COMMENT '连接密码', + `topic_filter` VARCHAR(200) NOT NULL COMMENT '订阅主题过滤器', + `publish_topic` VARCHAR(200) NOT NULL COMMENT '发布主题', + `creator_id` BIGINT NULL DEFAULT 0 COMMENT '创建者ID', + `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater_id` BIGINT NULL DEFAULT 0 COMMENT '更新者ID', + `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '删除标志(0存在 1删除)', + PRIMARY KEY (`mqtt_server_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='MQTT服务配置表'; + + +ALTER TABLE `smart_cabinet` +ADD COLUMN `mqtt_server_id` BIGINT NULL COMMENT 'MQTT服务ID' +AFTER `cabinet_type`; \ No newline at end of file