From fa900ef3f5ec3099256f5f07d2d164b3cc665ffc Mon Sep 17 00:00:00 2001 From: dzq Date: Fri, 9 May 2025 10:21:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=95=86=E5=BA=97=E6=A8=A1=E5=9D=97):=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E5=BA=97=E7=AE=A1=E7=90=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E5=8C=85=E6=8B=AC=E5=95=86=E5=BA=97=E7=9A=84?= =?UTF-8?q?=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5=E5=8F=8A=E4=B8=8E=E6=99=BA?= =?UTF-8?q?=E8=83=BD=E6=9F=9C=E7=9A=84=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 此次提交引入了完整的商店管理功能,包括商店的增删改查操作,以及商店与智能柜的关联。新增了ShopEntity、ShopService、ShopMapper等相关类,并实现了ShopController用于前端交互。同时,更新了智能柜模块,增加了商店ID字段,以支持商店与智能柜的关联管理。 --- .../admin/controller/shop/ShopController.java | 68 +++++++++++++++++++ .../smartCabinet/db/SmartCabinetEntity.java | 4 ++ .../smartCabinet/dto/SmartCabinetDTO.java | 3 + .../query/SearchSmartCabinetQuery.java | 2 + .../shop/shop/ShopApplicationService.java | 53 +++++++++++++++ .../shop/shop/command/AddShopCommand.java | 11 +++ .../shop/shop/command/UpdateShopCommand.java | 16 +++++ .../domain/shop/shop/db/ShopEntity.java | 44 ++++++++++++ .../domain/shop/shop/db/ShopMapper.java | 43 ++++++++++++ .../domain/shop/shop/db/ShopService.java | 15 ++++ .../domain/shop/shop/db/ShopServiceImpl.java | 17 +++++ .../domain/shop/shop/dto/ShopDTO.java | 27 ++++++++ .../domain/shop/shop/model/ShopModel.java | 39 +++++++++++ .../shop/shop/model/ShopModelFactory.java | 27 ++++++++ .../shop/shop/query/SearchShopQuery.java | 32 +++++++++ .../main/resources/mapper/shop/ShopMapper.xml | 5 ++ .../mybatisplus/CodeGenerator.java | 2 +- sql/20250508_mqtt_server.sql | 17 +++++ 18 files changed, 424 insertions(+), 1 deletion(-) create mode 100644 agileboot-admin/src/main/java/com/agileboot/admin/controller/shop/ShopController.java create mode 100644 agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/ShopApplicationService.java create mode 100644 agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/command/AddShopCommand.java create mode 100644 agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/command/UpdateShopCommand.java create mode 100644 agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopEntity.java create mode 100644 agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopMapper.java create mode 100644 agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopService.java create mode 100644 agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopServiceImpl.java create mode 100644 agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/dto/ShopDTO.java create mode 100644 agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/model/ShopModel.java create mode 100644 agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/model/ShopModelFactory.java create mode 100644 agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/query/SearchShopQuery.java create mode 100644 agileboot-domain/src/main/resources/mapper/shop/ShopMapper.xml diff --git a/agileboot-admin/src/main/java/com/agileboot/admin/controller/shop/ShopController.java b/agileboot-admin/src/main/java/com/agileboot/admin/controller/shop/ShopController.java new file mode 100644 index 0000000..736e02d --- /dev/null +++ b/agileboot-admin/src/main/java/com/agileboot/admin/controller/shop/ShopController.java @@ -0,0 +1,68 @@ +package com.agileboot.admin.controller.shop; + +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.common.command.BulkOperationCommand; +import com.agileboot.domain.shop.shop.ShopApplicationService; +import com.agileboot.domain.shop.shop.command.AddShopCommand; +import com.agileboot.domain.shop.shop.command.UpdateShopCommand; +import com.agileboot.domain.shop.shop.db.ShopEntity; +import com.agileboot.domain.shop.shop.dto.ShopDTO; +import com.agileboot.domain.shop.shop.query.SearchShopQuery; +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("/shop/shops") +@RequiredArgsConstructor +@Validated +public class ShopController extends BaseController { + + private final ShopApplicationService shopApplicationService; + + @Operation(summary = "商店列表") + @GetMapping + public ResponseDTO> list(SearchShopQuery query) { + PageDTO page = shopApplicationService.getShopList(query); + return ResponseDTO.ok(page); + } + + @Operation(summary = "新增商店") + @AccessLog(title = "商店管理", businessType = BusinessTypeEnum.ADD) + @PostMapping + public ResponseDTO add(@Validated @RequestBody AddShopCommand command) { + shopApplicationService.addShop(command); + return ResponseDTO.ok(); + } + + @Operation(summary = "修改商店") + @AccessLog(title = "商店管理", businessType = BusinessTypeEnum.MODIFY) + @PutMapping("/{id}") + public ResponseDTO edit(@PathVariable Long id, @Validated @RequestBody UpdateShopCommand command) { + command.setShopId(id); + shopApplicationService.updateShop(command); + return ResponseDTO.ok(); + } + + @Operation(summary = "删除商店") + @AccessLog(title = "商店管理", businessType = BusinessTypeEnum.DELETE) + @DeleteMapping("/{ids}") + public ResponseDTO remove(@PathVariable @NotNull List ids) { + shopApplicationService.deleteShop(new BulkOperationCommand<>(ids)); + return ResponseDTO.ok(); + } +} \ 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 d377821..2d89818 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 @@ -43,6 +43,10 @@ public class SmartCabinetEntity extends BaseEntity { @TableField("mqtt_server_id") private Long mqttServerId; + @ApiModelProperty("商店ID") + @TableField("shop_id") + private Long shopId; + @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 2167733..904158b 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 @@ -37,6 +37,9 @@ public class SmartCabinetDTO { @ExcelColumn(name = "MQTT服务ID") private Long mqttServerId; + @ExcelColumn(name = "商店ID") + private Long shopId; + @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 9c8f2b7..721080c 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 @@ -17,6 +17,7 @@ public class SearchSmartCabinetQuery extends AbstractPageQuery { private Date startTime; private Date endTime; private Long mqttServerId; + private Long shopId; @Override public QueryWrapper addQueryCondition() { @@ -26,6 +27,7 @@ public class SearchSmartCabinetQuery extends AbstractPageQuery { .like(StrUtil.isNotEmpty(cabinetName), "cabinet_name", cabinetName) .eq(cabinetType != null, "cabinet_type", cabinetType) .eq(mqttServerId!= null, "mqtt_server_id", mqttServerId) + .eq(shopId!= null, "shop_id", shopId) .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/java/com/agileboot/domain/shop/shop/ShopApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/ShopApplicationService.java new file mode 100644 index 0000000..640db99 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/ShopApplicationService.java @@ -0,0 +1,53 @@ +package com.agileboot.domain.shop.shop; + +import com.agileboot.common.core.page.PageDTO; +import com.agileboot.domain.common.command.BulkOperationCommand; +import com.agileboot.domain.shop.shop.command.AddShopCommand; +import com.agileboot.domain.shop.shop.command.UpdateShopCommand; +import com.agileboot.domain.shop.shop.db.ShopEntity; +import com.agileboot.domain.shop.shop.db.ShopService; +import com.agileboot.domain.shop.shop.dto.ShopDTO; +import com.agileboot.domain.shop.shop.model.ShopModel; +import com.agileboot.domain.shop.shop.model.ShopModelFactory; +import com.agileboot.domain.shop.shop.query.SearchShopQuery; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.util.List; +import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Service +@Slf4j +@RequiredArgsConstructor +public class ShopApplicationService { + private final ShopService shopService; + private final ShopModelFactory shopModelFactory; + + public PageDTO getShopList(SearchShopQuery query) { + Page page = shopService.page(query.toPage(), query.toQueryWrapper()); + List dtoList = page.getRecords().stream() + .map(ShopDTO::new) + .collect(Collectors.toList()); + return new PageDTO<>(dtoList, page.getTotal()); + } + + public void addShop(AddShopCommand command) { + ShopModel model = shopModelFactory.create(); + model.loadAddCommand(command); + model.insert(); + } + + public void updateShop(UpdateShopCommand command) { + ShopModel model = shopModelFactory.loadById(command.getShopId()); + model.loadUpdateCommand(command); + model.updateById(); + } + + public void deleteShop(BulkOperationCommand command) { + for (Long shopId : command.getIds()) { + ShopModel model = shopModelFactory.loadById(shopId); + model.deleteById(); + } + } +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/command/AddShopCommand.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/command/AddShopCommand.java new file mode 100644 index 0000000..b6fd17b --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/command/AddShopCommand.java @@ -0,0 +1,11 @@ +package com.agileboot.domain.shop.shop.command; + +import com.agileboot.domain.shop.shop.db.ShopEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class AddShopCommand extends ShopEntity { + +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/command/UpdateShopCommand.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/command/UpdateShopCommand.java new file mode 100644 index 0000000..e7a6479 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/command/UpdateShopCommand.java @@ -0,0 +1,16 @@ +package com.agileboot.domain.shop.shop.command; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.PositiveOrZero; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class UpdateShopCommand extends AddShopCommand { + + @NotNull + @PositiveOrZero + private Long shopId; + +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopEntity.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopEntity.java new file mode 100644 index 0000000..44e6352 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopEntity.java @@ -0,0 +1,44 @@ +package com.agileboot.domain.shop.shop.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; + +/** + *

+ * 商店表,每个柜子属于一个商店 + *

+ * + * @author valarchie + * @since 2025-05-09 + */ +@Getter +@Setter +@TableName("shop") +@ApiModel(value = "ShopEntity对象", description = "商店表,每个柜子属于一个商店") +public class ShopEntity extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键ID") + @TableId(value = "shop_id", type = IdType.AUTO) + private Long shopId; + + @ApiModelProperty("商店名称") + @TableField("shop_name") + private String shopName; + + + @Override + public Serializable pkVal() { + return this.shopId; + } + +} diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopMapper.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopMapper.java new file mode 100644 index 0000000..f6d2e8f --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopMapper.java @@ -0,0 +1,43 @@ +package com.agileboot.domain.shop.shop.db; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + *

+ * 商店表,每个柜子属于一个商店 Mapper 接口 + *

+ * + * @author valarchie + * @since 2025-05-09 + */ +public interface ShopMapper extends BaseMapper { + @Select("SELECT shop_id, shop_name " + + "FROM shop " + + "${ew.customSqlSegment}") + Page getShopList( + Page page, + @Param(Constants.WRAPPER) Wrapper queryWrapper + ); + + @Select("SELECT * " + + "FROM shop " + + "ORDER BY shop_id DESC " + + "LIMIT 1") + ShopEntity selectFirstShop(); + + @Select("SELECT * FROM shop ORDER BY shop_id DESC") + List selectAll(); + + @Select("SELECT * FROM shop WHERE shop_id = #{shopId} LIMIT 1") + ShopEntity selectByShopId(Long shopId); + + @Select("SELECT * FROM shop WHERE shop_name = #{shopName} LIMIT 1") + ShopEntity selectByShopName(String shopName); +} diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopService.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopService.java new file mode 100644 index 0000000..bc20fd6 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopService.java @@ -0,0 +1,15 @@ +package com.agileboot.domain.shop.shop.db; + +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 商店表,每个柜子属于一个商店 服务类 + *

+ * + * @author valarchie + * @since 2025-05-09 + */ +public interface ShopService extends IService { + +} diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopServiceImpl.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopServiceImpl.java new file mode 100644 index 0000000..78c42b9 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/db/ShopServiceImpl.java @@ -0,0 +1,17 @@ +package com.agileboot.domain.shop.shop.db; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 商店表,每个柜子属于一个商店 服务实现类 + *

+ * + * @author valarchie + * @since 2025-05-09 + */ +@Service +public class ShopServiceImpl extends ServiceImpl implements ShopService { + +} diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/dto/ShopDTO.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/dto/ShopDTO.java new file mode 100644 index 0000000..b404979 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/dto/ShopDTO.java @@ -0,0 +1,27 @@ +package com.agileboot.domain.shop.shop.dto; + +import cn.hutool.core.bean.BeanUtil; +import com.agileboot.common.annotation.ExcelColumn; +import com.agileboot.common.annotation.ExcelSheet; +import com.agileboot.domain.common.cache.CacheCenter; +import com.agileboot.domain.shop.shop.db.ShopEntity; +import com.agileboot.domain.system.user.db.SysUserEntity; +import lombok.Data; + +@ExcelSheet(name = "商店列表") +@Data +public class ShopDTO { + + public ShopDTO(ShopEntity entity) { + if (entity != null) { + BeanUtil.copyProperties(entity, this); + } + } + + @ExcelColumn(name = "商店ID") + private Long shopId; + + @ExcelColumn(name = "商店名称") + private String shopName; + +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/model/ShopModel.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/model/ShopModel.java new file mode 100644 index 0000000..79d8ca2 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/model/ShopModel.java @@ -0,0 +1,39 @@ +package com.agileboot.domain.shop.shop.model; + +import cn.hutool.core.bean.BeanUtil; +import com.agileboot.domain.shop.shop.command.AddShopCommand; +import com.agileboot.domain.shop.shop.command.UpdateShopCommand; +import com.agileboot.domain.shop.shop.db.ShopEntity; +import com.agileboot.domain.shop.shop.db.ShopService; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ShopModel extends ShopEntity { + + private ShopService shopService; + + public ShopModel(ShopEntity entity, ShopService shopService) { + this(shopService); + if (entity != null) { + BeanUtil.copyProperties(entity, this); + } + } + + public ShopModel(ShopService shopService) { + this.shopService = shopService; + } + + public void loadAddCommand(AddShopCommand command) { + if (command != null) { + BeanUtil.copyProperties(command, this, "id"); + } + } + + public void loadUpdateCommand(UpdateShopCommand command) { + if (command != null) { + loadAddCommand(command); + } + } +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/model/ShopModelFactory.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/model/ShopModelFactory.java new file mode 100644 index 0000000..a36c192 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/model/ShopModelFactory.java @@ -0,0 +1,27 @@ +package com.agileboot.domain.shop.shop.model; + +import com.agileboot.common.exception.ApiException; +import com.agileboot.common.exception.error.ErrorCode; +import com.agileboot.domain.shop.shop.db.ShopEntity; +import com.agileboot.domain.shop.shop.db.ShopService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class ShopModelFactory { + + private final ShopService shopService; + + public ShopModel loadById(Long shopId) { + ShopEntity entity = shopService.getById(shopId); + if (entity == null) { + throw new ApiException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, shopId, "店铺"); + } + return new ShopModel(entity, shopService); + } + + public ShopModel create() { + return new ShopModel(shopService); + } +} \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/query/SearchShopQuery.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/query/SearchShopQuery.java new file mode 100644 index 0000000..851440c --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/shop/query/SearchShopQuery.java @@ -0,0 +1,32 @@ +package com.agileboot.domain.shop.shop.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 SearchShopQuery extends AbstractPageQuery { + + private String shopName; + private String enable; + private Date startTime; + private Date endTime; + + @Override + public QueryWrapper addQueryCondition() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + + queryWrapper + .like(StrUtil.isNotEmpty(shopName), "shop_name", shopName) + .eq(StrUtil.isNotEmpty(enable), "enable", enable) + .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/resources/mapper/shop/ShopMapper.xml b/agileboot-domain/src/main/resources/mapper/shop/ShopMapper.xml new file mode 100644 index 0000000..6de26f2 --- /dev/null +++ b/agileboot-domain/src/main/resources/mapper/shop/ShopMapper.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 5db8105..0868ecd 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("mqtt_server") + .tableName("shop") // 决定是否继承基类 .isExtendsFromBaseEntity(true) .build(); diff --git a/sql/20250508_mqtt_server.sql b/sql/20250508_mqtt_server.sql index d6794f9..36f838b 100644 --- a/sql/20250508_mqtt_server.sql +++ b/sql/20250508_mqtt_server.sql @@ -18,4 +18,21 @@ CREATE TABLE `mqtt_server` ( ALTER TABLE `smart_cabinet` ADD COLUMN `mqtt_server_id` BIGINT NULL COMMENT 'MQTT服务ID' +AFTER `cabinet_type`; + +DROP TABLE IF EXISTS `shop`; + +CREATE TABLE `shop` ( + `shop_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `shop_name` VARCHAR(100) 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 (`shop_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商店表,每个柜子属于一个商店'; + +ALTER TABLE `smart_cabinet` +ADD COLUMN `shop_id` BIGINT NULL COMMENT '归属商店ID' AFTER `cabinet_type`; \ No newline at end of file