dev798
parent
566090ea36
commit
ed518ed484
|
@ -3,6 +3,7 @@ package com.muyu.product.controller;
|
||||||
import com.muyu.common.core.domain.AjaxResult;
|
import com.muyu.common.core.domain.AjaxResult;
|
||||||
import com.muyu.product.domain.DTO.Category;
|
import com.muyu.product.domain.DTO.Category;
|
||||||
import com.muyu.product.service.CategoryService;
|
import com.muyu.product.service.CategoryService;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -22,6 +23,7 @@ public class CategoryController {
|
||||||
private CategoryService categoryService;
|
private CategoryService categoryService;
|
||||||
|
|
||||||
@GetMapping("/queryCategory")
|
@GetMapping("/queryCategory")
|
||||||
|
@ApiOperation("类型列表")
|
||||||
public AjaxResult queryCategory(){
|
public AjaxResult queryCategory(){
|
||||||
List<Category>list=categoryService.queryCategory();
|
List<Category>list=categoryService.queryCategory();
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
|
@ -33,4 +35,18 @@ public class CategoryController {
|
||||||
Integer res = categoryService.deleteCategory(categoryId);
|
Integer res = categoryService.deleteCategory(categoryId);
|
||||||
return AjaxResult.success(res==1?"删除成功":"删除失败");
|
return AjaxResult.success(res==1?"删除成功":"删除失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@ApiOperation("分类添加")
|
||||||
|
public AjaxResult insertCategory(@RequestBody Category category){
|
||||||
|
Integer res = categoryService.insertCategory(category);
|
||||||
|
return AjaxResult.success(res==1?"添加成功":"添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
@ApiOperation("分类修改")
|
||||||
|
public AjaxResult updateCategory(@RequestBody Category category){
|
||||||
|
Integer res = categoryService.updateCategory(category);
|
||||||
|
return AjaxResult.success(res==1?"修改成功":"修改失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,8 @@ public interface CategoryMapper {
|
||||||
List<Category> queryCategory();
|
List<Category> queryCategory();
|
||||||
|
|
||||||
Integer deleteCategory(Integer categoryId);
|
Integer deleteCategory(Integer categoryId);
|
||||||
|
|
||||||
|
Integer insertCategory(Category category);
|
||||||
|
|
||||||
|
Integer updateCategory(Category category);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,4 +12,8 @@ public interface CategoryService {
|
||||||
List<Category> queryCategory();
|
List<Category> queryCategory();
|
||||||
|
|
||||||
Integer deleteCategory(Integer categoryId);
|
Integer deleteCategory(Integer categoryId);
|
||||||
|
|
||||||
|
Integer insertCategory(Category category);
|
||||||
|
|
||||||
|
Integer updateCategory(Category category);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.product.service.impl;
|
package com.muyu.product.service.impl;
|
||||||
|
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.product.domain.DTO.Category;
|
import com.muyu.product.domain.DTO.Category;
|
||||||
import com.muyu.product.mapper.CategoryMapper;
|
import com.muyu.product.mapper.CategoryMapper;
|
||||||
import com.muyu.product.service.CategoryService;
|
import com.muyu.product.service.CategoryService;
|
||||||
|
@ -26,4 +27,16 @@ public class CategoryServiceImpl implements CategoryService {
|
||||||
public Integer deleteCategory(Integer categoryId) {
|
public Integer deleteCategory(Integer categoryId) {
|
||||||
return categoryMapper.deleteCategory(categoryId);
|
return categoryMapper.deleteCategory(categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer insertCategory(Category category) {
|
||||||
|
category.setCategoryName(SecurityUtils.getUsername());
|
||||||
|
return categoryMapper.insertCategory(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer updateCategory(Category category) {
|
||||||
|
category.setCategoryName(SecurityUtils.getUsername());
|
||||||
|
return categoryMapper.updateCategory(category);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
,product_unit,nav_status,show_status,sort,icon,keywords,description
|
,product_unit,nav_status,show_status,sort,icon,keywords,description
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<insert id="insertCategory">
|
||||||
|
INSERT INTO `t_product_category` (
|
||||||
|
`parent_id`,
|
||||||
|
`category_name`,
|
||||||
|
`level`,
|
||||||
|
`product_count`,
|
||||||
|
`product_unit`,
|
||||||
|
`nav_status`,
|
||||||
|
`show_status`,
|
||||||
|
`sort`,
|
||||||
|
`icon`,
|
||||||
|
`keywords`,
|
||||||
|
`description`,
|
||||||
|
`create_time`,
|
||||||
|
`create_by`
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
#{parentId},
|
||||||
|
#{categoryName},
|
||||||
|
#{level},
|
||||||
|
#{productCount},
|
||||||
|
#{productUnit},
|
||||||
|
#{navStatus},
|
||||||
|
#{showStatus},
|
||||||
|
#{sort},
|
||||||
|
#{icon},
|
||||||
|
#{keywords},
|
||||||
|
#{description},
|
||||||
|
now(),
|
||||||
|
#{createBy}
|
||||||
|
);
|
||||||
|
</insert>
|
||||||
|
|
||||||
<update id="deleteCategory">
|
<update id="deleteCategory">
|
||||||
update t_product_category set id_delete = 0 where id = #{id}
|
update t_product_category set id_delete = 0 where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
<update id="updateCategory">
|
||||||
|
UPDATE `t_product_category`
|
||||||
|
SET `parent_id` = #{parentId},
|
||||||
|
`category_name` = #{categoryName},
|
||||||
|
`level` = #{level},
|
||||||
|
`product_count` = #{productCount},
|
||||||
|
`product_unit` = #{productUnit},
|
||||||
|
`nav_status` = #{navStatus},
|
||||||
|
`show_status` = #{showStatus},
|
||||||
|
`sort` = #{sort},
|
||||||
|
`icon` = #{icon},
|
||||||
|
`keywords` = #{keywords},
|
||||||
|
`description` = #{description},
|
||||||
|
`update_time` = now(),
|
||||||
|
`create_by` = #{createBy}
|
||||||
|
WHERE
|
||||||
|
`id` = #{id};
|
||||||
|
</update>
|
||||||
|
|
||||||
|
|
||||||
<select id="queryCategory" resultType="com.muyu.product.domain.DTO.Category">
|
<select id="queryCategory" resultType="com.muyu.product.domain.DTO.Category">
|
||||||
select <include refid="sqlCategory"></include> from t_product_category
|
select <include refid="sqlCategory"></include> from t_product_category
|
||||||
</select>
|
</select>
|
||||||
|
|
Loading…
Reference in New Issue