提交 288eb674 authored 作者: 吴德鹏's avatar 吴德鹏

广告复制

上级 9ec222b2
...@@ -93,9 +93,13 @@ public class AdvertisementController { ...@@ -93,9 +93,13 @@ public class AdvertisementController {
@RequiresPermissions("advertisement:update") @RequiresPermissions("advertisement:update")
@ResponseBody @ResponseBody
public R update(@RequestBody AdvertisementEntity advertisement) { public R update(@RequestBody AdvertisementEntity advertisement) {
advertisementService.update(advertisement); int res = advertisementService.update(advertisement);
if (res > 0) {
return R.ok(); return R.ok();
} else if (res == -1) {
return R.error("链接已存在");
}
return R.error("操作失败");
} }
/** /**
......
package com.platform.controller; package com.platform.controller;
import com.platform.entity.AdvertisementEntity;
import com.platform.entity.AdvertisementItemEntity; import com.platform.entity.AdvertisementItemEntity;
import com.platform.service.AdvertisementItemService; import com.platform.service.AdvertisementItemService;
import com.platform.service.AdvertisementService;
import com.platform.utils.IdUtil;
import com.platform.utils.PageUtils; import com.platform.utils.PageUtils;
import com.platform.utils.Query; import com.platform.utils.Query;
import com.platform.utils.R; import com.platform.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
...@@ -17,6 +21,7 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -17,6 +21,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* Controller * Controller
...@@ -30,6 +35,9 @@ public class AdvertisementItemController { ...@@ -30,6 +35,9 @@ public class AdvertisementItemController {
@Autowired @Autowired
private AdvertisementItemService advertisementItemService; private AdvertisementItemService advertisementItemService;
@Autowired
private AdvertisementService advertisementService;
/** /**
* 查看列表 * 查看列表
*/ */
...@@ -90,6 +98,30 @@ public class AdvertisementItemController { ...@@ -90,6 +98,30 @@ public class AdvertisementItemController {
return R.ok(); return R.ok();
} }
//复制
@RequestMapping("/copyAdInfo/{adId}")
@ResponseBody
public R copyAdInfo(@PathVariable String adId) {
//复制原广告信息
String newAdId = IdUtil.createIdbyUUID();
AdvertisementEntity sourceAdvertisement = advertisementService.queryObject(adId);
AdvertisementEntity advertisement = new AdvertisementEntity();
BeanUtils.copyProperties(sourceAdvertisement, advertisement);
advertisement.setId(newAdId);
advertisement.setAdLink(null);
advertisementService.save(advertisement);
List<AdvertisementItemEntity> list = advertisementItemService.queryById(adId);
//复制广告商品
list.forEach(adItem -> {
AdvertisementItemEntity advertisementItem = new AdvertisementItemEntity();
BeanUtils.copyProperties(adItem, advertisementItem);
advertisementItem.setAdId(newAdId);
advertisementItemService.save(advertisementItem);
});
return R.ok();
}
/** /**
* 修改 * 修改
......
package com.platform.dao; package com.platform.dao;
import com.platform.entity.AdvertisementEntity; import com.platform.entity.AdvertisementEntity;
import org.apache.ibatis.annotations.Param;
/** /**
* Dao * Dao
...@@ -12,4 +13,5 @@ public interface AdvertisementDao extends BaseDao<AdvertisementEntity> { ...@@ -12,4 +13,5 @@ public interface AdvertisementDao extends BaseDao<AdvertisementEntity> {
int existAdLink(String link); int existAdLink(String link);
int existAdLink1(@Param("link") String link, @Param("id") String id);
} }
...@@ -32,4 +32,5 @@ public interface AdvertisementItemDao extends BaseDao<AdvertisementItemEntity> { ...@@ -32,4 +32,5 @@ public interface AdvertisementItemDao extends BaseDao<AdvertisementItemEntity> {
List<AdvertisementItemEntity> changeSortFront(@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);
List<AdvertisementItemEntity> queryById(String id);
} }
...@@ -80,4 +80,6 @@ public interface AdvertisementItemService { ...@@ -80,4 +80,6 @@ public interface AdvertisementItemService {
int updateAdvertisementItem(@RequestParam Map<String, Object> map); int updateAdvertisementItem(@RequestParam Map<String, Object> map);
Integer getAdSort(Map<String, Object> map); Integer getAdSort(Map<String, Object> map);
List<AdvertisementItemEntity> queryById(String id);
} }
...@@ -204,4 +204,9 @@ public class AdvertisementItemServiceImpl implements AdvertisementItemService { ...@@ -204,4 +204,9 @@ public class AdvertisementItemServiceImpl implements AdvertisementItemService {
} }
return 0; return 0;
} }
@Override
public List<AdvertisementItemEntity> queryById(String id) {
return advertisementItemDao.queryById(id);
}
} }
...@@ -64,6 +64,9 @@ public class AdvertisementServiceImpl implements AdvertisementService { ...@@ -64,6 +64,9 @@ public class AdvertisementServiceImpl implements AdvertisementService {
@Override @Override
public int update(AdvertisementEntity advertisement) { public int update(AdvertisementEntity advertisement) {
int count = advertisementDao.existAdLink1(advertisement.getAdLink(),advertisement.getId());
if (count > 0)
return -1;
advertisement.setUpdateTime(new Date()); advertisement.setUpdateTime(new Date());
return advertisementDao.update(advertisement); return advertisementDao.update(advertisement);
} }
......
...@@ -36,6 +36,10 @@ ...@@ -36,6 +36,10 @@
select count(1) from advertisement where ad_link=#{link} select count(1) from advertisement where ad_link=#{link}
</select> </select>
<select id="existAdLink1" resultType="int">
select count(1) from advertisement where ad_link=#{link} id !=#{id}
</select>
<select id="queryList" resultType="com.platform.entity.AdvertisementEntity"> <select id="queryList" resultType="com.platform.entity.AdvertisementEntity">
select select
`id`, `id`,
......
...@@ -22,6 +22,17 @@ ...@@ -22,6 +22,17 @@
where ad_id = #{id} where ad_id = #{id}
</select> </select>
<select id="queryById" resultType="com.platform.entity.AdvertisementItemEntity">
select
`ad_id`,
`item_id`,
`is_top`,
`sort`,
`create_time`
from advertisement_item
where ad_id = #{id}
</select>
<select id="getAdItemById" resultType="com.platform.entity.AdvertisementItemEntity"> <select id="getAdItemById" resultType="com.platform.entity.AdvertisementItemEntity">
select select
`ad_id`, `ad_id`,
......
...@@ -314,7 +314,7 @@ ...@@ -314,7 +314,7 @@
left JOIN tb_cf_goodstwotype t ON i.item_categorytwo=t.goodstwotype_id 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 left JOIN tb_cf_descripiton d ON i.item_descrition_id=d.descripition_id
left JOIN sys_user s on i.creator=s.user_id left JOIN sys_user s on i.creator=s.user_id
WHERE i.enable_flag!=0 WHERE i.enable_flag in(1,2)
<if test="creator != null and creator.trim() != ''"> <if test="creator != null and creator.trim() != ''">
AND creator=#{creator} AND creator=#{creator}
</if> </if>
......
...@@ -33,7 +33,7 @@ let vm = new Vue({ ...@@ -33,7 +33,7 @@ let vm = new Vue({
], ],
tempId: '', tempId: '',
typeActive: 0, //显示索引 typeActive: 0, //显示索引
items: ["分类搜索","属性搜索"], items: ["分类搜索", "属性搜索"],
/* /*
--链接方式 --链接方式
*/ */
...@@ -131,7 +131,7 @@ let vm = new Vue({ ...@@ -131,7 +131,7 @@ let vm = new Vue({
q: { q: {
name: '' name: ''
}, },
iscopy:0,//是否为复制 iscopy: 0,//是否为复制
}, },
methods: { methods: {
//新增广告 //新增广告
...@@ -231,7 +231,7 @@ let vm = new Vue({ ...@@ -231,7 +231,7 @@ let vm = new Vue({
confirm('确定要删除选中的记录?', function () { confirm('确定要删除选中的记录?', function () {
Ajax.request({ Ajax.request({
// url: "../advertisementitem/deleteByItem?itemId=" + itemId + '&adId=' + id, // url: "../advertisementitem/deleteByItem?itemId=" + itemId + '&adId=' + id,
url: "../advertisementitem/deleteByItem?adId=" + id , url: "../advertisementitem/deleteByItem?adId=" + id,
type: "POST", type: "POST",
params: JSON.stringify(data), params: JSON.stringify(data),
contentType: "application/json", contentType: "application/json",
...@@ -253,7 +253,7 @@ let vm = new Vue({ ...@@ -253,7 +253,7 @@ let vm = new Vue({
confirm('确定要删除选中的记录?', function () { confirm('确定要删除选中的记录?', function () {
Ajax.request({ Ajax.request({
// url: "../advertisementitem/deleteByItem?itemId=" + itemId + '&adId=' + id, // url: "../advertisementitem/deleteByItem?itemId=" + itemId + '&adId=' + id,
url: "../advertisementitem/deleteByItem?adId=" + id , url: "../advertisementitem/deleteByItem?adId=" + id,
type: "POST", type: "POST",
params: JSON.stringify(ids), params: JSON.stringify(ids),
contentType: "application/json", contentType: "application/json",
...@@ -372,51 +372,64 @@ let vm = new Vue({ ...@@ -372,51 +372,64 @@ let vm = new Vue({
vm.getInfo(id); vm.getInfo(id);
}, },
//复制广告 //复制广告
copy: function (event) { // copy: function (event) {
$("#searchjqGrid").jqGrid("clearGridData"); // $("#searchjqGrid").jqGrid("clearGridData");
$("#adItemjqGrid").jqGrid("clearGridData"); // $("#adItemjqGrid").jqGrid("clearGridData");
// let id = getSelectedRow("#jqGrid");
// if (id == null) {
// return;
// }
// vm.tempId = this.guid();
// vm.iscopy = 1
// vm.showList = false;
// vm.title = "复制";
// $(function () {
// $("#adItemjqGrid").Grid({
// url: '../advertisement/getAdvertisementItem?adId=' + id,
// colModel: [
// {label: 'itemId', name: 'itemId', key: true, index: 'item_id', hidden: true},
// {label: '序号', name: 'itemSort', index: 'itemSort', width: 100},
// {label: '商品图片', name: 'itemImg', index: 'item_img', width: 100, formatter: imageFormat},
// {label: '商品编号', name: 'itemCode', index: 'item_code', width: 160},
// {label: '商品名称', name: 'itemName', index: 'item_name', width: 160},
// /* {label: '商品标题', name: 'itemBrief', index: 'item_brief', width: 120},*/
// /*{label: '商品链接', name: 'itemUrl', index: 'item_url', width: 80,formatter:linkFormat},*/
// {label: '商品原价', name: 'itemPrice', index: 'item_price', width: 100},
// {label: '商品现价', name: 'discountPrice', index: 'discount_price', width: 100},
// /*{label: '所属平台', name: 'platformCode', index: 'platform_code', width: 80},
// {label: '平台名', name: 'platformName', index: 'platform_name', width: 80},*/
// {label: '供应商', name: 'supplier', index: 'supplier', width: 120},
// {label: '商品一级分类', name: 'goodtype', index: 'goodtype', width: 120},
// {label: '商品二级分类', name: 'title', index: 'title', width: 120},
// {label: '商品品名', name: 'dname', index: 'itemDescritionId', width: 120},
// {
// label: '操作', index: 'operate', width: 160, formatter: function (value, grid, rows) {
//
//
// return '<span class="label label-info pointer" onclick="vm.delItem(\'' + rows.itemId + '\')">移除</span>&nbsp;&nbsp;' +
// '<span class="label label-info pointer" onclick="vm.sortItem(\'' + rows.itemId + '\')">排序</span>&nbsp;&nbsp;'
// }
// } // beforeSelectRow: beforeSelectRow,
//
// ],
// multiboxonly: true
// });
// });
// vm.btn_Search(id);
// vm.getInfo(id);
// },
copy() {
let id = getSelectedRow("#jqGrid"); let id = getSelectedRow("#jqGrid");
if (id == null) { let url = '../advertisementitem/copyAdInfo/'+id;
return; Ajax.request({
} url: url,
vm.tempId = this.guid(); type: "GET",
vm.iscopy = 1 contentType: "application/json",
vm.showList = false; successCallback: function (resultData) {
vm.title = "复制"; vm.reload();
$(function () { alert("复制完成")
$("#adItemjqGrid").Grid({
url: '../advertisement/getAdvertisementItem?adId=' + id,
colModel: [
{label: 'itemId', name: 'itemId', key: true, index: 'item_id', hidden: true},
{label: '序号', name: 'itemSort', index: 'itemSort', width: 100},
{label: '商品图片', name: 'itemImg', index: 'item_img', width: 100, formatter: imageFormat},
{label: '商品编号', name: 'itemCode', index: 'item_code', width: 160},
{label: '商品名称', name: 'itemName', index: 'item_name', width: 160},
/* {label: '商品标题', name: 'itemBrief', index: 'item_brief', width: 120},*/
/*{label: '商品链接', name: 'itemUrl', index: 'item_url', width: 80,formatter:linkFormat},*/
{label: '商品原价', name: 'itemPrice', index: 'item_price', width: 100},
{label: '商品现价', name: 'discountPrice', index: 'discount_price', width: 100},
/*{label: '所属平台', name: 'platformCode', index: 'platform_code', width: 80},
{label: '平台名', name: 'platformName', index: 'platform_name', width: 80},*/
{label: '供应商', name: 'supplier', index: 'supplier', width: 120},
{label: '商品一级分类', name: 'goodtype', index: 'goodtype', width: 120},
{label: '商品二级分类', name: 'title', index: 'title', width: 120},
{label: '商品品名', name: 'dname', index: 'itemDescritionId', width: 120},
{
label: '操作', index: 'operate', width: 160, formatter: function (value, grid, rows) {
return '<span class="label label-info pointer" onclick="vm.delItem(\'' + rows.itemId + '\')">移除</span>&nbsp;&nbsp;' +
'<span class="label label-info pointer" onclick="vm.sortItem(\'' + rows.itemId + '\')">排序</span>&nbsp;&nbsp;'
} }
} // beforeSelectRow: beforeSelectRow,
],
multiboxonly: true
}); });
});
vm.btn_Search(id);
vm.getInfo(id);
}, },
itemTop(itemId) { itemTop(itemId) {
let id = getSelectedRow("#jqGrid"); let id = getSelectedRow("#jqGrid");
...@@ -462,11 +475,11 @@ let vm = new Vue({ ...@@ -462,11 +475,11 @@ let vm = new Vue({
} }
// let url = vm.advertisement.id == null ? "../advertisement/save" : "../advertisement/update"; // let url = vm.advertisement.id == null ? "../advertisement/save" : "../advertisement/update";
var url; var url;
if (vm.iscopy == 1){ if (vm.iscopy == 1) {
url = "../advertisement/save" url = "../advertisement/save"
}else if (vm.advertisement.id == null && vm.iscopy == 0){ } else if (vm.advertisement.id == null && vm.iscopy == 0) {
url = "../advertisement/save" url = "../advertisement/save"
}else if (vm.advertisement.id != null && vm.iscopy == 0){ } else if (vm.advertisement.id != null && vm.iscopy == 0) {
url = "../advertisement/update" url = "../advertisement/update"
} }
...@@ -477,7 +490,7 @@ let vm = new Vue({ ...@@ -477,7 +490,7 @@ let vm = new Vue({
if (vm.advertisement.id == null || vm.advertisement.id == '' || vm.advertisement.id == 'undefined') { if (vm.advertisement.id == null || vm.advertisement.id == '' || vm.advertisement.id == 'undefined') {
vm.advertisement.id = vm.tempId; vm.advertisement.id = vm.tempId;
} }
if (vm.iscopy == 1){ if (vm.iscopy == 1) {
vm.advertisement.id = vm.tempId vm.advertisement.id = vm.tempId
} }
Ajax.request({ Ajax.request({
...@@ -520,7 +533,7 @@ let vm = new Vue({ ...@@ -520,7 +533,7 @@ let vm = new Vue({
async: true, async: true,
successCallback: function (r) { successCallback: function (r) {
vm.advertisement = r.advertisement; vm.advertisement = r.advertisement;
if(vm.iscopy == 1){ if (vm.iscopy == 1) {
vm.advertisement.adName = r.advertisement.adName + '(1)' vm.advertisement.adName = r.advertisement.adName + '(1)'
vm.advertisement.adLink = r.advertisement.adLink + '(1)' vm.advertisement.adLink = r.advertisement.adLink + '(1)'
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论