feat(格口): 添加格口备注字段及相关功能

- 在数据库表cabinet_cell中添加remark字段
- 在DTO和实体类中添加remark属性
- 在SmartCabinetApplicationService中处理remark字段
- 新增格口编辑接口
- 添加ModeEnum枚举类定义柜机模式
- 在ShopController中默认查询所有模式
This commit is contained in:
dzq 2025-12-31 17:40:58 +08:00
parent 268e690278
commit bac7a0b9e9
7 changed files with 88 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import com.agileboot.common.constant.WeixinConstants;
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.ModeEnum;
import com.agileboot.common.enums.common.BusinessTypeEnum;
import com.agileboot.domain.cabinet.cell.CabinetCellApplicationService;
import com.agileboot.domain.cabinet.smartCabinet.SmartCabinetApplicationService;
@ -27,7 +28,10 @@ import cn.hutool.core.date.DateUtil;
import io.swagger.v3.oas.annotations.Operation;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import javax.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
@ -104,6 +108,11 @@ public class ShopController extends BaseController {
@Operation(summary = "商店列表")
@GetMapping
public ResponseDTO<PageDTO<ShopDTO>> page(SearchShopQuery<ShopEntity> query) {
List<Integer> modeList = query.getModeList();
if (modeList == null || modeList.isEmpty()) {
modeList = ModeEnum.getCodeList();
query.setModeList(modeList);
}
PageDTO<ShopDTO> page = shopApplicationService.getShopPage(query);
return ResponseDTO.ok(page);
}
@ -111,6 +120,11 @@ public class ShopController extends BaseController {
@Operation(summary = "商店列表")
@GetMapping("/list")
public ResponseDTO<List<ShopDTO>> list(SearchShopQuery<ShopEntity> query) {
List<Integer> modeList = query.getModeList();
if (modeList == null || modeList.isEmpty()) {
modeList = ModeEnum.getCodeList();
query.setModeList(modeList);
}
List<ShopDTO> list = shopApplicationService.getShopList(query);
return ResponseDTO.ok(list);
}

View File

@ -9,6 +9,7 @@ import com.agileboot.common.exception.error.ErrorCode;
import com.agileboot.domain.cabinet.cell.CabinetCellApplicationService;
import com.agileboot.domain.cabinet.cell.command.OpenCellByPasswordCommand;
import com.agileboot.domain.cabinet.cell.command.StoreItemToCellCommand;
import com.agileboot.domain.cabinet.cell.command.UpdateCabinetCellCommand;
import com.agileboot.domain.cabinet.cell.dto.CabinetCellDTO;
import com.agileboot.domain.cabinet.cell.dto.AvailableStorageCellDTO;
import com.agileboot.domain.cabinet.cell.db.CabinetCellEntity;
@ -255,4 +256,22 @@ public class CabinetCellController {
return ResponseDTO.fail(new ApiException(ErrorCode.Internal.INTERNAL_ERROR, e));
}
}
@Operation(summary = "编辑格口信息")
@PutMapping("/cell")
public ResponseDTO<Void> updateCell(@RequestBody UpdateCabinetCellCommand command) {
if (command.getCellId() == null) {
throw new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "cellId不能为空");
}
try {
command.setUpdaterId(0L);
command.setUpdateTime(new Date());
cabinetCellApplicationService.updateCabinetCell(command);
return ResponseDTO.ok();
} catch (Exception e) {
log.error("编辑格口信息失败", e);
throw new ApiException(ErrorCode.Internal.INTERNAL_ERROR, e.getMessage());
}
}
}

View File

@ -0,0 +1,45 @@
package com.agileboot.common.enums;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public enum ModeEnum {
PAY_CABINET(0, "支付柜"),
APPROVAL_CABINET(1, "审批柜"),
BORROW_RETURN_CABINET(2, "借还柜"),
MEMBER_CABINET(3, "会员柜"),
CONSUMABLE_CABINET(4, "耗材柜"),
TEMPORARY_CABINET(5, "暂存柜");
private final int code;
private final String description;
ModeEnum(int code, String description) {
this.code = code;
this.description = description;
}
public int getCode() {
return code;
}
public String getDescription() {
return description;
}
public static ModeEnum fromCode(int code) {
for (ModeEnum mode : values()) {
if (mode.code == code) {
return mode;
}
}
return null;
}
public static List<Integer> getCodeList() {
return Arrays.stream(values())
.map(mode -> mode.code)
.collect(Collectors.toList());
}
}

View File

@ -67,6 +67,10 @@ public class CabinetCellEntity extends BaseEntity<CabinetCellEntity> {
@TableField("password_create_time")
private Date passwordCreateTime;
@ApiModelProperty("格口备注")
@TableField("remark")
private String remark;
@ApiModelProperty("是否已租用0-未租用1-已租用")
@TableField("is_rented")
private Integer isRented;

View File

@ -232,6 +232,7 @@ public class SmartCabinetApplicationService {
cellInfo.setPassword(cell.getPassword());
cellInfo.setUsageStatus(cell.getUsageStatus());
cellInfo.setCellType(cell.getCellType());
cellInfo.setRemark(cell.getRemark());
// 处理单元格关联的商品信息
if (cell.getGoodsId() != null) {

View File

@ -25,6 +25,7 @@ public class CabinetDetailDTO {
private String password;
private Integer usageStatus;
private Integer cellType;
private String remark;
}
@Data

View File

@ -4,4 +4,7 @@ AFTER `cell_price`;
ALTER TABLE `cabinet_cell`
ADD COLUMN `password_create_time` datetime DEFAULT NULL COMMENT '格口密码创建时间'
AFTER `password`;
AFTER `password`;
ALTER TABLE `cabinet_cell`
ADD COLUMN `remark` VARCHAR(1024) DEFAULT NULL COMMENT '格口备注';