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

广告复制

上级 9ec222b2
......@@ -93,9 +93,13 @@ public class AdvertisementController {
@RequiresPermissions("advertisement:update")
@ResponseBody
public R update(@RequestBody AdvertisementEntity advertisement) {
advertisementService.update(advertisement);
int res = advertisementService.update(advertisement);
if (res > 0) {
return R.ok();
} else if (res == -1) {
return R.error("链接已存在");
}
return R.error("操作失败");
}
/**
......
package com.platform.controller;
import com.platform.entity.AdvertisementEntity;
import com.platform.entity.AdvertisementItemEntity;
import com.platform.service.AdvertisementItemService;
import com.platform.service.AdvertisementService;
import com.platform.utils.IdUtil;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -17,6 +21,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Controller
......@@ -30,6 +35,9 @@ public class AdvertisementItemController {
@Autowired
private AdvertisementItemService advertisementItemService;
@Autowired
private AdvertisementService advertisementService;
/**
* 查看列表
*/
......@@ -90,6 +98,30 @@ public class AdvertisementItemController {
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;
import com.platform.entity.AdvertisementEntity;
import org.apache.ibatis.annotations.Param;
/**
* Dao
......@@ -12,4 +13,5 @@ public interface AdvertisementDao extends BaseDao<AdvertisementEntity> {
int existAdLink(String link);
int existAdLink1(@Param("link") String link, @Param("id") String id);
}
......@@ -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> queryById(String id);
}
......@@ -80,4 +80,6 @@ public interface AdvertisementItemService {
int updateAdvertisementItem(@RequestParam Map<String, Object> map);
Integer getAdSort(Map<String, Object> map);
List<AdvertisementItemEntity> queryById(String id);
}
......@@ -204,4 +204,9 @@ public class AdvertisementItemServiceImpl implements AdvertisementItemService {
}
return 0;
}
@Override
public List<AdvertisementItemEntity> queryById(String id) {
return advertisementItemDao.queryById(id);
}
}
......@@ -64,6 +64,9 @@ public class AdvertisementServiceImpl implements AdvertisementService {
@Override
public int update(AdvertisementEntity advertisement) {
int count = advertisementDao.existAdLink1(advertisement.getAdLink(),advertisement.getId());
if (count > 0)
return -1;
advertisement.setUpdateTime(new Date());
return advertisementDao.update(advertisement);
}
......
......@@ -36,6 +36,10 @@
select count(1) from advertisement where ad_link=#{link}
</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`,
......
......@@ -22,6 +22,17 @@
where ad_id = #{id}
</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
`ad_id`,
......
......@@ -314,7 +314,7 @@
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 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() != ''">
AND creator=#{creator}
</if>
......
......@@ -33,7 +33,7 @@ let vm = new Vue({
],
tempId: '',
typeActive: 0, //显示索引
items: ["分类搜索","属性搜索"],
items: ["分类搜索", "属性搜索"],
/*
--链接方式
*/
......@@ -131,7 +131,7 @@ let vm = new Vue({
q: {
name: ''
},
iscopy:0,//是否为复制
iscopy: 0,//是否为复制
},
methods: {
//新增广告
......@@ -231,7 +231,7 @@ let vm = new Vue({
confirm('确定要删除选中的记录?', function () {
Ajax.request({
// url: "../advertisementitem/deleteByItem?itemId=" + itemId + '&adId=' + id,
url: "../advertisementitem/deleteByItem?adId=" + id ,
url: "../advertisementitem/deleteByItem?adId=" + id,
type: "POST",
params: JSON.stringify(data),
contentType: "application/json",
......@@ -253,7 +253,7 @@ let vm = new Vue({
confirm('确定要删除选中的记录?', function () {
Ajax.request({
// url: "../advertisementitem/deleteByItem?itemId=" + itemId + '&adId=' + id,
url: "../advertisementitem/deleteByItem?adId=" + id ,
url: "../advertisementitem/deleteByItem?adId=" + id,
type: "POST",
params: JSON.stringify(ids),
contentType: "application/json",
......@@ -372,51 +372,64 @@ let vm = new Vue({
vm.getInfo(id);
},
//复制广告
copy: function (event) {
$("#searchjqGrid").jqGrid("clearGridData");
$("#adItemjqGrid").jqGrid("clearGridData");
// copy: function (event) {
// $("#searchjqGrid").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");
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;'
let url = '../advertisementitem/copyAdInfo/'+id;
Ajax.request({
url: url,
type: "GET",
contentType: "application/json",
successCallback: function (resultData) {
vm.reload();
alert("复制完成")
}
} // beforeSelectRow: beforeSelectRow,
],
multiboxonly: true
});
});
vm.btn_Search(id);
vm.getInfo(id);
},
itemTop(itemId) {
let id = getSelectedRow("#jqGrid");
......@@ -462,11 +475,11 @@ let vm = new Vue({
}
// let url = vm.advertisement.id == null ? "../advertisement/save" : "../advertisement/update";
var url;
if (vm.iscopy == 1){
if (vm.iscopy == 1) {
url = "../advertisement/save"
}else if (vm.advertisement.id == null && vm.iscopy == 0){
} else if (vm.advertisement.id == null && vm.iscopy == 0) {
url = "../advertisement/save"
}else if (vm.advertisement.id != null && vm.iscopy == 0){
} else if (vm.advertisement.id != null && vm.iscopy == 0) {
url = "../advertisement/update"
}
......@@ -477,7 +490,7 @@ let vm = new Vue({
if (vm.advertisement.id == null || vm.advertisement.id == '' || vm.advertisement.id == 'undefined') {
vm.advertisement.id = vm.tempId;
}
if (vm.iscopy == 1){
if (vm.iscopy == 1) {
vm.advertisement.id = vm.tempId
}
Ajax.request({
......@@ -520,7 +533,7 @@ let vm = new Vue({
async: true,
successCallback: function (r) {
vm.advertisement = r.advertisement;
if(vm.iscopy == 1){
if (vm.iscopy == 1) {
vm.advertisement.adName = r.advertisement.adName + '(1)'
vm.advertisement.adLink = r.advertisement.adLink + '(1)'
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论