Browse Source

品类管理

wwl 4 years ago
parent
commit
7abbbb867b

+ 96 - 0
zzjs-admin/src/main/java/com/miaxis/pc/controller/product/ProductTypeInfoController.java

@@ -0,0 +1,96 @@
+package com.miaxis.pc.controller.product;
+
+import com.miaxis.common.annotation.Log;
+import com.miaxis.common.core.controller.BaseController;
+import com.miaxis.common.core.domain.Response;
+import com.miaxis.common.core.page.ResponsePageInfo;
+import com.miaxis.common.enums.BusinessTypeEnum;
+import com.miaxis.product.domain.ProductTypeInfo;
+import com.miaxis.product.service.IProductTypeInfoService;
+import io.swagger.annotations.*;
+import lombok.RequiredArgsConstructor;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 【品类管理】Controller
+ *
+ * @author miaxis
+ * @date 2021-03-11
+ */
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/pc/product/info")
+@Api(tags={"【pc-品类管理】"})
+public class ProductTypeInfoController extends BaseController{
+
+    private final IProductTypeInfoService productTypeInfoService;
+
+    /**
+     * 查询品类列表
+     */
+    @PreAuthorize("@ss.hasPermi('product:info:list')")
+    @GetMapping("/list")
+    @ApiOperation("查询品类列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
+            @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
+    })
+    public ResponsePageInfo<ProductTypeInfo> list(@ModelAttribute ProductTypeInfo productTypeInfo){
+        startPage();
+        List<ProductTypeInfo> list = productTypeInfoService.selectProductTypeInfoList(productTypeInfo);
+        return toResponsePageInfo(list);
+    }
+
+
+    /**
+     * 获取品类详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('product:info:query')")
+    @GetMapping(value = "/{id}")
+    @ApiOperation("获取品类详细信息")
+    public Response<ProductTypeInfo> getInfo(
+            @ApiParam(name = "id", value = "品类参数", required = true)
+            @PathVariable("id") Long id
+    ){
+        return Response.success(productTypeInfoService.getById(id));
+    }
+
+    /**
+     * 新增品类
+     */
+    @PreAuthorize("@ss.hasPermi('product:info:add')")
+    @Log(title = "品类", businessType = BusinessTypeEnum.INSERT)
+    @PostMapping
+    @ApiOperation("新增品类")
+    public Response<Integer> add(@RequestBody ProductTypeInfo productTypeInfo){
+        return toResponse(productTypeInfoService.save(productTypeInfo) ? 1 : 0);
+    }
+
+    /**
+     * 修改品类
+     */
+    @PreAuthorize("@ss.hasPermi('product:info:edit')")
+    @Log(title = "品类", businessType = BusinessTypeEnum.UPDATE)
+    @PutMapping
+    @ApiOperation("修改品类")
+    public Response<Integer> edit(@RequestBody ProductTypeInfo productTypeInfo){
+        return toResponse(productTypeInfoService.updateById(productTypeInfo) ? 1 : 0);
+    }
+
+    /**
+     * 删除品类
+     */
+    @PreAuthorize("@ss.hasPermi('product:info:remove')")
+    @Log(title = "品类", businessType = BusinessTypeEnum.UPDATE)
+	@PutMapping("/{ids}")
+    @ApiOperation("删除品类")
+    public  Response<Integer> remove(
+            @ApiParam(name = "ids", value = "品类ids参数", required = true)
+            @PathVariable Long[] ids
+    ){
+        return productTypeInfoService.removeProductByIds(ids);
+    }
+}

+ 0 - 40
zzjs-service/src/main/java/com/miaxis/carousel/domain/CarouselChartInfo.java

@@ -45,44 +45,4 @@ public class CarouselChartInfo extends BaseBusinessEntity{
     @ApiModelProperty(value = "状态  0:有效(默认)、1:失效 (伪删除)")
     @ApiModelProperty(value = "状态  0:有效(默认)、1:失效 (伪删除)")
     private Integer status;
     private Integer status;
 
 
-    public void setId(Long id){
-        this.id = id;
-    }
-
-    public Long getId(){
-        return id;
-    }
-    public void setPictureName(String pictureName){
-        this.pictureName = pictureName;
-    }
-
-    public String getPictureName(){
-        return pictureName;
-    }
-    public void setFileId(Long fileId){
-        this.fileId = fileId;
-    }
-
-    public Long getFileId(){
-        return fileId;
-    }
-    public void setStatus(Integer status){
-        this.status = status;
-    }
-
-    public Integer getStatus(){
-        return status;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
-            .append("pictureName", getPictureName())
-            .append("fileId", getFileId())
-            .append("createTime", getCreateTime())
-            .append("updateTime", getUpdateTime())
-            .append("status", getStatus())
-            .toString();
-    }
 }
 }

+ 53 - 0
zzjs-service/src/main/java/com/miaxis/product/domain/ProductTypeInfo.java

