|
@@ -263,33 +263,33 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, GoodsEntity> impl
|
|
|
@Override
|
|
|
public Result sort(GoodsSortDto param) {
|
|
|
Long id = param.getId();
|
|
|
- GoodsEntity entity = this.getById(id);
|
|
|
- String orderBy = param.getOrderBy();
|
|
|
+ Integer sort = param.getSort();
|
|
|
+ Integer sortOld = param.getSortOld();
|
|
|
+ String type = param.getType();
|
|
|
+
|
|
|
// id降序, 区间升
|
|
|
- if ("desc".equals(orderBy)){
|
|
|
- ascSort(id, param.getSort(), entity.getSort(), entity.getType());
|
|
|
+ if (sort < sortOld){
|
|
|
+ log.info("走升序");
|
|
|
+ entityMapper.ascSort(sort, sortOld, type);
|
|
|
} else { // id升序, 区间降
|
|
|
- descSort(id, param.getSort(), entity.getSort(), entity.getType());
|
|
|
+ log.info("走将序");
|
|
|
+ entityMapper.descSort(sort, sortOld, type);
|
|
|
}
|
|
|
+ entityMapper.updateSortById(id, sort);
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
- * @param id 对象id
|
|
|
* @param sort 新排序序号
|
|
|
* @param oldSort 旧序号
|
|
|
*/
|
|
|
- private void descSort(Long id, Integer sort, Integer oldSort, String type){
|
|
|
+ private void descSort(Integer sort, Integer oldSort, String type){
|
|
|
entityMapper.descSort(sort, oldSort, type);
|
|
|
- entityMapper.updateSortById(id, sort);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- private void ascSort(Long id, Integer sort, Integer oldSort, String type){
|
|
|
+ private void ascSort(Integer sort, Integer oldSort, String type){
|
|
|
entityMapper.ascSort(sort, oldSort, type);
|
|
|
- entityMapper.updateSortById(id, sort);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// 更新封面图
|