提交 b4b57917 作者: 张小凤

CateGory(update)

上级 e8e25d6e
...@@ -83,15 +83,15 @@ public class CategoryController { ...@@ -83,15 +83,15 @@ public class CategoryController {
@ApiOperation(value = "二级分类————删除") @ApiOperation(value = "二级分类————删除")
@GetMapping("/deleteSubCategory") @GetMapping("/deleteSubCategory")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody deleteSubCategory(HttpServletRequest request, @RequestParam(value = "id", required = true) Integer id) { public ResultBody deleteSubCategory(HttpServletRequest request, @RequestParam(value = "subId", required = true) Integer subId) {
return categoryService.deleteSubCategory(id); return categoryService.deleteSubCategory(subId);
} }
@ApiOperation(value = "二级分类————详情") @ApiOperation(value = "二级分类————详情")
@GetMapping("/detailSubCategory") @GetMapping("/detailSubCategory")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody<CategorySubDTO> detailSubCategory(HttpServletRequest request, @RequestParam(value = "id", required = true) Integer id) { public ResultBody<CategorySubDTO> detailSubCategory(HttpServletRequest request, @RequestParam(value = "subId", required = true) Integer subId) {
return categoryService.detailSubCategory(id); return categoryService.detailSubCategory(subId);
} }
......
...@@ -34,9 +34,9 @@ public interface CategoryDao { ...@@ -34,9 +34,9 @@ public interface CategoryDao {
void updateSubCategory(CategorySubDO subDO); void updateSubCategory(CategorySubDO subDO);
void deleteSubCategory(Integer id); void deleteSubCategory(Integer subId);
CategorySubDO detailSubCategory(Integer id); CategorySubDO detailSubCategory(Integer subId);
List<CategoryPrimaryDO> categoryList(CategoryQO param); List<CategoryPrimaryDO> categoryList(CategoryQO param);
......
...@@ -33,7 +33,8 @@ public class CategorySubDO { ...@@ -33,7 +33,8 @@ public class CategorySubDO {
@NotNull(message = "id不能为空", groups = {Update.class}) @NotNull(message = "id不能为空", groups = {Update.class})
@Min(value = 1, groups = {Update.class}) @Min(value = 1, groups = {Update.class})
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Integer id; private Integer subId;
@ApiModelProperty(value = "分类名称", required = true, example = "无人机") @ApiModelProperty(value = "分类名称", required = true, example = "无人机")
@Size(max = 15, message = "分类名称不能超过15个字", groups = {Update.class, Create.class}) @Size(max = 15, message = "分类名称不能超过15个字", groups = {Update.class, Create.class})
...@@ -58,7 +59,7 @@ public class CategorySubDO { ...@@ -58,7 +59,7 @@ public class CategorySubDO {
private Date updateTime; private Date updateTime;
public CategorySubDO(CategorySubVO subVO) { public CategorySubDO(CategorySubVO subVO) {
this.id = subVO.getId(); this.subId = subVO.getSubId();
this.name = subVO.getName(); this.name = subVO.getName();
this.description = subVO.getDescription(); this.description = subVO.getDescription();
this.categoryPrimaryId = subVO.getCategoryPrimaryId(); this.categoryPrimaryId = subVO.getCategoryPrimaryId();
...@@ -66,7 +67,7 @@ public class CategorySubDO { ...@@ -66,7 +67,7 @@ public class CategorySubDO {
public CategorySubDTO buildCategorySubDTO() { public CategorySubDTO buildCategorySubDTO() {
return CategorySubDTO.builder() return CategorySubDTO.builder()
.id(this.id) .subId(this.subId)
.name(this.name) .name(this.name)
.description(this.description) .description(this.description)
.categoryPrimaryId(this.categoryPrimaryId) .categoryPrimaryId(this.categoryPrimaryId)
......
...@@ -29,9 +29,9 @@ public class CategorySubDTO { ...@@ -29,9 +29,9 @@ public class CategorySubDTO {
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
@NotNull(message = "id不能为空", groups = {Update.class}) @NotNull(message = "id不能为空", groups = {Update.class})
@Min(value = 1, groups = {Update.class}) @Min(value = 1, groups = {Update.class})
private Integer id; private Integer subId;
@ApiModelProperty(value = "分类名称", required = true,example = "无人机") @ApiModelProperty(value = "分类名称", required = true, example = "无人机")
@Size(max = 15, message = "分类名称不能超过15个字", groups = {Update.class, Create.class}) @Size(max = 15, message = "分类名称不能超过15个字", groups = {Update.class, Create.class})
@NotBlank(message = "分类名称不能为空或空字符", groups = {Update.class, Create.class}) @NotBlank(message = "分类名称不能为空或空字符", groups = {Update.class, Create.class})
private String name; private String name;
...@@ -40,7 +40,7 @@ public class CategorySubDTO { ...@@ -40,7 +40,7 @@ public class CategorySubDTO {
@Size(max = 70, message = "分类描述不能超过70个字", groups = {Update.class, Create.class}) @Size(max = 70, message = "分类描述不能超过70个字", groups = {Update.class, Create.class})
private String description; private String description;
@ApiModelProperty(value = "一级id不能为空",required = true,example = "1") @ApiModelProperty(value = "一级id不能为空", required = true, example = "1")
@NotNull(message = "一级id不能为空", groups = {Update.class, Create.class}) @NotNull(message = "一级id不能为空", groups = {Update.class, Create.class})
private Integer categoryPrimaryId; private Integer categoryPrimaryId;
......
...@@ -21,7 +21,7 @@ public class CategorySubVO { ...@@ -21,7 +21,7 @@ public class CategorySubVO {
@ApiModelProperty(value = "id", example = "1") @ApiModelProperty(value = "id", example = "1")
@NotNull(message = "id不能为空", groups = {Update.class}) @NotNull(message = "id不能为空", groups = {Update.class})
@Min(value = 1, groups = {Update.class}) @Min(value = 1, groups = {Update.class})
private Integer id; private Integer subId;
@ApiModelProperty(value = "分类名称", required = true, example = "无人机") @ApiModelProperty(value = "分类名称", required = true, example = "无人机")
@Size(max = 15, message = "分类名称不能超过15个字", groups = {Update.class, Create.class}) @Size(max = 15, message = "分类名称不能超过15个字", groups = {Update.class, Create.class})
......
...@@ -24,9 +24,9 @@ public interface CategoryService { ...@@ -24,9 +24,9 @@ public interface CategoryService {
ResultBody updateSubCategory(CategorySubVO subVO); ResultBody updateSubCategory(CategorySubVO subVO);
ResultBody deleteSubCategory(Integer id); ResultBody deleteSubCategory(Integer subId);
ResultBody detailSubCategory(Integer id); ResultBody detailSubCategory(Integer subId);
PageResult<CategoryPrimaryDTO> categoryList(CategoryQO param); PageResult<CategoryPrimaryDTO> categoryList(CategoryQO param);
} }
...@@ -84,15 +84,18 @@ public class CategoryServiceImpl implements CategoryService { ...@@ -84,15 +84,18 @@ public class CategoryServiceImpl implements CategoryService {
} }
@Override @Override
public ResultBody deleteSubCategory(Integer id) { public ResultBody deleteSubCategory(Integer subId) {
categoryDao.deleteSubCategory(id); categoryDao.deleteSubCategory(subId);
return ResultBody.success(); return ResultBody.success();
} }
@Override @Override
public ResultBody<CategorySubDTO> detailSubCategory(Integer id) { public ResultBody<CategorySubDTO> detailSubCategory(Integer subId) {
CategorySubDO subDO = categoryDao.detailSubCategory(id); CategorySubDO subDO = categoryDao.detailSubCategory(subId);
CategorySubDTO categorySubDTO = subDO.buildCategorySubDTO(); CategorySubDTO categorySubDTO = null;
if (subDO != null) {
categorySubDTO = subDO.buildCategorySubDTO();
}
return ResultBody.success(categorySubDTO); return ResultBody.success(categorySubDTO);
} }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</resultMap> </resultMap>
<select id="selectSubList" resultType="com.mmc.pms.entity.category.CategorySubDO"> <select id="selectSubList" resultType="com.mmc.pms.entity.category.CategorySubDO">
select id, select id AS subId,
`name`, `name`,
description, description,
category_primary_id AS categoryPrimaryId, category_primary_id AS categoryPrimaryId,
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
<insert id="addSubCategory" useGeneratedKeys="true" <insert id="addSubCategory" useGeneratedKeys="true"
keyProperty="id" parameterType="com.mmc.pms.entity.category.CategorySubDO"> keyProperty="subId" parameterType="com.mmc.pms.entity.category.CategorySubDO">
insert into category_sub(`name`, description, create_time, update_time, category_primary_id) insert into category_sub(`name`, description, create_time, update_time, category_primary_id)
values (#{name}, #{description}, NOW(), NOW(), #{categoryPrimaryId}) values (#{name}, #{description}, NOW(), NOW(), #{categoryPrimaryId})
</insert> </insert>
...@@ -126,8 +126,8 @@ ...@@ -126,8 +126,8 @@
<if test=" name != null and name != '' "> <if test=" name != null and name != '' ">
and `name` = #{name} and `name` = #{name}
</if> </if>
<if test=" id != null and id != '' "> <if test=" subId != null and subId != '' ">
and id != #{id} and id != #{subId}
</if> </if>
<if test=" categoryPrimaryId != null and categoryPrimaryId != '' "> <if test=" categoryPrimaryId != null and categoryPrimaryId != '' ">
and category_primary_id != #{categoryPrimaryId} and category_primary_id != #{categoryPrimaryId}
...@@ -147,25 +147,25 @@ ...@@ -147,25 +147,25 @@
</if> </if>
update_time=NOW() update_time=NOW()
</set> </set>
where id = #{id} where id = #{subId}
</update> </update>
<delete id="deleteSubCategory"> <delete id="deleteSubCategory">
delete delete
from category_sub from category_sub
where id = #{id} where id = #{subId}
</delete> </delete>
<select id="detailSubCategory" resultType="com.mmc.pms.entity.category.CategorySubDO"> <select id="detailSubCategory" resultType="com.mmc.pms.entity.category.CategorySubDO">
select id, select id AS subId,
`name`, `name`,
description, description,
create_time AS createTime, create_time AS createTime,
update_time AS updateTime, update_time AS updateTime,
category_primary_id AS categoryPrimaryId category_primary_id AS categoryPrimaryId
from category_sub from category_sub
where id = #{id} where id = #{subId}
</select> </select>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论