diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenErpMaterialSaveDTO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenErpMaterialSaveDTO.java index 8c2f58b17..21fe8a32d 100644 --- a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenErpMaterialSaveDTO.java +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenErpMaterialSaveDTO.java @@ -41,4 +41,7 @@ public class CanteenErpMaterialSaveDTO { @Schema(description="采购价格") private Integer purchasePrice; + + @Schema(description="所属分类id") + private Long categoryId; } diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenErpMaterialEntity.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenErpMaterialEntity.java index 708868fd8..01170ef8d 100644 --- a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenErpMaterialEntity.java +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenErpMaterialEntity.java @@ -96,4 +96,8 @@ public class CanteenErpMaterialEntity extends Model { @Schema(description="采购价格") private Integer purchasePrice; + + @Schema(description="所属分类id") + private Long categoryId; + } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenErpCategorySimpleVo.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenErpCategorySimpleVo.java new file mode 100644 index 000000000..479d615f6 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenErpCategorySimpleVo.java @@ -0,0 +1,17 @@ +package com.bsd.pjcloud.canteen.vo.erp; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class CanteenErpCategorySimpleVo { + + + @Schema(description = "分类id") + private Long id; + + + @Schema(description = "分类名称") + private String name; +} diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenErpMaterialVO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenErpMaterialVO.java index 62e60afec..983e28509 100644 --- a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenErpMaterialVO.java +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenErpMaterialVO.java @@ -47,4 +47,7 @@ public class CanteenErpMaterialVO { @Schema(description="采购价格") private Integer purchasePrice; + + @Schema(description="所属分类id") + private Long categoryId; } diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenErpCategoryController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenErpCategoryController.java new file mode 100644 index 000000000..4fabf6050 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenErpCategoryController.java @@ -0,0 +1,141 @@ +package com.bsd.pjcloud.canteen.controller; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsd.pjcloud.canteen.entity.CanteenCategoryEntity; +import com.bsd.pjcloud.canteen.vo.erp.CanteenErpCategorySimpleVo; +import com.bsd.pjcloud.common.core.util.BeanUtils; +import com.bsd.pjcloud.common.core.util.R; +import com.bsd.pjcloud.common.log.annotation.SysLog; +import com.bsd.pjcloud.canteen.entity.CanteenErpCategoryEntity; +import com.bsd.pjcloud.canteen.service.CanteenErpCategoryService; +import com.bsd.pjcloud.common.security.util.SecurityUtils; +import org.springframework.security.access.prepost.PreAuthorize; +import com.bsd.pjcloud.common.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.http.HttpHeaders; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Objects; + +/** + * 食材分类 + * + * @author zjf + * @date 2025-05-28 11:12:41 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/canteenErpCategory" ) +@Tag(description = "canteenErpCategory" , name = "食材分类管理" ) +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class CanteenErpCategoryController { + + private final CanteenErpCategoryService canteenErpCategoryService; + + /** + * 分页查询 + * @param page 分页对象 + * @param canteenErpCategory 食材分类 + * @return + */ + @Operation(summary = "分页查询" , description = "分页查询" ) + @GetMapping("/page" ) + @PreAuthorize("@pms.hasPermission('canteen_canteenErpCategory_view')" ) + public R getCanteenErpCategoryPage(@ParameterObject Page page, @ParameterObject CanteenErpCategoryEntity canteenErpCategory) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(StrUtil.isNotBlank(canteenErpCategory.getName()),CanteenErpCategoryEntity::getName,canteenErpCategory.getName()); + return R.ok(canteenErpCategoryService.pageScope(page, wrapper)); + } + + + /** + * 通过id查询食材分类 + * @param id id + * @return R + */ + @Operation(summary = "通过id查询" , description = "通过id查询" ) + @GetMapping("/{id}" ) + @PreAuthorize("@pms.hasPermission('canteen_canteenErpCategory_view')" ) + public R getById(@PathVariable("id" ) Long id) { + return R.ok(canteenErpCategoryService.getById(id)); + } + + /** + * 新增食材分类 + * @param canteenErpCategory 食材分类 + * @return R + */ + @Operation(summary = "新增食材分类" , description = "新增食材分类" ) + @SysLog("新增食材分类" ) + @PostMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenErpCategory_add')" ) + public R save(@RequestBody CanteenErpCategoryEntity canteenErpCategory) { + canteenErpCategory.setDeptId(SecurityUtils.getUser().getDeptId()); + return R.ok(canteenErpCategoryService.save(canteenErpCategory)); + } + + /** + * 修改食材分类 + * @param canteenErpCategory 食材分类 + * @return R + */ + @Operation(summary = "修改食材分类" , description = "修改食材分类" ) + @SysLog("修改食材分类" ) + @PutMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenErpCategory_edit')" ) + public R updateById(@RequestBody CanteenErpCategoryEntity canteenErpCategory) { + return R.ok(canteenErpCategoryService.updateById(canteenErpCategory)); + } + + /** + * 通过id删除食材分类 + * @param ids id列表 + * @return R + */ + @Operation(summary = "通过id删除食材分类" , description = "通过id删除食材分类" ) + @SysLog("通过id删除食材分类" ) + @DeleteMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenErpCategory_del')" ) + public R removeById(@RequestBody Long[] ids) { + return R.ok(canteenErpCategoryService.removeBatchByIds(CollUtil.toList(ids))); + } + + + /** + * 导出excel 表格 + * @param canteenErpCategory 查询条件 + * @param ids 导出指定ID + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('canteen_canteenErpCategory_export')" ) + public List export(CanteenErpCategoryEntity canteenErpCategory,Long[] ids) { + return canteenErpCategoryService.list(Wrappers.lambdaQuery(canteenErpCategory).in(ArrayUtil.isNotEmpty(ids), CanteenErpCategoryEntity::getId, ids)); + } + + + + /** + * 获取所有分类 + * @return + */ + @Operation(summary = "下拉查询") + @GetMapping("/simpleAll") + public R getSimpleAll(@RequestParam(value = "id",required = false)Long categoryId) { + List list = canteenErpCategoryService.listScope(categoryId); + List bean = BeanUtils.toBean(list, CanteenErpCategorySimpleVo.class); + return R.ok(bean); + } + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenErpCategoryEntity.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenErpCategoryEntity.java new file mode 100644 index 000000000..2f57ab6c5 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenErpCategoryEntity.java @@ -0,0 +1,115 @@ +package com.bsd.pjcloud.canteen.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import com.bsd.pjcloud.common.core.util.TenantTable; +import java.time.LocalDateTime; + +/** + * 食材分类 + * + * @author zjf + * @date 2025-05-28 11:12:41 + */ +@Data +@TenantTable +@TableName("canteen_erp_category") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "食材分类") +public class CanteenErpCategoryEntity extends Model { + + + /** + * 分类编号 + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description="分类编号") + private Long id; + + /** + * 父分类编号 + */ + @Schema(description="父分类编号") + private Long parentId; + + /** + * 分类名称 + */ + @Schema(description="分类名称") + private String name; + + /** + * 分类图 + */ + @Schema(description="分类图") + private String picUrl; + + /** + * 分类排序 + */ + @Schema(description="分类排序") + private Integer sort; + + /** + * 开启状态 + */ + @Schema(description="开启状态") + private String status; + + /** + * 部门id + */ + @Schema(description="部门id") + private Long deptId; + + /** + * merchantId + */ + @Schema(description="merchantId") + private Long merchantId; + + /** + * 创建者 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description="创建者") + private String createBy; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description="创建时间") + private LocalDateTime createTime; + + /** + * 更新者 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description="更新者") + private String updateBy; + + /** + * 更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description="更新时间") + private LocalDateTime updateTime; + + /** + * 是否删除 + */ + @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description="是否删除") + private String delFlag; + + /** + * 租户编号 + */ + @Schema(description="租户编号") + private Long tenantId; +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenErpCategoryMapper.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenErpCategoryMapper.java new file mode 100644 index 000000000..2e5593e89 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenErpCategoryMapper.java @@ -0,0 +1,11 @@ +package com.bsd.pjcloud.canteen.mapper; + +import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; +import com.bsd.pjcloud.canteen.entity.CanteenErpCategoryEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CanteenErpCategoryMapper extends PjcloudBaseMapper { + + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenErpCategoryService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenErpCategoryService.java new file mode 100644 index 000000000..84d72b005 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenErpCategoryService.java @@ -0,0 +1,29 @@ +package com.bsd.pjcloud.canteen.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsd.pjcloud.canteen.entity.CanteenCategoryEntity; +import com.bsd.pjcloud.canteen.entity.CanteenErpCategoryEntity; + +import java.util.List; + +public interface CanteenErpCategoryService extends IService { + + + /** + * 分页查询 + * @param page + * @param wrapper + * @return + */ + Object pageScope(Page page, LambdaQueryWrapper wrapper); + + + /** + * 查询下拉分类 + * @param categoryId + * @return + */ + List listScope(Long categoryId); +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenErpCategoryServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenErpCategoryServiceImpl.java new file mode 100644 index 000000000..41fb984d6 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenErpCategoryServiceImpl.java @@ -0,0 +1,36 @@ +package com.bsd.pjcloud.canteen.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsd.pjcloud.canteen.entity.CanteenCategoryEntity; +import com.bsd.pjcloud.canteen.entity.CanteenErpCategoryEntity; +import com.bsd.pjcloud.canteen.mapper.CanteenErpCategoryMapper; +import com.bsd.pjcloud.canteen.service.CanteenErpCategoryService; +import com.bsd.pjcloud.common.data.datascope.DataScope; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 食材分类 + * + * @author zjf + * @date 2025-05-28 11:12:41 + */ +@Service +public class CanteenErpCategoryServiceImpl extends ServiceImpl implements CanteenErpCategoryService { + @Override + public Object pageScope(Page page, LambdaQueryWrapper wrapper) { + return baseMapper.selectPageByScope(page, wrapper, DataScope.of()); + } + + @Override + public List listScope(Long categoryId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (categoryId != null) { + wrapper.eq(CanteenErpCategoryEntity::getId, categoryId); + } + return baseMapper.selectListByScope(wrapper, DataScope.of()); + } +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenErpCategoryMapper.xml b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenErpCategoryMapper.xml new file mode 100644 index 000000000..7ac0fc16c --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenErpCategoryMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenErpMaterialMapper.xml b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenErpMaterialMapper.xml index 05660e129..8cd338bd6 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenErpMaterialMapper.xml +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenErpMaterialMapper.xml @@ -15,6 +15,7 @@ +