提交 34c648fa authored 作者: 吴德鹏's avatar 吴德鹏

修改商品oss上传二级目录

上级 1c00243f
...@@ -3,6 +3,7 @@ package com.platform.dao; ...@@ -3,6 +3,7 @@ package com.platform.dao;
import com.platform.entity.AdvertisementItemEntity; import com.platform.entity.AdvertisementItemEntity;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -27,5 +28,8 @@ public interface AdvertisementItemDao extends BaseDao<AdvertisementItemEntity> { ...@@ -27,5 +28,8 @@ public interface AdvertisementItemDao extends BaseDao<AdvertisementItemEntity> {
int existItemSort(@Param("adId") String adId, @Param("sort") Integer sort); int existItemSort(@Param("adId") String adId, @Param("sort") Integer sort);
List<AdvertisementItemEntity> changeSortBack(@Param("firstSort") Integer firstSort, @Param("endSort") Integer endSort, @Param("adId") String adId);
List<AdvertisementItemEntity> changeSortFront(@Param("firstSort") Integer firstSort, @Param("endSort") Integer endSort, @Param("adId") String adId);
} }
...@@ -146,13 +146,24 @@ public class AdvertisementItemServiceImpl implements AdvertisementItemService { ...@@ -146,13 +146,24 @@ public class AdvertisementItemServiceImpl implements AdvertisementItemService {
res = advertisementItemDao.updateAdItem(byId); res = advertisementItemDao.updateAdItem(byId);
} else { } else {
//要更换的序号被占有 //要更换的序号被占有
//情况3 //情况3 (2-->8)
if (byId.getSort() < itemSort) { Integer sort1 = byId.getSort();
if (sort1 < itemSort) {
List<AdvertisementItemEntity> list = advertisementItemDao.changeSortBack(sort1 + 1, itemSort, adId);
for (AdvertisementItemEntity ad : list) {
ad.setSort(ad.getSort() - 1);
advertisementItemDao.updateAdItem(ad);
}
} else { } else {
//情况4 //情况4 (8-->2)
List<AdvertisementItemEntity> list = advertisementItemDao.changeSortFront(itemSort, sort1 - 1, adId);
for (AdvertisementItemEntity ad : list) {
ad.setSort(ad.getSort() + 1);
advertisementItemDao.updateAdItem(ad);
}
} }
byId.setSort(itemSort);
res = advertisementItemDao.updateAdItem(byId);
} }
......
...@@ -57,6 +57,26 @@ ...@@ -57,6 +57,26 @@
</if> </if>
</select> </select>
<select id="changeSortBack" resultType="com.platform.entity.AdvertisementItemEntity">
select
`ad_id`,
`item_id`,
`is_top`,
`sort`,
`create_time`
from advertisement_item where sort BETWEEN #{firstSort} AND #{endSort} and ad_id=#{adId}
</select>
<select id="changeSortFront" resultType="com.platform.entity.AdvertisementItemEntity">
select
`ad_id`,
`item_id`,
`is_top`,
`sort`,
`create_time`
from advertisement_item where sort BETWEEN #{firstSort} AND #{endSort} and ad_id=#{adId}
</select>
<delete id="deleteByItem"> <delete id="deleteByItem">
delete from advertisement_item where item_id=#{itemId} and ad_id=#{adId} delete from advertisement_item where item_id=#{itemId} and ad_id=#{adId}
</delete> </delete>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论