Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
C
chinafrica
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
chinafrica
Commits
1c00243f
提交
1c00243f
authored
10月 15, 2020
作者:
吴德鹏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
广告投放页优化之商品排序
上级
07f4d43f
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
230 行增加
和
29 行删除
+230
-29
AdvertisementItemController.java
.../com/platform/controller/AdvertisementItemController.java
+20
-0
AdvertisementItemDao.java
.../src/main/java/com/platform/dao/AdvertisementItemDao.java
+5
-1
AdvertisementItemEntity.java
...ain/java/com/platform/entity/AdvertisementItemEntity.java
+21
-4
TbCfStationItemEntityExtends.java
...ava/com/platform/entity/TbCfStationItemEntityExtends.java
+9
-0
AdvertisementItemService.java
...n/java/com/platform/service/AdvertisementItemService.java
+5
-0
AdvertisementItemServiceImpl.java
...m/platform/service/impl/AdvertisementItemServiceImpl.java
+83
-4
AdvertisementItemDao.xml
.../main/resources/com/platform/dao/AdvertisementItemDao.xml
+22
-7
TbCfStationItemDao.xml
...rc/main/resources/com/platform/dao/TbCfStationItemDao.xml
+3
-3
advertisement.html
...admin/src/main/webapp/WEB-INF/page/sys/advertisement.html
+13
-1
advertisement.js
platform-admin/src/main/webapp/js/sys/advertisement.js
+49
-9
没有找到文件。
platform-admin/src/main/java/com/platform/controller/AdvertisementItemController.java
浏览文件 @
1c00243f
...
...
@@ -150,4 +150,24 @@ public class AdvertisementItemController {
}
return
R
.
error
(
"操作失败"
);
}
/**
* 修改广告页商品
*/
@RequestMapping
(
"/updateAdvertisementItem"
)
@ResponseBody
public
R
updateAdvertisementItem
(
@RequestParam
Map
<
String
,
Object
>
map
)
{
int
res
=
advertisementItemService
.
updateAdvertisementItem
(
map
);
if
(
res
>
0
)
{
return
R
.
ok
();
}
return
R
.
error
(
"操作失败"
);
}
@RequestMapping
(
"/getAdSort"
)
@ResponseBody
public
R
getAdSort
(
@RequestParam
Map
<
String
,
Object
>
map
)
{
Integer
sort
=
advertisementItemService
.
getAdSort
(
map
);
return
R
.
ok
().
put
(
"sort"
,
sort
);
}
}
platform-admin/src/main/java/com/platform/dao/AdvertisementItemDao.java
浏览文件 @
1c00243f
...
...
@@ -17,11 +17,15 @@ public interface AdvertisementItemDao extends BaseDao<AdvertisementItemEntity> {
int
deleteByItem
(
@Param
(
"itemId"
)
String
itemId
,
@Param
(
"adId"
)
String
adId
);
int
getMaxSort
();
int
getMaxSort
(
@Param
(
"adId"
)
String
adId
);
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
);
int
existItemSort
(
@Param
(
"adId"
)
String
adId
,
@Param
(
"sort"
)
Integer
sort
);
}
platform-admin/src/main/java/com/platform/entity/AdvertisementItemEntity.java
浏览文件 @
1c00243f
...
...
@@ -8,7 +8,7 @@ import java.util.Date;
* 表名 advertisement_item
*
* @author lipengjun
* @date 2020-10-
07 15:50:04
* @date 2020-10-
13 17:30:21
*/
public
class
AdvertisementItemEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -22,13 +22,17 @@ public class AdvertisementItemEntity implements Serializable {
*/
private
String
itemId
;
/**
* 置顶
*
是否置顶 0: 不置顶 1:
置顶
*/
private
Integer
isTop
;
/**
* 排序
*/
private
Integer
sort
;
/**
* 商品添加时间
*/
private
Date
createTime
;
/**
* 设置:广告投放ID
...
...
@@ -57,14 +61,14 @@ public class AdvertisementItemEntity implements Serializable {
return
itemId
;
}
/**
* 设置:置顶
* 设置:
是否置顶 0: 不置顶 1:
置顶
*/
public
void
setIsTop
(
Integer
isTop
)
{
this
.
isTop
=
isTop
;
}
/**
* 获取:置顶
* 获取:
是否置顶 0: 不置顶 1:
置顶
*/
public
Integer
getIsTop
()
{
return
isTop
;
...
...
@@ -82,4 +86,17 @@ public class AdvertisementItemEntity implements Serializable {
public
Integer
getSort
()
{
return
sort
;
}
/**
* 设置:商品添加时间
*/
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
/**
* 获取:商品添加时间
*/
public
Date
getCreateTime
()
{
return
createTime
;
}
}
platform-admin/src/main/java/com/platform/entity/TbCfStationItemEntityExtends.java
浏览文件 @
1c00243f
...
...
@@ -14,6 +14,15 @@ public class TbCfStationItemEntityExtends extends TbCfStationItemEntity implemen
private
String
uname
;
private
Integer
isTop
;
private
Integer
sort
;
private
Integer
itemSort
;
public
Integer
getItemSort
()
{
return
itemSort
;
}
public
void
setItemSort
(
Integer
itemSort
)
{
this
.
itemSort
=
itemSort
;
}
public
String
getUname
()
{
return
uname
;
...
...
platform-admin/src/main/java/com/platform/service/AdvertisementItemService.java
浏览文件 @
1c00243f
package
com
.
platform
.
service
;
import
com.platform.entity.AdvertisementItemEntity
;
import
io.swagger.models.auth.In
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.List
;
...
...
@@ -75,4 +76,8 @@ public interface AdvertisementItemService {
int
deleteByItem
(
String
itemId
,
String
adId
);
int
setItemTop
(
String
itemId
,
String
adId
);
int
updateAdvertisementItem
(
@RequestParam
Map
<
String
,
Object
>
map
);
Integer
getAdSort
(
Map
<
String
,
Object
>
map
);
}
platform-admin/src/main/java/com/platform/service/impl/AdvertisementItemServiceImpl.java
浏览文件 @
1c00243f
...
...
@@ -4,13 +4,16 @@ import com.platform.dao.AdvertisementItemDao;
import
com.platform.entity.AdvertisementItemEntity
;
import
com.platform.service.AdvertisementItemService
;
import
com.platform.utils.IdUtil
;
import
io.swagger.models.auth.In
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.locks.ReentrantLock
;
/**
* Service实现类
...
...
@@ -23,6 +26,8 @@ public class AdvertisementItemServiceImpl implements AdvertisementItemService {
@Autowired
private
AdvertisementItemDao
advertisementItemDao
;
final
ReentrantLock
lock
=
new
ReentrantLock
();
@Override
public
AdvertisementItemEntity
queryObject
(
String
adId
)
{
return
advertisementItemDao
.
queryObject
(
adId
);
...
...
@@ -40,9 +45,14 @@ public class AdvertisementItemServiceImpl implements AdvertisementItemService {
@Override
public
int
save
(
AdvertisementItemEntity
advertisementItem
)
{
advertisementItem
.
setIsTop
(
0
);
advertisementItem
.
setSort
(
0
);
return
advertisementItemDao
.
save
(
advertisementItem
);
// advertisementItem.setIsTop(0);
lock
.
lock
();
int
maxSort
=
advertisementItemDao
.
getMaxSort
(
advertisementItem
.
getAdId
());
advertisementItem
.
setSort
(++
maxSort
);
advertisementItem
.
setCreateTime
(
new
Date
());
int
res
=
advertisementItemDao
.
save
(
advertisementItem
);
lock
.
unlock
();
return
res
;
}
@Override
...
...
@@ -90,7 +100,7 @@ public class AdvertisementItemServiceImpl implements AdvertisementItemService {
if
(
count
>=
60
)
{
return
-
1
;
}
int
maxSort
=
advertisementItemDao
.
getMaxSort
();
int
maxSort
=
advertisementItemDao
.
getMaxSort
(
null
);
byId
.
setSort
(++
maxSort
);
byId
.
setIsTop
(
1
);
}
else
{
...
...
@@ -100,4 +110,73 @@ public class AdvertisementItemServiceImpl implements AdvertisementItemService {
}
return
advertisementItemDao
.
updateAdItem
(
byId
);
}
//商品排序需求
//1、要更改的序号与原序号相同,不做处理
//2、要更改的序号没被商品占有,直接修改序号
//3、将序号调至后面
//4、将序号调至前面
@Override
public
int
updateAdvertisementItem
(
Map
<
String
,
Object
>
map
)
{
int
res
=
0
;
String
itemId
=
map
.
get
(
"itemId"
).
toString
();
String
adId
=
map
.
get
(
"adId"
).
toString
();
String
sort
=
map
.
get
(
"sort"
).
toString
();
Integer
itemSort
=
Integer
.
parseInt
(
sort
);
if
(
itemId
==
null
||
itemId
==
""
)
{
return
res
;
}
if
(
adId
==
null
||
adId
==
""
)
{
return
res
;
}
if
(
sort
==
null
||
sort
==
""
)
{
return
res
;
}
AdvertisementItemEntity
byId
=
advertisementItemDao
.
getAdItemById
(
itemId
,
adId
);
//情况1
String
firstSort
=
String
.
valueOf
(
byId
.
getSort
());
if
(
sort
.
equals
(
firstSort
))
{
return
res
;
}
//情况2
int
count
=
advertisementItemDao
.
existItemSort
(
adId
,
itemSort
);
if
(
count
==
0
)
{
byId
.
setSort
(
itemSort
);
res
=
advertisementItemDao
.
updateAdItem
(
byId
);
}
else
{
//要更换的序号被占有
//情况3
if
(
byId
.
getSort
()
<
itemSort
)
{
}
else
{
//情况4
}
}
return
res
;
}
@Override
public
Integer
getAdSort
(
Map
<
String
,
Object
>
map
)
{
String
itemId
=
map
.
get
(
"itemId"
).
toString
();
String
adId
=
map
.
get
(
"adId"
).
toString
();
if
(
itemId
==
null
||
itemId
==
""
)
{
return
null
;
}
if
(
adId
==
null
||
adId
==
""
)
{
return
null
;
}
AdvertisementItemEntity
byId
=
advertisementItemDao
.
getAdItemById
(
itemId
,
adId
);
if
(
byId
!=
null
)
{
Integer
sort
=
byId
.
getSort
();
if
(
sort
!=
null
)
{
return
byId
.
getSort
();
}
}
return
0
;
}
}
platform-admin/src/main/resources/com/platform/dao/AdvertisementItemDao.xml
浏览文件 @
1c00243f
...
...
@@ -8,6 +8,7 @@
<result
property=
"itemId"
column=
"item_id"
/>
<result
property=
"isTop"
column=
"is_top"
/>
<result
property=
"sort"
column=
"sort"
/>
<result
property=
"createTime"
column=
"create_time"
/>
</resultMap>
<select
id=
"queryObject"
resultType=
"com.platform.entity.AdvertisementItemEntity"
>
...
...
@@ -15,7 +16,8 @@
`ad_id`,
`item_id`,
`is_top`,
`sort`
`sort`,
`create_time`
from advertisement_item
where ad_id = #{id}
</select>
...
...
@@ -25,12 +27,18 @@
`ad_id`,
`item_id`,
`is_top`,
`sort`
`sort`,
`create_time`
from advertisement_item
where ad_id = #{adId}
and item_id=#{itemId}
</select>
<select
id=
"existItemSort"
resultType=
"int"
>
select count(1) from advertisement_item where ad_id = #{adId} and sort=#{sort}
</select>
<select
id=
"getAdItemCount"
resultType=
"int"
>
select count(1) from advertisement_item where ad_id = #{adId}
<if
test=
"itemId != null and itemId.trim() != ''"
>
...
...
@@ -43,7 +51,10 @@
</update>
<select
id=
"getMaxSort"
resultType=
"int"
>
select max(sort) from advertisement_item
select IFNULL(max(sort),0) from advertisement_item
<if
test=
"adId != null and adId.trim() != ''"
>
where ad_id=#{adId}
</if>
</select>
<delete
id=
"deleteByItem"
>
...
...
@@ -55,7 +66,8 @@
`ad_id`,
`item_id`,
`is_top`,
`sort`
`sort`,
`create_time`
from advertisement_item
WHERE 1=1
<if
test=
"name != null and name.trim() != ''"
>
...
...
@@ -87,12 +99,14 @@
`ad_id`,
`item_id`,
`is_top`,
`sort`)
`sort`,
`create_time`)
values(
#{adId},
#{itemId},
#{isTop},
#{sort})
#{sort},
#{createTime})
</insert>
<update
id=
"update"
parameterType=
"com.platform.entity.AdvertisementItemEntity"
>
...
...
@@ -100,7 +114,8 @@
<set>
<if
test=
"itemId != null"
>
`item_id` = #{itemId},
</if>
<if
test=
"isTop != null"
>
`is_top` = #{isTop},
</if>
<if
test=
"sort != null"
>
`sort` = #{sort}
</if>
<if
test=
"sort != null"
>
`sort` = #{sort},
</if>
<if
test=
"createTime != null"
>
`create_time` = #{createTime}
</if>
</set>
where ad_id = #{adId}
</update>
...
...
platform-admin/src/main/resources/com/platform/dao/TbCfStationItemDao.xml
浏览文件 @
1c00243f
...
...
@@ -95,14 +95,14 @@
t.goodstwotype_title title,
o.goodstype_title goodtype,
a.is_top,
a.sort
a.sort
itemSort
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 de
sc
where a.ad_id=#{adId}
order by
itemSort a
sc
<if
test=
"offset != null and limit != null"
>
limit #{offset}, #{limit}
</if>
...
...
platform-admin/src/main/webapp/WEB-INF/page/sys/advertisement.html
浏览文件 @
1c00243f
...
...
@@ -125,7 +125,7 @@
<Form-item
label=
"状态"
prop=
"status"
>
<!--<i-input v-model="advertisement.status" placeholder="状态" style="width: 800px"/>-->
<i-select
v-model=
"advertisement.status"
placeholder=
"请选择"
style=
"width: 800px"
/>
<i-option
v-for=
"v in versionList"
:value=
"v.value"
>
{{v.label}}
</i-option>
<i-option
v-for=
"v in versionList"
:value=
"v.value"
>
{{v.label}}
</i-option>
</i-select>
</Form-item>
<!--<Form-item label="banner图" prop="picture">
...
...
@@ -288,6 +288,18 @@
</Form-item>
</i-form>
</Card>
<Modal
v-model=
"modal1"
title=
"商品排序"
@
on-ok=
"deal"
width=
"600px"
@
on-cancel=
"cancel"
>
<i-form
ref=
"formValidate"
:model=
"advertisement"
:rules=
"ruleValidate"
:label-width=
"80"
>
<Form-item
label=
"序号"
prop=
"sort"
>
<i-input
v-model=
"sort"
placeholder=
"序号"
style=
"width: 160px"
/>
</Form-item>
</i-form>
</Modal>
</div>
<script
src=
"${rc.contextPath}/js/sys/advertisement.js?_${date.systemTime}"
></script>
...
...
platform-admin/src/main/webapp/js/sys/advertisement.js
浏览文件 @
1c00243f
...
...
@@ -18,6 +18,9 @@ $(function () {
let
vm
=
new
Vue
({
el
:
'#rrapp'
,
data
:
{
itemId
:
0
,
modal1
:
false
,
sort
:
''
,
versionList
:
[
{
value
:
1
,
...
...
@@ -130,6 +133,44 @@ let vm = new Vue({
}
},
methods
:
{
sortItem
(
e
)
{
let
id
=
getSelectedRow
(
"#jqGrid"
);
vm
.
modal1
=
true
;
vm
.
itemId
=
e
;
Ajax
.
request
({
url
:
"../advertisementitem/getAdSort?itemId="
+
e
+
'&adId='
+
id
,
type
:
"POST"
,
contentType
:
"application/json"
,
successCallback
:
function
(
res
)
{
vm
.
sort
=
res
.
sort
}
});
},
deal
()
{
let
id
=
getSelectedRow
(
"#jqGrid"
);
let
itemSort
;
console
.
log
(
'商品ID'
,
vm
.
itemId
)
console
.
log
(
'广告ID'
,
id
)
itemSort
=
parseInt
(
vm
.
sort
);
console
.
log
(
'序号'
,
itemSort
)
Ajax
.
request
({
url
:
"../advertisementitem/updateAdvertisementItem?itemId="
+
vm
.
itemId
+
'&adId='
+
id
+
'&sort='
+
vm
.
sort
,
type
:
"POST"
,
contentType
:
"application/json"
,
successCallback
:
function
()
{
alert
(
'操作成功'
,
function
(
index
)
{
vm
.
btn_Search
(
id
);
vm
.
modal1
=
false
;
});
}
});
},
cancel
()
{
vm
.
modal1
=
false
;
},
delItem
(
itemId
)
{
let
id
=
getSelectedRow
(
"#jqGrid"
);
confirm
(
'确定要删除选中的记录?'
,
function
()
{
...
...
@@ -255,6 +296,7 @@ let vm = new Vue({
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
},
...
...
@@ -269,18 +311,16 @@ let vm = new Vue({
{
label
:
'商品二级分类'
,
name
:
'title'
,
index
:
'title'
,
width
:
120
},
{
label
:
'商品品名'
,
name
:
'dname'
,
index
:
'itemDescritionId'
,
width
:
120
},
{
label
:
'操作'
,
index
:
'operate'
,
width
:
120
,
formatter
:
function
(
value
,
grid
,
rows
)
{
label
:
'操作'
,
index
:
'operate'
,
width
:
160
,
formatter
:
function
(
value
,
grid
,
rows
)
{
if
(
rows
.
isTop
==
1
)
{
return
'<span class="label label-danger pointer" onclick="vm.itemTop(
\'
'
+
rows
.
itemId
+
'
\'
)">取消置顶</span> '
+
'<span class="label label-info pointer" onclick="vm.delItem(
\'
'
+
rows
.
itemId
+
'
\'
)">移除</span> '
}
return
'<span class="label label-info pointer" onclick="vm.itemTop(
\'
'
+
rows
.
itemId
+
'
\'
)">置顶</span> '
+
'<span class="label label-info pointer" onclick="vm.delItem(
\'
'
+
rows
.
itemId
+
'
\'
)">移除</span> '
return
'<span class="label label-info pointer" onclick="vm.delItem(
\'
'
+
rows
.
itemId
+
'
\'
)">移除</span> '
+
'<span class="label label-info pointer" onclick="vm.sortItem(
\'
'
+
rows
.
itemId
+
'
\'
)">排序</span> '
}
}
}
// beforeSelectRow: beforeSelectRow,
],
// beforeSelectRow: beforeSelectRow,
multiboxonly
:
true
});
});
vm
.
btn_Search
(
id
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论