提交 be3b422c 作者: xiaowang

新增:排序

上级 40b7b899
...@@ -137,4 +137,12 @@ public class BackstageGoodsManageController extends BaseController { ...@@ -137,4 +137,12 @@ public class BackstageGoodsManageController extends BaseController {
@RequestBody MallOrderGoodsInfoQO mallOrderGoodsInfoQO) { @RequestBody MallOrderGoodsInfoQO mallOrderGoodsInfoQO) {
return goodsInfoService.feignListIndstGoodsSkuInfo(mallOrderGoodsInfoQO); return goodsInfoService.feignListIndstGoodsSkuInfo(mallOrderGoodsInfoQO);
} }
@ApiOperation(value = "商品列表-排序")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("exchangeGoodsInfo")
public ResultBody exchangeGoodsInfo(@ApiParam(value = "第一个参数id", required = true) @RequestParam(value = "firstId") Integer firstId,
@ApiParam(value = "第二个参数id", required = true) @RequestParam(value = "secondId") Integer secondId) {
return goodsInfoService.exchangeGoodsInfo(firstId, secondId);
}
} }
...@@ -112,4 +112,6 @@ public interface GoodsInfoDao { ...@@ -112,4 +112,6 @@ public interface GoodsInfoDao {
void updateMallProdSkuInfo(MallProdInfoDO mallProdInfoDO); void updateMallProdSkuInfo(MallProdInfoDO mallProdInfoDO);
List<MallProdInfoDO> getAllMallProSkuInfo(Integer goodsInfoId); List<MallProdInfoDO> getAllMallProSkuInfo(Integer goodsInfoId);
int updateGoodsInfoSort(Integer id, Integer sort);
} }
...@@ -46,4 +46,6 @@ public interface GoodsInfoService { ...@@ -46,4 +46,6 @@ public interface GoodsInfoService {
ResultBody batchOnShelfOrTakeDown(List<Integer> goodsIds, Integer status); ResultBody batchOnShelfOrTakeDown(List<Integer> goodsIds, Integer status);
ResultBody batchRemoveWareInfo(List<Integer> ids); ResultBody batchRemoveWareInfo(List<Integer> ids);
ResultBody exchangeGoodsInfo(Integer firstId, Integer secondId);
} }
...@@ -20,6 +20,7 @@ import com.mmc.pms.util.TDateUtil; ...@@ -20,6 +20,7 @@ import com.mmc.pms.util.TDateUtil;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
...@@ -1114,4 +1115,19 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -1114,4 +1115,19 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
goodsInfoDao.removeWareInfo(ids); goodsInfoDao.removeWareInfo(ids);
return ResultBody.success(); return ResultBody.success();
} }
@Override
@Transactional(rollbackFor = Exception.class)
public ResultBody exchangeGoodsInfo(Integer firstId, Integer secondId) {
GoodsInfo firstGoodsInfoDO = goodsInfoDao.getGoodsSimpleInfo(firstId);
GoodsInfo secondGoodsInfoDO = goodsInfoDao.getGoodsSimpleInfo(secondId);
int updateCount1 = goodsInfoDao.updateGoodsInfoSort(firstId, secondGoodsInfoDO.getSort());
int updateCount2 = goodsInfoDao.updateGoodsInfoSort(secondId, firstGoodsInfoDO.getSort());
if (updateCount1 == updateCount2) {
return ResultBody.success();
} else {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return ResultBody.error("排序失败");
}
}
} }
...@@ -165,6 +165,9 @@ ...@@ -165,6 +165,9 @@
is_must = #{must} is_must = #{must}
where id = #{id} where id = #{id}
</update> </update>
<update id="updateGoodsInfoSort">
update goods_info set sort = #{sort} where id = #{id}
</update>
<delete id="deleteGoodsServiceByGoodsId"> <delete id="deleteGoodsServiceByGoodsId">
delete delete
from goods_service from goods_service
...@@ -250,6 +253,7 @@ ...@@ -250,6 +253,7 @@
gi.category_by_two, gi.category_by_two,
gi.shelf_status, gi.shelf_status,
gi.create_time, gi.create_time,
gi.sort,
gv.id goodsVideoId, gv.id goodsVideoId,
gv.video_url videoUrl gv.video_url videoUrl
FROM goods_info gi FROM goods_info gi
...@@ -570,7 +574,7 @@ ...@@ -570,7 +574,7 @@
</if> </if>
</where> </where>
ORDER BY ORDER BY
gi.shelf_status DESC , gi.create_time asc gi.shelf_status DESC , gi.sort DESC
limit #{pageNo},#{pageSize} limit #{pageNo},#{pageSize}
</select> </select>
......
...@@ -200,7 +200,7 @@ ...@@ -200,7 +200,7 @@
and gi.goods_name like CONCAT('%',#{goodsName},'%') and gi.goods_name like CONCAT('%',#{goodsName},'%')
</if> </if>
</where> </where>
order by gi.create_time asc order by gi.sort desc
limit #{param.pageNo},#{param.pageSize} limit #{param.pageNo},#{param.pageSize}
</select> </select>
<select id="getWareInfoById" resultMap="wareInfoResultMap" parameterType="java.lang.Integer"> <select id="getWareInfoById" resultMap="wareInfoResultMap" parameterType="java.lang.Integer">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论