Sfoglia il codice sorgente

fix:table_info对象的curd

huangjinliang 1 settimana fa
parent
commit
689812c88e

+ 5 - 0
fuintBackend/fuint-application/src/main/java/com/fuint/common/dto/ext/TableInfoDto.java

@@ -47,4 +47,9 @@ public class TableInfoDto implements Serializable {
     @ApiModelProperty(value = "状态(0-空闲 1-占用)", example = "0")
     private Integer tableStatus;
 
+//    @NotBlank(message = "分类名称不能为空")
+//    @Size(max = 50, message = "分类名称最长50个字符")
+    @ApiModelProperty(value = "分类名称")
+    private String categoryName;
+
 }

+ 12 - 6
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/TableInfoServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fuint.common.enums.StatusEnum;
 import com.fuint.common.service.TableInfoService;
+import com.fuint.common.util.AuthUserUtil;
 import com.fuint.common.util.I18nUtil;
 import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
@@ -38,7 +39,7 @@ public class TableInfoServiceImpl extends ServiceImpl<MtTableInfoMapper, MtTable
 
     private static final Logger logger = LoggerFactory.getLogger(TableInfoServiceImpl.class);
 
-    private MtTableInfoMapper mtTableInfoMapper;
+    private  MtTableInfoMapper mtTableInfoMapper;
 
     private MtTableCategoryMapper tableCategoryMapper;
 
@@ -194,15 +195,20 @@ public class TableInfoServiceImpl extends ServiceImpl<MtTableInfoMapper, MtTable
     @Transactional(rollbackFor = Exception.class)
     public boolean saveTable(MtTableInfo entity) throws BusinessCheckException {
         // 校验桌号唯一性
-        LambdaQueryWrapper<MtTableInfo> query = new LambdaQueryWrapper<>();
-        query.eq(MtTableInfo::getTableNumber, entity.getTableNumber())
-                .eq(MtTableInfo::getDeleteFlag, 0);
-        if (mtTableInfoMapper.exists(query)) {
+
+        Long storeId = AuthUserUtil.get().getStoreId();
+        if (storeId==null || storeId<0){
+            throw new BusinessCheckException("平台号无权限修改");
+        }
+        Integer count = this.baseMapper.selectCount(new LambdaQueryWrapper<MtTableInfo>()
+                .eq(MtTableInfo::getTableNumber, entity.getTableNumber())
+                .eq(MtTableInfo::getStoreId,storeId)
+                .eq(MtTableInfo::getDeleteFlag, 0));
+        if (count>0) {
             throw new BusinessCheckException("桌号已存在");
         }
 
         // 自动填充时间(兼容数据库自动填充)
-//        LocalDateTime now = LocalDateTime.now();
         if (entity.getCreateTime() == null) {
             entity.setCreateTime(new Date());
         }

+ 43 - 4
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendTableInfoController.java

@@ -215,7 +215,7 @@ public class BackendTableInfoController extends BaseController {
     @ApiOperation("新增餐桌信息接口")
     @PostMapping("/create")
     @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('table:create')")
+//    @PreAuthorize("@pms.hasPermission('table:create')")
     public ResponseObject createTable(
             HttpServletRequest request,
              @RequestBody TableInfoDto dto) throws BusinessCheckException {
@@ -282,7 +282,7 @@ public class BackendTableInfoController extends BaseController {
     @ApiOperation("逻辑删除餐桌")
     @DeleteMapping("/delete/{id}")
     @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('table:delete')")
+//    @PreAuthorize("@pms.hasPermission('table:delete')")
     public ResponseObject logicalDelete(
             HttpServletRequest request,
             @PathVariable Long id) throws BusinessCheckException {
@@ -316,10 +316,10 @@ public class BackendTableInfoController extends BaseController {
     private void verifyUpdateData(TableInfoDto dto, MtTableInfo existTable, AccountInfo account)
             throws BusinessCheckException {
 
-        // 校验分类有效性
+       /* // 校验分类有效性
         if (!categoryService.existCategory(dto.getCategoryId())) {
             throw new BusinessCheckException("关联分类不存在");
-        }
+        }*/
 
         // 校验桌号唯一性(排除自身)
         LambdaQueryWrapper<MtTableInfo> query = new LambdaQueryWrapper<>();
@@ -345,4 +345,43 @@ public class BackendTableInfoController extends BaseController {
         return entity;
     }
 
+
+    /**
+     * 新增餐桌信息接口(无关联分类表)
+     * @param request
+     * @param dto
+     * @return
+     * @throws BusinessCheckException
+     */
+    @ApiOperation("新增餐桌信息接口")
+    @PostMapping("/addTableInfo")
+    @CrossOrigin
+//    @PreAuthorize("@pms.hasPermission('table:create')")
+    public ResponseObject addTableInfo(
+            HttpServletRequest request,
+            @RequestBody TableInfoDto dto) throws BusinessCheckException {
+        // 身份验证
+        String token = request.getHeader("Access-Token");
+        AccountInfo account = TokenUtil.getAccountInfoByToken(token);
+        if (account == null) {
+            return getFailureResult(1001, I18nUtil.getMessage("notAuthenticated"));
+        }
+
+
+        // 构造实体
+        MtTableInfo entity = new MtTableInfo();
+        BeanUtils.copyProperties(dto, entity);
+        entity.setCreateUserId(account.getAccountName());
+        entity.setUpdateUserId(account.getAccountName());
+        entity.setTableStatus(0); // 默认空闲状态
+        entity.setDeleteFlag(0);
+
+        // 保存数据
+        boolean result = tableInfoService.saveTable(entity);
+        return result ? getSuccessResult(true) : getFailureResult(500, "保存失败");
+    }
+
+
+
+
 }

+ 9 - 1
fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtTableInfo.java

@@ -1,6 +1,7 @@
 package com.fuint.repository.model;
 
 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;
@@ -40,8 +41,10 @@ public class MtTableInfo implements Serializable {
     private Integer deleteFlag;
 
     @ApiModelProperty("餐桌ID,主键,自增")
-    @TableId(value = "ID", type = IdType.AUTO)
+    @TableId(value = "ID", type = IdType.ID_WORKER)
     private Long id;
+    @ApiModelProperty("店铺id")
+    private Long storeId;
 
     @ApiModelProperty("项目标识")
     private String project;
@@ -49,6 +52,11 @@ public class MtTableInfo implements Serializable {
     @ApiModelProperty("餐桌编号,如T001、T002等")
     private String tableNumber;
 
+
+    @ApiModelProperty("分类名称")
+    private String categoryName;
+
+
     @ApiModelProperty("餐桌状态,0空闲、1占用或2预订")
     private Integer tableStatus;