提交 4bad1054 authored 作者: 吴德鹏's avatar 吴德鹏

修改商品置顶bug

上级 49856c70
......@@ -32,4 +32,12 @@ public interface TbCfStationItemDao extends BaseDao<TbCfStationItemEntity> {
TbCfStationItemEntity queryItemBySort(Integer sort);
int updateItemSort(TbCfStationItemEntity item);
int minSort();
int maxSort();
TbCfStationItemEntity upSortItem(Integer sort);
TbCfStationItemEntity downSortItem(Integer sort);
}
......@@ -506,14 +506,15 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
TbCfStationItemEntity item = tbCfStationItemDao.queryObject(itemId);
Integer sort = item.getSort();
if ("1".equals(String.valueOf(sort))) {
int minSort = tbCfStationItemDao.minSort();
if (String.valueOf(minSort).equals(String.valueOf(sort))) {
return -1;
}
TbCfStationItemEntity upItem = tbCfStationItemDao.queryItemBySort(sort - 1);
TbCfStationItemEntity upItem = tbCfStationItemDao.upSortItem(sort);
item.setSort(upItem.getSort());
upItem.setSort(sort);
int res1 = tbCfStationItemDao.updateItemSort(upItem);
item.setSort(sort - 1);
int res2 = tbCfStationItemDao.updateItemSort(item);
if (res1 > 0 && res2 > 0) {
......@@ -529,14 +530,14 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
int res = 0;
TbCfStationItemEntity item = tbCfStationItemDao.queryObject(itemId);
Integer sort = item.getSort();
int count = tbCfStationItemDao.queryTopCount();
if (String.valueOf(count).equals(String.valueOf(sort))) {
int maxSort = tbCfStationItemDao.maxSort();
if (String.valueOf(maxSort).equals(String.valueOf(sort))) {
return -1;
}
TbCfStationItemEntity downItem = tbCfStationItemDao.queryItemBySort(sort + 1);
TbCfStationItemEntity downItem = tbCfStationItemDao.downSortItem(sort);
item.setSort(downItem.getSort());
downItem.setSort(sort);
int res1 = tbCfStationItemDao.updateItemSort(downItem);
item.setSort(sort + 1);
int res2 = tbCfStationItemDao.updateItemSort(item);
if (res1 > 0 && res2 > 0) {
res = 1;
......
......@@ -105,6 +105,90 @@
WHERE item_code = #{code}
</select>
<select id="minSort" resultType="int">
select min(sort) FROM tb_cf_station_item where item_top=1
</select>
<select id="maxSort" resultType="int">
select max(sort) FROM tb_cf_station_item where item_top=1
</select>
<select id="upSortItem" resultType="com.platform.entity.TbCfStationItemEntity">
SELECT
item_id,
`item_code`,
`item_name`,
`item_brief`,
`item_category`,
`item_price`,
`discount_price`,
cost_price,
`item_url`,
`item_img`,
`item_tags`,
`item_label`,
`item_num`,
`item_count`,
`item_sku`,
`item_top`,
sort,
`supplier`,
template,
`sku_imgs`,
`platform_code`,
`platform_name`,
`enable_flag`,
create_time,
`item_categorytwo`,
`item_descrition_id`,
creator
FROM
tb_cf_station_item
WHERE
item_top = 1
AND sort &lt; #{sort}
ORDER BY sort desc
limit 1
</select>
<select id="downSortItem" resultType="com.platform.entity.TbCfStationItemEntity">
SELECT
item_id,
`item_code`,
`item_name`,
`item_brief`,
`item_category`,
`item_price`,
`discount_price`,
cost_price,
`item_url`,
`item_img`,
`item_tags`,
`item_label`,
`item_num`,
`item_count`,
`item_sku`,
`item_top`,
sort,
`supplier`,
template,
`sku_imgs`,
`platform_code`,
`platform_name`,
`enable_flag`,
create_time,
`item_categorytwo`,
`item_descrition_id`,
creator
FROM
tb_cf_station_item
WHERE
item_top = 1
AND sort &gt; #{sort}
ORDER BY sort asc
limit 1
</select>
<select id="queryList" resultType="com.platform.entity.TbCfStationItemEntityExtends">
SELECT
i.item_id,
......
......@@ -25,8 +25,8 @@ $(function () {
{
label: '操作', index: 'operate', width: 120, formatter: function (value, grid, rows) {
if (rows.itemTop === 1) {
return '<span class="label label-primary pointer" onclick="vm.itemUpward(\'' + rows.itemId + '\')" ">up</span>&nbsp;&nbsp;' +
'<span class="label label-success pointer" onclick="vm.itemDownward(\'' + rows.itemId + '\')" ">down</span>&nbsp;&nbsp' +
return '<span class="label label-primary pointer" onclick="vm.itemUpward(\'' + rows.itemId + '\')" ">上移</span>&nbsp;&nbsp;' +
'<span class="label label-success pointer" onclick="vm.itemDownward(\'' + rows.itemId + '\')" ">下移</span>&nbsp;&nbsp' +
'<span class="label label-danger pointer" onclick="vm.cancelTop(\'' + rows.itemId + '\')" ">取消置顶</span>&nbsp;&nbsp;';
}
return '<span class="label label-info pointer" onclick="vm.itemTop(\'' + rows.itemId + '\')">置顶</span>&nbsp;&nbsp;'
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论