提交 ff6a8008 作者: xiaowang

Merge remote-tracking branch 'origin/develop' into develop

......@@ -18,4 +18,4 @@ patches:
images:
- name: REGISTRY/NAMESPACE/IMAGE:TAG
newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/pms
newTag: b4b57917b9435ef94fcf7487cba52ce1a97b5770
newTag: 4f99e35b7546fd1584a7e275d54fbaf86d17ad45
......@@ -8,6 +8,7 @@ import com.mmc.pms.model.category.qo.CategoryQO;
import com.mmc.pms.model.category.vo.CategoryPrimaryVO;
import com.mmc.pms.model.category.vo.CategorySubVO;
import com.mmc.pms.model.group.Create;
import com.mmc.pms.model.group.Others;
import com.mmc.pms.model.group.Update;
import com.mmc.pms.service.category.CategoryService;
import io.swagger.annotations.*;
......@@ -16,6 +17,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @Author small
......@@ -94,5 +96,12 @@ public class CategoryController {
return categoryService.detailSubCategory(subId);
}
@ApiOperation(value = "一级分类——排序交换")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("exchange")
public ResultBody exchangeBannerInfo(@Validated(Others.class) @RequestBody List<CategoryPrimaryVO> list) {
return categoryService.exchange(list);
}
}
package com.mmc.pms.dao.category;
import com.mmc.pms.entity.ServiceDO;
import com.mmc.pms.entity.category.CategoryPrimaryDO;
import com.mmc.pms.entity.category.CategorySubDO;
import com.mmc.pms.model.category.qo.CategoryQO;
......@@ -46,4 +47,6 @@ public interface CategoryDao {
int categoryListCount(CategoryQO param);
void exchange(ServiceDO serviceDO);
}
......@@ -61,6 +61,9 @@ public class CategoryPrimaryDO {
private List<CategorySubDO> subDOList;
@ApiModelProperty(value = "顺序")
private Integer sort;
public CategoryPrimaryDO(CategoryPrimaryVO primaryVO) {
this.id = primaryVO.getId();
this.name = primaryVO.getName();
......@@ -77,6 +80,7 @@ public class CategoryPrimaryDO {
.createTime(this.createTime)
.updateTime(this.updateTime)
.subDTOList(this.subDOList)
.sort(this.sort)
.build();
}
......
......@@ -55,4 +55,8 @@ public class CategoryPrimaryDTO {
@ApiModelProperty(value = "二级分类")
private List<CategorySubDO> subDTOList;
@ApiModelProperty(value = "顺序")
private Integer sort;
}
package com.mmc.pms.model.category.vo;
import com.mmc.pms.model.group.Create;
import com.mmc.pms.model.group.Others;
import com.mmc.pms.model.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -19,7 +20,7 @@ import javax.validation.constraints.Size;
public class CategoryPrimaryVO {
@ApiModelProperty(value = "id", example = "1")
@NotNull(message = "id不能为空", groups = {Update.class})
@NotNull(message = "id不能为空", groups = {Update.class, Others.class})
@Min(value = 1, groups = {Update.class})
private Integer id;
......@@ -35,4 +36,8 @@ public class CategoryPrimaryVO {
@ApiModelProperty(value = "icon图标", example = "http://")
private String icon;
@ApiModelProperty(value = "顺序")
@NotNull(message = "sort不能为空", groups = {Others.class})
private Integer sort;
}
......@@ -7,6 +7,8 @@ import com.mmc.pms.model.category.vo.CategoryPrimaryVO;
import com.mmc.pms.model.category.vo.CategorySubVO;
import com.mmc.pms.page.PageResult;
import java.util.List;
/**
* @Author small
* @Date 2023/7/20 16:26
......@@ -29,4 +31,7 @@ public interface CategoryService {
ResultBody detailSubCategory(Integer subId);
PageResult<CategoryPrimaryDTO> categoryList(CategoryQO param);
ResultBody exchange(List<CategoryPrimaryVO> list);
}
......@@ -3,6 +3,7 @@ package com.mmc.pms.service.category.impl;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.common.ResultEnum;
import com.mmc.pms.dao.category.CategoryDao;
import com.mmc.pms.entity.ServiceDO;
import com.mmc.pms.entity.category.CategoryPrimaryDO;
import com.mmc.pms.entity.category.CategorySubDO;
import com.mmc.pms.model.category.dto.CategoryPrimaryDTO;
......@@ -14,6 +15,7 @@ import com.mmc.pms.page.PageResult;
import com.mmc.pms.service.category.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
......@@ -68,6 +70,7 @@ public class CategoryServiceImpl implements CategoryService {
return ResultBody.error(ResultEnum.THE_NAME_OF_THE_SECONDARY_CLASS_MUST_BE_UNIQUE);
}
CategorySubDO subDO = new CategorySubDO(subVO);
subDO.setSubId(subVO.getCategoryPrimaryId() + 1);
categoryDao.addSubCategory(subDO);
return ResultBody.success();
}
......@@ -110,4 +113,22 @@ public class CategoryServiceImpl implements CategoryService {
List<CategoryPrimaryDTO> collect = categoryPrimaryDOS.stream().map(t -> t.buildCategoryPrimaryDTO()).collect(Collectors.toList());
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count, collect);
}
@Transactional
@Override
public ResultBody exchange(List<CategoryPrimaryVO> list) {
Integer sort = list.get(0).getSort();
ServiceDO serviceDO = new ServiceDO();
serviceDO.setId(list.get(0).getId());
serviceDO.setSort(list.get(1).getSort());
categoryDao.exchange(serviceDO);
ServiceDO serviceDO1 = new ServiceDO();
serviceDO1.setId(list.get(1).getId());
serviceDO1.setSort(sort);
categoryDao.exchange(serviceDO1);
return ResultBody.success();
}
}
......@@ -47,6 +47,16 @@
</if>
</select>
<update id="exchange" parameterType="com.mmc.pms.entity.ServiceDO">
update category_primary
<set>
<if test=" sort != null ">
sort = #{sort}
</if>
</set>
where id = #{id}
</update>
<insert id="addPrimaryCategory" useGeneratedKeys="true"
keyProperty="id" parameterType="com.mmc.pms.entity.category.CategoryPrimaryDO">
......@@ -115,8 +125,8 @@
<insert id="addSubCategory" useGeneratedKeys="true"
keyProperty="subId" parameterType="com.mmc.pms.entity.category.CategorySubDO">
insert into category_sub(`name`, description, create_time, update_time, category_primary_id)
values (#{name}, #{description}, NOW(), NOW(), #{categoryPrimaryId})
insert into category_sub(id, `name`, description, create_time, update_time, category_primary_id)
values (#{subId}, #{name}, #{description}, NOW(), NOW(), #{categoryPrimaryId})
</insert>
<select id="categorySubCount" resultType="java.lang.Integer">
......@@ -170,12 +180,12 @@
<select id="categoryList" resultMap="CategoryList">
select id, `name`, description, create_time, update_time, icon
select id, `name`, description, create_time, update_time, icon,sort
from category_primary where 1=1
<if test=" id != null and id != '' ">
and id =#{id}
</if>
order by update_time desc, create_time desc
order by sort desc, update_time desc, create_time desc
limit #{pageNo},#{pageSize}
</select>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论