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

广告投放页优化

上级 af1db774
......@@ -76,9 +76,9 @@ public class AdvertisementItemController {
public R saveBatch(@RequestParam("aId") String aId, @RequestParam("itemIds") String itemIds) {
String itemIdArr[] = itemIds.split(",");
for (int i = 0; i < itemIdArr.length; i++) {
Map map=new HashMap();
map.put("adId",aId);
map.put("itemId",itemIdArr[i]);
Map map = new HashMap();
map.put("adId", aId);
map.put("itemId", itemIdArr[i]);
int count = advertisementItemService.getAdItemCount(map);
if (count > 0)
continue;
......@@ -129,11 +129,25 @@ public class AdvertisementItemController {
@RequestMapping("/deleteByItem")
@ResponseBody
public R deleteByItem(@RequestParam("itemId") String itemId) {
int res = advertisementItemService.deleteByItem(itemId);
public R deleteByItem(@RequestParam("itemId") String itemId, @RequestParam("adId") String adId) {
int res = advertisementItemService.deleteByItem(itemId, adId);
if (res > 0) {
return R.ok();
}
return R.error("操作失败");
}
@RequestMapping("/setItemTop")
@ResponseBody
public R setItemTop(@RequestParam("itemId") String itemId,
@RequestParam("adId") String adId) {
int res = advertisementItemService.setItemTop(itemId, adId);
if (res > 0) {
return R.ok();
} else if (res == -1) {
return R.error("最多置顶60个商品");
}
return R.error("操作失败");
}
}
......@@ -15,5 +15,13 @@ public interface AdvertisementItemDao extends BaseDao<AdvertisementItemEntity> {
int getAdItemCount(Map<String, Object> map);
int deleteByItem(String itemId);
int deleteByItem(@Param("itemId") String itemId, @Param("adId") String adId);
int getMaxSort();
int setItemTop(@Param("top") Integer top, @Param("itemId") String itemId, @Param("adId") String adId);
AdvertisementItemEntity getAdItemById(@Param("itemId") String itemId, @Param("adId") String adId);
int updateAdItem(AdvertisementItemEntity advertisementItemEntity);
}
......@@ -8,7 +8,7 @@ import java.util.Date;
* 表名 advertisement_item
*
* @author lipengjun
* @date 2020-09-25 14:48:21
* @date 2020-10-07 15:50:04
*/
public class AdvertisementItemEntity implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -21,6 +21,14 @@ public class AdvertisementItemEntity implements Serializable {
* 商品ID
*/
private String itemId;
/**
* 置顶
*/
private Integer isTop;
/**
* 排序
*/
private Integer sort;
/**
* 设置:广告投放ID
......@@ -48,6 +56,30 @@ public class AdvertisementItemEntity implements Serializable {
public String getItemId() {
return itemId;
}
/**
* 设置:置顶
*/
public void setIsTop(Integer isTop) {
this.isTop = isTop;
}
/**
* 获取:置顶
*/
public Integer getIsTop() {
return isTop;
}
/**
* 设置:排序
*/
public void setSort(Integer sort) {
this.sort = sort;
}
/**
* 获取:排序
*/
public Integer getSort() {
return sort;
}
}
......@@ -12,6 +12,8 @@ public class TbCfStationItemEntityExtends extends TbCfStationItemEntity implemen
private String itemDesc;
private BigDecimal discountPrice;
private String uname;
private Integer isTop;
private Integer sort;
public String getUname() {
return uname;
......@@ -62,4 +64,22 @@ public class TbCfStationItemEntityExtends extends TbCfStationItemEntity implemen
public void setGoodtype(String goodtype) {
this.goodtype = goodtype;
}
public Integer getIsTop() {
return isTop;
}
public void setIsTop(Integer isTop) {
this.isTop = isTop;
}
@Override
public Integer getSort() {
return sort;
}
@Override
public void setSort(Integer sort) {
this.sort = sort;
}
}
package com.platform.service;
import com.platform.entity.AdvertisementItemEntity;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
......@@ -71,5 +72,7 @@ public interface AdvertisementItemService {
int getAdItemCount(Map<String, Object> map);
int deleteByItem(String itemId);
int deleteByItem(String itemId, String adId);
int setItemTop(String itemId, String adId);
}
......@@ -4,9 +4,11 @@ import com.platform.dao.AdvertisementItemDao;
import com.platform.entity.AdvertisementItemEntity;
import com.platform.service.AdvertisementItemService;
import com.platform.utils.IdUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -62,7 +64,38 @@ public class AdvertisementItemServiceImpl implements AdvertisementItemService {
}
@Override
public int deleteByItem(String itemId) {
return advertisementItemDao.deleteByItem(itemId);
public int deleteByItem(String itemId, String adId) {
return advertisementItemDao.deleteByItem(itemId, adId);
}
@Override
public int setItemTop(String itemId, String adId) {
if (StringUtils.isBlank(itemId) || StringUtils.isBlank(adId)) {
return 0;
}
AdvertisementItemEntity byId = advertisementItemDao.getAdItemById(itemId, adId);
if (byId == null) {
return 0;
}
String top = byId.getIsTop().toString();
//置顶
if ("0".equals(top)) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("adId", adId);
paramMap.put("itemId", itemId);
int count = advertisementItemDao.getAdItemCount(paramMap);
//最多置顶60个
if (count >= 60) {
return -1;
}
int maxSort = advertisementItemDao.getMaxSort();
byId.setSort(++maxSort);
byId.setIsTop(1);
} else {
//取消置顶
byId.setSort(0);
byId.setIsTop(0);
}
return advertisementItemDao.updateAdItem(byId);
}
}
......@@ -6,16 +6,31 @@
<resultMap type="com.platform.entity.AdvertisementItemEntity" id="advertisementItemMap">
<result property="adId" column="ad_id"/>
<result property="itemId" column="item_id"/>
<result property="isTop" column="is_top"/>
<result property="sort" column="sort"/>
</resultMap>
<select id="queryObject" resultType="com.platform.entity.AdvertisementItemEntity">
select
`ad_id`,
`item_id`
`item_id`,
`is_top`,
`sort`
from advertisement_item
where ad_id = #{id}
</select>
<select id="getAdItemById" resultType="com.platform.entity.AdvertisementItemEntity">
select
`ad_id`,
`item_id`,
`is_top`,
`sort`
from advertisement_item
where ad_id = #{adId}
and item_id=#{itemId}
</select>
<select id="getAdItemCount" resultType="int">
select count(1) from advertisement_item where ad_id = #{adId}
<if test="itemId != null and itemId.trim() != ''">
......@@ -23,15 +38,24 @@
</if>
</select>
<update id="setItemTop">
update advertisement_item set is_top=#{top} where item_id=#{itemId} and ad_id=#{adId}
</update>
<select id="getMaxSort" resultType="int">
select max(sort) from advertisement_item
</select>
<delete id="deleteByItem">
delete from advertisement_item where item_id=#{itemId}
delete from advertisement_item where item_id=#{itemId} and ad_id=#{adId}
</delete>
<select id="queryList" resultType="com.platform.entity.AdvertisementItemEntity">
select
`ad_id`,
`item_id`
`item_id`,
`is_top`,
`sort`
from advertisement_item
WHERE 1=1
<if test="name != null and name.trim() != ''">
......@@ -61,20 +85,35 @@
<insert id="save" parameterType="com.platform.entity.AdvertisementItemEntity">
insert into advertisement_item(
`ad_id`,
`item_id`)
`item_id`,
`is_top`,
`sort`)
values(
#{adId},
#{itemId})
#{itemId},
#{isTop},
#{sort})
</insert>
<update id="update" parameterType="com.platform.entity.AdvertisementItemEntity">
update advertisement_item
<set>
<if test="itemId != null">`item_id` = #{itemId}</if>
<if test="itemId != null">`item_id` = #{itemId},</if>
<if test="isTop != null">`is_top` = #{isTop},</if>
<if test="sort != null">`sort` = #{sort}</if>
</set>
where ad_id = #{adId}
</update>
<update id="updateAdItem" parameterType="com.platform.entity.AdvertisementItemEntity">
update advertisement_item
<set>
<if test="isTop != null">`is_top` = #{isTop},</if>
<if test="sort != null">`sort` = #{sort}</if>
</set>
where ad_id = #{adId} and item_id = #{itemId}
</update>
<delete id="delete">
delete from advertisement_item where ad_id = #{value}
</delete>
......
......@@ -93,13 +93,16 @@
i.`creator`,
d.descripition_name dname,
t.goodstwotype_title title,
o.goodstype_title goodtype
o.goodstype_title goodtype,
a.is_top,
a.sort
from advertisement_item a
left join tb_cf_station_item i on i.item_id=a.item_id
left JOIN tb_cf_goodstype o ON o.goodstype_id = i.item_category
left JOIN tb_cf_goodstwotype t ON i.item_categorytwo=t.goodstwotype_id
left JOIN tb_cf_descripiton d ON i.item_descrition_id=d.descripition_id
where a.ad_id=#{adId} and i.enable_flag!=0
order by a.is_top desc,a.sort desc,i.create_time desc
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
......
......@@ -130,18 +130,16 @@ let vm = new Vue({
}
},
methods: {
delItem(id) {
delItem(itemId) {
let id = getSelectedRow("#jqGrid");
confirm('确定要删除选中的记录?', function () {
Ajax.request({
url: "../advertisementitem/deleteByItem?itemId=" + id,
url: "../advertisementitem/deleteByItem?itemId=" + itemId + '&adId=' + id,
type: "POST",
contentType: "application/json",
successCallback: function () {
alert('操作成功', function (index) {
let page = $("#adItemjqGrid").jqGrid('getGridParam', 'page');
$("#adItemjqGrid").jqGrid('setGridParam', {
page: page
}).trigger("reloadGrid");
vm.btn_Search(id);
});
}
});
......@@ -273,7 +271,12 @@ let vm = new Vue({
{
label: '操作', index: 'operate', width: 120, formatter: function (value, grid, rows) {
return '<span class="label label-info pointer" onclick="vm.delItem(\'' + rows.itemId + '\')">移除</span>&nbsp;&nbsp;'
if (rows.isTop == 1) {
return '<span class="label label-danger pointer" onclick="vm.itemTop(\'' + rows.itemId + '\')">取消置顶</span>&nbsp;&nbsp;' +
'<span class="label label-info pointer" onclick="vm.delItem(\'' + rows.itemId + '\')">移除</span>&nbsp;&nbsp;'
}
return '<span class="label label-info pointer" onclick="vm.itemTop(\'' + rows.itemId + '\')">置顶</span>&nbsp;&nbsp;' +
'<span class="label label-info pointer" onclick="vm.delItem(\'' + rows.itemId + '\')">移除</span>&nbsp;&nbsp;'
}
}
],
......@@ -283,6 +286,19 @@ let vm = new Vue({
vm.btn_Search(id);
vm.getInfo(id);
},
itemTop(itemId) {
let id = getSelectedRow("#jqGrid");
let url = '../advertisementitem/setItemTop?itemId=' + itemId + '&adId=' + id;
Ajax.request({
url: url,
type: "GET",
contentType: "application/json",
successCallback: function (resultData) {
vm.btn_Search(id);
!notShowMessage ? iview.Message.success(resultData.success) : null;
}
});
},
saveOrUpdate: function (event) {
if (vm.advertisement.adName == null || vm.advertisement.adName == '') {
alert("广告名称不能为空")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论