Commit 634b467b684bc2a8b14ec1d35a9e9715c1304c18
1 parent
6d172931
Exists in
master
渠道商后台
Showing
6 changed files
with
115 additions
and
1 deletions
Show diff stats
src/main/java/com/sincere/wechatbusiness/controller/ChannelController.java
| @@ -66,6 +66,22 @@ public class ChannelController { | @@ -66,6 +66,22 @@ public class ChannelController { | ||
| 66 | return result; | 66 | return result; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | + @RequestMapping(value="GetAreaList",method = RequestMethod.POST) | ||
| 70 | + @ApiOperation(value = "获取省市") | ||
| 71 | + public BaseDto<List<Area>> GetAreaList(){ | ||
| 72 | + BaseDto<List<Area>> result=new BaseDto<>(); | ||
| 73 | + result.setData(channelService.getAreaList()); | ||
| 74 | + return result; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + @RequestMapping(value = "GetTemplateList",method = RequestMethod.POST) | ||
| 78 | + @ApiOperation(value = "获取模板库列表") | ||
| 79 | + public BaseDto<List<Template>> GetTemplateList(){ | ||
| 80 | + BaseDto<List<Template>> result=new BaseDto<>(); | ||
| 81 | + result.setData(channelService.getTemplateList()); | ||
| 82 | + return result; | ||
| 83 | + } | ||
| 84 | + | ||
| 69 | @RequestMapping(value = "AddChannel",method = RequestMethod.POST) | 85 | @RequestMapping(value = "AddChannel",method = RequestMethod.POST) |
| 70 | @ApiOperation(value = "新增渠道商") | 86 | @ApiOperation(value = "新增渠道商") |
| 71 | public BaseDto AddChannel(@RequestBody Channel channel){ | 87 | public BaseDto AddChannel(@RequestBody Channel channel){ |
| @@ -79,6 +95,14 @@ public class ChannelController { | @@ -79,6 +95,14 @@ public class ChannelController { | ||
| 79 | return new BaseDto(); | 95 | return new BaseDto(); |
| 80 | } | 96 | } |
| 81 | 97 | ||
| 98 | + @RequestMapping(value = "GetChannelProductList",method = RequestMethod.GET) | ||
| 99 | + @ApiOperation(value = "获取渠道商代理商品列表") | ||
| 100 | + public BaseDto<List<ChannelProduct>> GetChannelProductList(int id){ | ||
| 101 | + BaseDto<List<ChannelProduct>> result=new BaseDto<>(); | ||
| 102 | + result.setData(channelProductService.getList(id)); | ||
| 103 | + return result; | ||
| 104 | + } | ||
| 105 | + | ||
| 82 | @RequestMapping(value = "GetChannelDetail",method = RequestMethod.GET) | 106 | @RequestMapping(value = "GetChannelDetail",method = RequestMethod.GET) |
| 83 | @ApiOperation(value = "获取渠道商详情") | 107 | @ApiOperation(value = "获取渠道商详情") |
| 84 | public BaseDto<Channel> GetChannelDetail(int id){ | 108 | public BaseDto<Channel> GetChannelDetail(int id){ |
| @@ -240,7 +264,7 @@ public class ChannelController { | @@ -240,7 +264,7 @@ public class ChannelController { | ||
| 240 | } | 264 | } |
| 241 | // 定义 BufferedReader输入流来读取URL的响应 | 265 | // 定义 BufferedReader输入流来读取URL的响应 |
| 242 | in = new BufferedReader(new InputStreamReader( | 266 | in = new BufferedReader(new InputStreamReader( |
| 243 | - connection.getInputStream())); | 267 | + connection.getInputStream(),"UTF-8")); |
| 244 | String line; | 268 | String line; |
| 245 | while ((line = in.readLine()) != null) { | 269 | while ((line = in.readLine()) != null) { |
| 246 | result += line; | 270 | result += line; |
src/main/java/com/sincere/wechatbusiness/mapper/ChannelMapper.java
| 1 | package com.sincere.wechatbusiness.mapper; | 1 | package com.sincere.wechatbusiness.mapper; |
| 2 | 2 | ||
| 3 | +import com.sincere.wechatbusiness.model.Area; | ||
| 3 | import com.sincere.wechatbusiness.model.Channel; | 4 | import com.sincere.wechatbusiness.model.Channel; |
| 5 | +import com.sincere.wechatbusiness.model.Template; | ||
| 4 | 6 | ||
| 5 | import java.util.List; | 7 | import java.util.List; |
| 6 | 8 | ||
| @@ -16,4 +18,12 @@ public interface ChannelMapper { | @@ -16,4 +18,12 @@ public interface ChannelMapper { | ||
| 16 | int update(Channel channel); | 18 | int update(Channel channel); |
| 17 | 19 | ||
| 18 | int deleteChannel(int id); | 20 | int deleteChannel(int id); |
| 21 | + | ||
| 22 | + List<Area> getProvince(); | ||
| 23 | + | ||
| 24 | + List<Area> getCity(String areaCode); | ||
| 25 | + | ||
| 26 | + List<Area> getArea(String areaCode); | ||
| 27 | + | ||
| 28 | + List<Template> getTemplateList(); | ||
| 19 | } | 29 | } |
src/main/java/com/sincere/wechatbusiness/model/Area.java
0 → 100644
| @@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
| 1 | +package com.sincere.wechatbusiness.model; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | + | ||
| 5 | +public class Area { | ||
| 6 | + private String value; | ||
| 7 | + | ||
| 8 | + private String label; | ||
| 9 | + | ||
| 10 | + private List<Area> children; | ||
| 11 | + | ||
| 12 | + public String getValue(){return value;} | ||
| 13 | + | ||
| 14 | + public void setValue(String value){this.value=value;} | ||
| 15 | + | ||
| 16 | + public String getLabel(){return label;} | ||
| 17 | + | ||
| 18 | + public void setLabel(String label){this.label=label;} | ||
| 19 | + | ||
| 20 | + public List<Area> getChildren(){return children;} | ||
| 21 | + | ||
| 22 | + public void setChildren(List<Area> children){this.children=children;} | ||
| 23 | +} |
src/main/java/com/sincere/wechatbusiness/service/ChannelService.java
| 1 | package com.sincere.wechatbusiness.service; | 1 | package com.sincere.wechatbusiness.service; |
| 2 | 2 | ||
| 3 | +import com.sincere.wechatbusiness.model.Area; | ||
| 3 | import com.sincere.wechatbusiness.model.Channel; | 4 | import com.sincere.wechatbusiness.model.Channel; |
| 5 | +import com.sincere.wechatbusiness.model.Template; | ||
| 4 | import com.sincere.wechatbusiness.utils.Page; | 6 | import com.sincere.wechatbusiness.utils.Page; |
| 5 | 7 | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 6 | public interface ChannelService { | 10 | public interface ChannelService { |
| 7 | Page<Channel> getList(Channel channel, int page, int pageSize); | 11 | Page<Channel> getList(Channel channel, int page, int pageSize); |
| 8 | 12 | ||
| @@ -13,4 +17,8 @@ public interface ChannelService { | @@ -13,4 +17,8 @@ public interface ChannelService { | ||
| 13 | int update(Channel channel); | 17 | int update(Channel channel); |
| 14 | 18 | ||
| 15 | int deleteChannel(int id); | 19 | int deleteChannel(int id); |
| 20 | + | ||
| 21 | + List<Area> getAreaList(); | ||
| 22 | + | ||
| 23 | + List<Template> getTemplateList(); | ||
| 16 | } | 24 | } |
src/main/java/com/sincere/wechatbusiness/service/impl/ChannelServiceImpl.java
| @@ -2,7 +2,9 @@ package com.sincere.wechatbusiness.service.impl; | @@ -2,7 +2,9 @@ package com.sincere.wechatbusiness.service.impl; | ||
| 2 | 2 | ||
| 3 | import com.github.pagehelper.PageHelper; | 3 | import com.github.pagehelper.PageHelper; |
| 4 | import com.sincere.wechatbusiness.mapper.ChannelMapper; | 4 | import com.sincere.wechatbusiness.mapper.ChannelMapper; |
| 5 | +import com.sincere.wechatbusiness.model.Area; | ||
| 5 | import com.sincere.wechatbusiness.model.Channel; | 6 | import com.sincere.wechatbusiness.model.Channel; |
| 7 | +import com.sincere.wechatbusiness.model.Template; | ||
| 6 | import com.sincere.wechatbusiness.service.ChannelService; | 8 | import com.sincere.wechatbusiness.service.ChannelService; |
| 7 | import com.sincere.wechatbusiness.utils.Page; | 9 | import com.sincere.wechatbusiness.utils.Page; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -40,5 +42,23 @@ public class ChannelServiceImpl implements ChannelService { | @@ -40,5 +42,23 @@ public class ChannelServiceImpl implements ChannelService { | ||
| 40 | 42 | ||
| 41 | @Override | 43 | @Override |
| 42 | public int deleteChannel(int id){return channelMapper.deleteChannel(id);} | 44 | public int deleteChannel(int id){return channelMapper.deleteChannel(id);} |
| 45 | + | ||
| 46 | + @Override | ||
| 47 | + public List<Area> getAreaList(){ | ||
| 48 | + List<Area> areaList=channelMapper.getProvince(); | ||
| 49 | + for (Area area:areaList) | ||
| 50 | + { | ||
| 51 | + List<Area> areaList1=channelMapper.getCity(area.getValue()); | ||
| 52 | + for(Area area1:areaList1) | ||
| 53 | + { | ||
| 54 | + area1.setChildren(channelMapper.getArea(area1.getValue())); | ||
| 55 | + } | ||
| 56 | + area.setChildren(areaList1); | ||
| 57 | + } | ||
| 58 | + return areaList; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @Override | ||
| 62 | + public List<Template> getTemplateList(){return channelMapper.getTemplateList();} | ||
| 43 | } | 63 | } |
| 44 | 64 |
src/main/resources/mapper/ChannelMapper.xml
| @@ -16,6 +16,19 @@ | @@ -16,6 +16,19 @@ | ||
| 16 | <result column="city_code" jdbcType="VARCHAR" property="cityCode" /> | 16 | <result column="city_code" jdbcType="VARCHAR" property="cityCode" /> |
| 17 | </resultMap> | 17 | </resultMap> |
| 18 | 18 | ||
| 19 | + <resultMap id="AreaMap" type="com.sincere.wechatbusiness.model.Area"> | ||
| 20 | + <result column="value" jdbcType="VARCHAR" property="value" /> | ||
| 21 | + <result column="label" jdbcType="VARCHAR" property="label" /> | ||
| 22 | + </resultMap> | ||
| 23 | + | ||
| 24 | + <resultMap id="TemplateMap" type="com.sincere.wechatbusiness.model.Template"> | ||
| 25 | + <id column="id" jdbcType="INTEGER" property="id" /> | ||
| 26 | + <result column="title" jdbcType="VARCHAR" property="title" /> | ||
| 27 | + <result column="img_url" jdbcType="VARCHAR" property="imgUrl" /> | ||
| 28 | + <result column="state" jdbcType="INTEGER" property="state"/> | ||
| 29 | + <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | ||
| 30 | + </resultMap> | ||
| 31 | + | ||
| 19 | <select id="getList" parameterType="com.sincere.wechatbusiness.model.Channel" resultMap="ChannelMap"> | 32 | <select id="getList" parameterType="com.sincere.wechatbusiness.model.Channel" resultMap="ChannelMap"> |
| 20 | select *,(select count(0) from channel_product where channelId=c.id and state=1) as product_count, | 33 | select *,(select count(0) from channel_product where channelId=c.id and state=1) as product_count, |
| 21 | (select title from template where id=c.templateId) as template_name from channel c | 34 | (select title from template where id=c.templateId) as template_name from channel c |
| @@ -79,4 +92,20 @@ | @@ -79,4 +92,20 @@ | ||
| 79 | update channel set state=0 where id = #{id} | 92 | update channel set state=0 where id = #{id} |
| 80 | update channel_product set state=0 where channelId = #{id} | 93 | update channel_product set state=0 where channelId = #{id} |
| 81 | </update> | 94 | </update> |
| 95 | + | ||
| 96 | + <select id="getProvince" resultMap="AreaMap"> | ||
| 97 | + select area_code as value,area_name as label from sys_area where area_code like '__' | ||
| 98 | + </select> | ||
| 99 | + | ||
| 100 | + <select id="getCity" parameterType="java.lang.String" resultMap="AreaMap"> | ||
| 101 | + select area_code as value,area_name as label from sys_area where area_code like '____' and area_code like #{areaCode}+'%' | ||
| 102 | + </select> | ||
| 103 | + | ||
| 104 | + <select id="getArea" parameterType="java.lang.String" resultMap="AreaMap"> | ||
| 105 | + select area_code as value,area_name as label from sys_area where area_code like '______' and area_code like #{areaCode}+'%' | ||
| 106 | + </select> | ||
| 107 | + | ||
| 108 | + <select id="getTemplateList" resultMap="TemplateMap"> | ||
| 109 | + select * from template where state=1 order by create_time | ||
| 110 | + </select> | ||
| 82 | </mapper> | 111 | </mapper> |
| 83 | \ No newline at end of file | 112 | \ No newline at end of file |