diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketCategoryController.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketCategoryController.java new file mode 100644 index 000000000..b47f4ac5d --- /dev/null +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketCategoryController.java @@ -0,0 +1,121 @@ +package com.bsd.pjcloud.supermarket.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.common.core.util.R; +import com.bsd.pjcloud.common.log.annotation.SysLog; +import com.bsd.pjcloud.supermarket.entity.SupermarketCategoryEntity; +import com.bsd.pjcloud.supermarket.service.SupermarketCategoryService; +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 2024-12-24 15:07:07 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/supermarketCategory" ) +@Tag(description = "supermarketCategory" , name = "商品分类管理" ) +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class SupermarketCategoryController { + + private final SupermarketCategoryService supermarketCategoryService; + + /** + * 分页查询 + * @param page 分页对象 + * @param supermarketCategory 商品分类 + * @return + */ + @Operation(summary = "分页查询" , description = "分页查询" ) + @GetMapping("/page" ) + @PreAuthorize("@pms.hasPermission('supermarket_supermarketCategory_view')" ) + public R getSupermarketCategoryPage(@ParameterObject Page page, @ParameterObject SupermarketCategoryEntity supermarketCategory) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.like(StrUtil.isNotBlank(supermarketCategory.getName()),SupermarketCategoryEntity::getName,supermarketCategory.getName()); + return R.ok(supermarketCategoryService.page(page, wrapper)); + } + + + /** + * 通过id查询商品分类 + * @param id id + * @return R + */ + @Operation(summary = "通过id查询" , description = "通过id查询" ) + @GetMapping("/{id}" ) + @PreAuthorize("@pms.hasPermission('supermarket_supermarketCategory_view')" ) + public R getById(@PathVariable("id" ) Long id) { + return R.ok(supermarketCategoryService.getById(id)); + } + + /** + * 新增商品分类 + * @param supermarketCategory 商品分类 + * @return R + */ + @Operation(summary = "新增商品分类" , description = "新增商品分类" ) + @SysLog("新增商品分类" ) + @PostMapping + @PreAuthorize("@pms.hasPermission('supermarket_supermarketCategory_add')" ) + public R save(@RequestBody SupermarketCategoryEntity supermarketCategory) { + return R.ok(supermarketCategoryService.save(supermarketCategory)); + } + + /** + * 修改商品分类 + * @param supermarketCategory 商品分类 + * @return R + */ + @Operation(summary = "修改商品分类" , description = "修改商品分类" ) + @SysLog("修改商品分类" ) + @PutMapping + @PreAuthorize("@pms.hasPermission('supermarket_supermarketCategory_edit')" ) + public R updateById(@RequestBody SupermarketCategoryEntity supermarketCategory) { + return R.ok(supermarketCategoryService.updateById(supermarketCategory)); + } + + /** + * 通过id删除商品分类 + * @param ids id列表 + * @return R + */ + @Operation(summary = "通过id删除商品分类" , description = "通过id删除商品分类" ) + @SysLog("通过id删除商品分类" ) + @DeleteMapping + @PreAuthorize("@pms.hasPermission('supermarket_supermarketCategory_del')" ) + public R removeById(@RequestBody Long[] ids) { + return R.ok(supermarketCategoryService.removeBatchByIds(CollUtil.toList(ids))); + } + + + /** + * 导出excel 表格 + * @param supermarketCategory 查询条件 + * @param ids 导出指定ID + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('supermarket_supermarketCategory_export')" ) + public List export(SupermarketCategoryEntity supermarketCategory,Long[] ids) { + return supermarketCategoryService.list(Wrappers.lambdaQuery(supermarketCategory).in(ArrayUtil.isNotEmpty(ids), SupermarketCategoryEntity::getId, ids)); + } +} \ No newline at end of file diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/entity/SupermarketCategoryEntity.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/entity/SupermarketCategoryEntity.java new file mode 100644 index 000000000..d72704920 --- /dev/null +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/entity/SupermarketCategoryEntity.java @@ -0,0 +1,109 @@ +package com.bsd.pjcloud.supermarket.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 2024-12-24 15:07:07 + */ +@Data +@TenantTable +@TableName("supermarket_category") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "商品分类") +public class SupermarketCategoryEntity 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; + + /** + * 创建者 + */ + @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-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/mapper/SupermarketCategoryMapper.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/mapper/SupermarketCategoryMapper.java new file mode 100644 index 000000000..f1710df9e --- /dev/null +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/mapper/SupermarketCategoryMapper.java @@ -0,0 +1,11 @@ +package com.bsd.pjcloud.supermarket.mapper; + +import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; +import com.bsd.pjcloud.supermarket.entity.SupermarketCategoryEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface SupermarketCategoryMapper extends PjcloudBaseMapper { + + +} \ No newline at end of file diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketCategoryService.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketCategoryService.java new file mode 100644 index 000000000..e4b45697e --- /dev/null +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketCategoryService.java @@ -0,0 +1,8 @@ +package com.bsd.pjcloud.supermarket.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsd.pjcloud.supermarket.entity.SupermarketCategoryEntity; + +public interface SupermarketCategoryService extends IService { + +} \ No newline at end of file diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SupermarketCategoryServiceImpl.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SupermarketCategoryServiceImpl.java new file mode 100644 index 000000000..3304d38e3 --- /dev/null +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SupermarketCategoryServiceImpl.java @@ -0,0 +1,16 @@ +package com.bsd.pjcloud.supermarket.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsd.pjcloud.supermarket.entity.SupermarketCategoryEntity; +import com.bsd.pjcloud.supermarket.mapper.SupermarketCategoryMapper; +import com.bsd.pjcloud.supermarket.service.SupermarketCategoryService; +import org.springframework.stereotype.Service; +/** + * 商品分类 + * + * @author zjf + * @date 2024-12-24 15:07:07 + */ +@Service +public class SupermarketCategoryServiceImpl extends ServiceImpl implements SupermarketCategoryService { +} \ No newline at end of file diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/resources/mapper/SupermarketCategoryMapper.xml b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/resources/mapper/SupermarketCategoryMapper.xml new file mode 100644 index 000000000..8ba7fdbd0 --- /dev/null +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/resources/mapper/SupermarketCategoryMapper.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file