Commit 4086b7de3badffdb019b5d1e199d4eccfe4468da
1 parent
845f9c99
Exists in
master
1
Showing
16 changed files
with
270 additions
and
2 deletions
Show diff stats
src/main/java/com/sincere/wechatbusiness/controller/ChannelController.java
... | ... | @@ -6,6 +6,7 @@ import com.alibaba.fastjson.TypeReference; |
6 | 6 | import com.fasterxml.jackson.databind.ser.Serializers; |
7 | 7 | import com.sincere.wechatbusiness.dto.BaseDto; |
8 | 8 | import com.sincere.wechatbusiness.dto.ChannelDto; |
9 | +import com.sincere.wechatbusiness.dto.CopyDto; | |
9 | 10 | import com.sincere.wechatbusiness.logs.LogName; |
10 | 11 | import com.sincere.wechatbusiness.logs.LoggerUtils; |
11 | 12 | import com.sincere.wechatbusiness.model.*; |
... | ... | @@ -54,11 +55,67 @@ public class ChannelController { |
54 | 55 | @Autowired |
55 | 56 | AgentService agentService; |
56 | 57 | |
58 | + @Autowired | |
59 | + PageViewService pageViewService ; | |
60 | + | |
57 | 61 | private static final Logger log_channel = LoggerUtils.Logger(LogName.channel); |
58 | 62 | |
59 | 63 | // private String domain="https://mytest.myjxt.com:51314"; |
60 | 64 | private String domain="https://proxy.shunzhi.net:51314"; |
61 | 65 | |
66 | + | |
67 | + @RequestMapping(value = "copyChannel",method = RequestMethod.POST) | |
68 | + @ApiOperation(value = "内容下发") | |
69 | + public BaseDto copyChannel(@RequestBody CopyDto copyDto){ | |
70 | + Channel channel = channelService.getDetail(copyDto.getSourceId()); | |
71 | + if(channel.getTemplateId() == 1){ | |
72 | + List<Banner> banners = bannerService.getList(copyDto.getSourceId()); | |
73 | + Attention attention = attentionService.getDetail(copyDto.getSourceId()); | |
74 | + List<Catalog> catalogs = catalogService.getList(copyDto.getSourceId()); | |
75 | + for(Integer channelId : copyDto.getTargetIdList()){ | |
76 | + for(Banner banner : banners){ | |
77 | + banner.setChannelId(channelId); | |
78 | + bannerService.copy(banner); | |
79 | + } | |
80 | + if(attention != null){ | |
81 | + attention.setChannelId(channelId); | |
82 | + attentionService.insert(attention); | |
83 | + } | |
84 | + for(Catalog catalog : catalogs){ | |
85 | + catalog.setChannelId(channelId); | |
86 | + catalogService.insert(catalog); | |
87 | + List<CatalogContent> list = catalogContentService.getList(catalog.getId()); | |
88 | + for(CatalogContent catalogContent : list){ | |
89 | + catalogContent.setCatalogId(catalog.getId()); | |
90 | + catalogContentService.insert(catalogContent); | |
91 | + } | |
92 | + } | |
93 | + } | |
94 | + }else if(channel.getTemplateId() == 2){ | |
95 | + List<Banner> banners = bannerService.getList(copyDto.getSourceId()); | |
96 | + List<BannerNext> bannerNexts = bannerService.getBannerNextList(copyDto.getSourceId()); | |
97 | + for(Integer channelId : copyDto.getTargetIdList()){ | |
98 | + for(Banner banner : banners){ | |
99 | + banner.setChannelId(channelId); | |
100 | + bannerService.copy(banner); | |
101 | + } | |
102 | + for(BannerNext bannerNext : bannerNexts){ | |
103 | + bannerNext.setChannelId(channelId); | |
104 | + bannerService.copyBannerNext(bannerNext); | |
105 | + } | |
106 | + } | |
107 | + } | |
108 | + return new BaseDto(); | |
109 | + } | |
110 | + | |
111 | + | |
112 | + @RequestMapping(value = "updateLook",method = RequestMethod.POST) | |
113 | + @ApiOperation(value = "增加浏览量") | |
114 | + public BaseDto updateLook(@RequestBody PageView pageView){ | |
115 | + pageViewService.updateLook(pageView); | |
116 | + return new BaseDto(); | |
117 | + } | |
118 | + | |
62 | 119 | @RequestMapping(value = "getBannerNextList",method = RequestMethod.GET) |
63 | 120 | @ApiOperation(value = "获取左右轮播图列表") |
64 | 121 | public BaseDto<List<BannerNext>> getBannerNextList(int channelId){ | ... | ... |
src/main/java/com/sincere/wechatbusiness/dto/CopyDto.java
0 → 100644
... | ... | @@ -0,0 +1,25 @@ |
1 | +package com.sincere.wechatbusiness.dto; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +public class CopyDto { | |
6 | + | |
7 | + private int sourceId ; | |
8 | + private List<Integer> targetIdList ; | |
9 | + | |
10 | + public int getSourceId() { | |
11 | + return sourceId; | |
12 | + } | |
13 | + | |
14 | + public void setSourceId(int sourceId) { | |
15 | + this.sourceId = sourceId; | |
16 | + } | |
17 | + | |
18 | + public List<Integer> getTargetIdList() { | |
19 | + return targetIdList; | |
20 | + } | |
21 | + | |
22 | + public void setTargetIdList(List<Integer> targetIdList) { | |
23 | + this.targetIdList = targetIdList; | |
24 | + } | |
25 | +} | ... | ... |
src/main/java/com/sincere/wechatbusiness/mapper/BannerMapper.java
src/main/java/com/sincere/wechatbusiness/mapper/BannerNextMapper.java
src/main/java/com/sincere/wechatbusiness/mapper/ChannelMapper.java
src/main/java/com/sincere/wechatbusiness/mapper/PageViewMapper.java
0 → 100644
... | ... | @@ -0,0 +1,12 @@ |
1 | +package com.sincere.wechatbusiness.mapper; | |
2 | + | |
3 | +import com.sincere.wechatbusiness.model.PageView; | |
4 | + | |
5 | +public interface PageViewMapper { | |
6 | + | |
7 | + int insert(PageView record); | |
8 | + | |
9 | + PageView getDetail(PageView pageView); | |
10 | + | |
11 | + int updateLook(PageView pageView); | |
12 | +} | |
0 | 13 | \ No newline at end of file | ... | ... |
src/main/java/com/sincere/wechatbusiness/model/PageView.java
0 → 100644
... | ... | @@ -0,0 +1,65 @@ |
1 | +package com.sincere.wechatbusiness.model; | |
2 | + | |
3 | +import java.util.Date; | |
4 | + | |
5 | +public class PageView { | |
6 | + private Integer id; | |
7 | + | |
8 | + private Integer channelId; | |
9 | + | |
10 | + private Integer agentId; | |
11 | + | |
12 | + private Integer channelProductId; | |
13 | + | |
14 | + private Integer lookNumber; | |
15 | + | |
16 | + private Date createTime; | |
17 | + | |
18 | + public Integer getId() { | |
19 | + return id; | |
20 | + } | |
21 | + | |
22 | + public void setId(Integer id) { | |
23 | + this.id = id; | |
24 | + } | |
25 | + | |
26 | + public Integer getChannelId() { | |
27 | + return channelId; | |
28 | + } | |
29 | + | |
30 | + public void setChannelId(Integer channelId) { | |
31 | + this.channelId = channelId; | |
32 | + } | |
33 | + | |
34 | + public Integer getAgentId() { | |
35 | + return agentId; | |
36 | + } | |
37 | + | |
38 | + public void setAgentId(Integer agentId) { | |
39 | + this.agentId = agentId; | |
40 | + } | |
41 | + | |
42 | + public Integer getChannelProductId() { | |
43 | + return channelProductId; | |
44 | + } | |
45 | + | |
46 | + public void setChannelProductId(Integer channelProductId) { | |
47 | + this.channelProductId = channelProductId; | |
48 | + } | |
49 | + | |
50 | + public Integer getLookNumber() { | |
51 | + return lookNumber; | |
52 | + } | |
53 | + | |
54 | + public void setLookNumber(Integer lookNumber) { | |
55 | + this.lookNumber = lookNumber; | |
56 | + } | |
57 | + | |
58 | + public Date getCreateTime() { | |
59 | + return createTime; | |
60 | + } | |
61 | + | |
62 | + public void setCreateTime(Date createTime) { | |
63 | + this.createTime = createTime; | |
64 | + } | |
65 | +} | |
0 | 66 | \ No newline at end of file | ... | ... |
src/main/java/com/sincere/wechatbusiness/service/BannerService.java
... | ... | @@ -10,6 +10,8 @@ public interface BannerService { |
10 | 10 | |
11 | 11 | int insert(Banner banner); |
12 | 12 | |
13 | + int copy(Banner banner); | |
14 | + | |
13 | 15 | int update(Banner banner); |
14 | 16 | |
15 | 17 | int deleteBanner(int id); |
... | ... | @@ -23,4 +25,6 @@ public interface BannerService { |
23 | 25 | |
24 | 26 | int update(BannerNext bannerNext); |
25 | 27 | |
28 | + int copyBannerNext(BannerNext bannerNext); | |
29 | + | |
26 | 30 | } | ... | ... |
src/main/java/com/sincere/wechatbusiness/service/PageViewService.java
0 → 100644
src/main/java/com/sincere/wechatbusiness/service/impl/BannerServiceImpl.java
... | ... | @@ -50,4 +50,14 @@ public class BannerServiceImpl implements BannerService { |
50 | 50 | public int update(BannerNext bannerNext) { |
51 | 51 | return bannerNextMapper.update(bannerNext); |
52 | 52 | } |
53 | + | |
54 | + @Override | |
55 | + public int copy(Banner banner) { | |
56 | + return bannerMapper.copy(banner); | |
57 | + } | |
58 | + | |
59 | + @Override | |
60 | + public int copyBannerNext(BannerNext bannerNext) { | |
61 | + return bannerNextMapper.copy(bannerNext); | |
62 | + } | |
53 | 63 | } | ... | ... |
src/main/java/com/sincere/wechatbusiness/service/impl/PageViewServiceImpl.java
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +package com.sincere.wechatbusiness.service.impl; | |
2 | + | |
3 | +import com.sincere.wechatbusiness.mapper.PageViewMapper; | |
4 | +import com.sincere.wechatbusiness.model.PageView; | |
5 | +import com.sincere.wechatbusiness.service.PageViewService; | |
6 | +import org.springframework.beans.factory.annotation.Autowired; | |
7 | +import org.springframework.stereotype.Service; | |
8 | + | |
9 | +@Service | |
10 | +public class PageViewServiceImpl implements PageViewService { | |
11 | + | |
12 | + @Autowired | |
13 | + PageViewMapper pageViewMapper ; | |
14 | + | |
15 | + @Override | |
16 | + public int updateLook(PageView pageView) { | |
17 | + PageView temp = pageViewMapper.getDetail(pageView); | |
18 | + if(temp != null){ | |
19 | + pageViewMapper.updateLook(pageView); | |
20 | + }else { | |
21 | + pageView.setLookNumber(1); | |
22 | + pageViewMapper.insert(pageView); | |
23 | + } | |
24 | + return 1; | |
25 | + } | |
26 | +} | ... | ... |
src/main/resources/mapper/BannerMapper.xml
... | ... | @@ -20,6 +20,12 @@ |
20 | 20 | ) |
21 | 21 | </insert> |
22 | 22 | |
23 | + <insert id="copy" parameterType="com.sincere.wechatbusiness.model.Banner"> | |
24 | + insert into banner (channelId, img_url,link_url,create_time) | |
25 | + values (#{channelId,jdbcType=INTEGER}, #{imgUrl,jdbcType=VARCHAR}, #{linkUrl,jdbcType=VARCHAR},#{createTime} | |
26 | + ) | |
27 | + </insert> | |
28 | + | |
23 | 29 | <update id="update" parameterType="com.sincere.wechatbusiness.model.Banner"> |
24 | 30 | update banner |
25 | 31 | <trim prefix="set" suffixOverrides=","> | ... | ... |
src/main/resources/mapper/BannerNextMapper.xml
... | ... | @@ -13,7 +13,7 @@ |
13 | 13 | </sql> |
14 | 14 | |
15 | 15 | <select id="getByChannel" parameterType="java.lang.Integer" resultMap="BaseResultMap"> |
16 | - select * from banner_next where channel_id = #{channelId} order by sort | |
16 | + select * from banner_next where channel_id = #{channelId} order by create_time | |
17 | 17 | </select> |
18 | 18 | |
19 | 19 | <update id="update" parameterType="com.sincere.wechatbusiness.model.BannerNext"> |
... | ... | @@ -45,6 +45,14 @@ |
45 | 45 | values ( #{imgUrl,jdbcType=VARCHAR}, #{channelId,jdbcType=INTEGER}, |
46 | 46 | getdate(), #{sort,jdbcType=INTEGER}) |
47 | 47 | </insert> |
48 | + | |
49 | + <insert id="copy" parameterType="com.sincere.wechatbusiness.model.BannerNext"> | |
50 | + insert into banner_next ( img_url, channel_id, | |
51 | + create_time, sort) | |
52 | + values ( #{imgUrl,jdbcType=VARCHAR}, #{channelId,jdbcType=INTEGER}, | |
53 | + #{createTime}, #{sort,jdbcType=INTEGER}) | |
54 | + </insert> | |
55 | + | |
48 | 56 | <insert id="insertSelective" parameterType="com.sincere.wechatbusiness.model.BannerNext"> |
49 | 57 | insert into banner_next |
50 | 58 | <trim prefix="(" suffix=")" suffixOverrides=","> | ... | ... |
src/main/resources/mapper/CatalogMapper.xml
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | select * from catalog where channelId=#{channelId} and sort=#{sort} and state=1 |
19 | 19 | </select> |
20 | 20 | |
21 | - <insert id="insert" parameterType="com.sincere.wechatbusiness.model.Catalog"> | |
21 | + <insert id="insert" parameterType="com.sincere.wechatbusiness.model.Catalog" useGeneratedKeys="true" keyProperty="id"> | |
22 | 22 | insert into catalog (channelId, name,sort) |
23 | 23 | values (#{channelId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER} |
24 | 24 | ) | ... | ... |
src/main/resources/mapper/ChannelMapper.xml
... | ... | @@ -65,6 +65,10 @@ |
65 | 65 | <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
66 | 66 | </resultMap> |
67 | 67 | |
68 | + <select id="get2List" resultMap="ChannelMap"> | |
69 | + select * from channel where templateId = 2 | |
70 | + </select> | |
71 | + | |
68 | 72 | <select id="getList" parameterType="com.sincere.wechatbusiness.model.Channel" resultMap="ChannelMap"> |
69 | 73 | select *,(select count(0) from channel_product where channelId=c.id and state=1) as product_count, |
70 | 74 | (select title from template where id=c.templateId) as template_name from channel c | ... | ... |
... | ... | @@ -0,0 +1,36 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
3 | +<mapper namespace="com.sincere.wechatbusiness.mapper.PageViewMapper"> | |
4 | + <resultMap id="BaseResultMap" type="com.sincere.wechatbusiness.model.PageView"> | |
5 | + <id column="id" jdbcType="INTEGER" property="id" /> | |
6 | + <result column="channel_id" jdbcType="INTEGER" property="channelId" /> | |
7 | + <result column="agent_id" jdbcType="INTEGER" property="agentId" /> | |
8 | + <result column="channel_product_id" jdbcType="INTEGER" property="channelProductId" /> | |
9 | + <result column="look_number" jdbcType="INTEGER" property="lookNumber" /> | |
10 | + <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | |
11 | + </resultMap> | |
12 | + <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | |
13 | + select * | |
14 | + from page_view | |
15 | + where id = #{id,jdbcType=INTEGER} | |
16 | + </select> | |
17 | + | |
18 | + <insert id="insert" parameterType="com.sincere.wechatbusiness.model.PageView"> | |
19 | + insert into page_view (channel_id, agent_id, | |
20 | + channel_product_id, look_number, create_time | |
21 | + ) | |
22 | + values ( #{channelId,jdbcType=INTEGER}, #{agentId,jdbcType=INTEGER}, | |
23 | + #{channelProductId,jdbcType=INTEGER}, #{lookNumber,jdbcType=INTEGER}, getdate() | |
24 | + ) | |
25 | + </insert> | |
26 | + | |
27 | + <select id="getDetail" parameterType="com.sincere.wechatbusiness.model.PageView" resultMap="BaseResultMap"> | |
28 | + select * from page_view | |
29 | + where channel_id = #{channelId} and agent_id = #{agentId} and channel_product_id = #{channelProductId} | |
30 | + </select> | |
31 | + | |
32 | + <update id="updateLook" parameterType="com.sincere.wechatbusiness.model.PageView"> | |
33 | + update page_view set look_number = look_number + 1 | |
34 | + where channel_id = #{channelId} and agent_id = #{agentId} and channel_product_id = #{channelProductId} | |
35 | + </update> | |
36 | +</mapper> | |
0 | 37 | \ No newline at end of file | ... | ... |