添加超市分类
This commit is contained in:
1 parent
1e11b774f0
commit
e304f70a1e
6 files changed
+286
No files matched your search
+121
@@ -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<SupermarketCategoryEntity> 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<SupermarketCategoryEntity> export(SupermarketCategoryEntity supermarketCategory,Long[] ids) {
|
||||
return supermarketCategoryService.list(Wrappers.lambdaQuery(supermarketCategory).in(ArrayUtil.isNotEmpty(ids), SupermarketCategoryEntity::getId, ids));
|
||||
}
|
||||
}
|
||||
+109
@@ -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<SupermarketCategoryEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 分类编号
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
+11
@@ -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<SupermarketCategoryEntity> {
|
||||
|
||||
|
||||
}
|
||||
+8
@@ -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<SupermarketCategoryEntity> {
|
||||
|
||||
}
|
||||
+16
@@ -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<SupermarketCategoryMapper, SupermarketCategoryEntity> implements SupermarketCategoryService {
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bsd.pjcloud.supermarket.mapper.SupermarketCategoryMapper">
|
||||
|
||||
<resultMap id="supermarketCategoryMap" type="com.bsd.pjcloud.supermarket.entity.SupermarketCategoryEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="parentId" column="parent_id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="picUrl" column="pic_url"/>
|
||||
<result property="sort" column="sort"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="deptId" column="dept_id"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user