@@ -0,0 +1,53 @@
+package com.miaxis.product.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.miaxis.common.annotation.Excel;
+import com.miaxis.common.core.domain.BaseBusinessEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+/**
+ * 品类对象 product_type_info
+ *
+ * @author miaxis
+ * @date 2021-03-11
+ */
+@Data
+@TableName("product_type_info")
+@ApiModel(value = "ProductTypeInfo", description = "品类对象 product_type_info")
+public class ProductTypeInfo extends BaseBusinessEntity{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键 */
+    @TableId(value = "id")
+    @ApiModelProperty(value = "主键")
+    private Long id;
+
+    /** 分类名称 */
+    @Excel(name = "分类名称")
+    @TableField("product_name")
+    @ApiModelProperty(value = "分类名称")
+    private String productName;
+
+    /** 父节点(预留) */
+    @Excel(name = "父节点(预留)", readConverterExp = "预=留")
+    @TableField("pid")
+    @ApiModelProperty(value = "父节点(预留)")
+    private Long pid;
+
+    /** 分类描述,该分类名称的描述 */
+    @Excel(name = "分类描述,该分类名称的描述")
+    @TableField("product_describe")
+    @ApiModelProperty(value = "分类描述,该分类名称的描述")
+    private String productDescribe;
+
+    /** 状态  0:有效(默认)、1:失效 (伪删除) */
+    @Excel(name = "状态  0:有效(默认)、1:失效 (伪删除)", readConverterExp = "伪=删除")
+    @TableField("status")
+    @ApiModelProperty(value = "状态  0:有效(默认)、1:失效 (伪删除)")
+    private Integer status;
+
+
+}

+ 22 - 0
zzjs-service/src/main/java/com/miaxis/product/mapper/ProductTypeInfoMapper.java

@@ -0,0 +1,22 @@
+package com.miaxis.product.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.miaxis.product.domain.ProductTypeInfo;
+
+/**
+ * 品类Mapper接口
+ *
+ * @author miaxis
+ * @date 2021-03-11
+ */
+public interface ProductTypeInfoMapper extends BaseMapper<ProductTypeInfo> {
+    /**
+     * 查询品类列表
+     *
+     * @param productTypeInfo 品类
+     * @return 品类集合
+     */
+    List<ProductTypeInfo> selectProductTypeInfoList(ProductTypeInfo productTypeInfo);
+
+}

+ 30 - 0
zzjs-service/src/main/java/com/miaxis/product/service/IProductTypeInfoService.java

@@ -0,0 +1,30 @@
+package com.miaxis.product.service;
+
+import java.util.List;
+
+import com.miaxis.common.core.domain.Response;
+import com.miaxis.product.domain.ProductTypeInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 品类Service接口
+ *
+ * @author miaxis
+ * @date 2021-03-11
+ */
+public interface IProductTypeInfoService extends IService<ProductTypeInfo>{
+    /**
+     * 查询品类列表
+     *
+     * @param productTypeInfo 品类
+     * @return 品类集合
+     */
+    List<ProductTypeInfo> selectProductTypeInfoList(ProductTypeInfo productTypeInfo);
+
+    /**
+     * 删除品类
+     * @param ids
+     * @return
+     */
+    Response<Integer> removeProductByIds(Long[] ids);
+}

+ 55 - 0
zzjs-service/src/main/java/com/miaxis/product/service/impl/ProductTypeInfoServiceImpl.java

@@ -0,0 +1,55 @@
+package com.miaxis.product.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.miaxis.common.core.domain.Response;
+import com.miaxis.product.domain.ProductTypeInfo;
+import com.miaxis.product.mapper.ProductTypeInfoMapper;
+import com.miaxis.product.service.IProductTypeInfoService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * 品类Service业务层处理
+ *
+ * @author miaxis
+ * @date 2021-03-11
+ */
+@Service
+@RequiredArgsConstructor
+public class ProductTypeInfoServiceImpl extends ServiceImpl<ProductTypeInfoMapper, ProductTypeInfo> implements IProductTypeInfoService {
+
+    private final ProductTypeInfoMapper productTypeInfoMapper;
+
+    /**
+     * 查询品类列表
+     *
+     * @param productTypeInfo 品类
+     * @return 品类
+     */
+    @Override
+    public List<ProductTypeInfo> selectProductTypeInfoList(ProductTypeInfo productTypeInfo){
+        return productTypeInfoMapper.selectProductTypeInfoList(productTypeInfo);
+    }
+
+    /**
+     * 删除品类
+     * @param ids
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Response<Integer> removeProductByIds(Long[] ids) {
+        try {
+            for (Long id : ids) {
+                this.update(new UpdateWrapper<ProductTypeInfo>().set("status",1).eq("id",id));
+            }
+            return Response.success();
+        }catch (Exception e){
+            throw new RuntimeException(e);
+        }
+    }
+}

+ 31 - 0
zzjs-service/src/main/resources/mapper/product/ProductTypeInfoMapper.xml

@@ -0,0 +1,31 @@
+<?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.miaxis.product.mapper.ProductTypeInfoMapper">
+
+    <resultMap type="ProductTypeInfo" id="ProductTypeInfoResult">
+        <result property="id"    column="id"    />
+        <result property="productName"    column="product_name"    />
+        <result property="pid"    column="pid"    />
+        <result property="productDescribe"    column="product_describe"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="status"    column="status"    />
+    </resultMap>
+
+    <sql id="selectProductTypeInfoVo">
+        select id, product_name, pid, product_describe, create_time, update_time, status from product_type_info
+    </sql>
+
+    <select id="selectProductTypeInfoList" parameterType="ProductTypeInfo" resultMap="ProductTypeInfoResult">
+        <include refid="selectProductTypeInfoVo"/>
+        <where>
+            <if test="productName != null  and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
+            <if test="pid != null "> and pid = #{pid}</if>
+            <if test="productDescribe != null  and productDescribe != ''"> and product_describe = #{describe}</if>
+            <if test="status != null "> and status = #{status}</if>
+        </where>
+    </select>
+
+</mapper>