From e4e809bcafdb517fcc2c289dd78794b832a818f9 Mon Sep 17 00:00:00 2001 From: starlbb Date: Mon, 23 Mar 2020 23:00:03 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E9=80=86=E5=90=91=E5=B7=A5=E7=A8=8B?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=AF=B9=E5=BA=94=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- communityservice/pom.xml | 22 +++++++++++ .../woniu/controller/DynamicController.java | 38 ++++++++++++++----- .../src/main/resources/generatorConfig.xml | 29 ++++++++++++++ 3 files changed, 79 insertions(+), 10 deletions(-) create mode 100644 communityservice/src/main/resources/generatorConfig.xml diff --git a/communityservice/pom.xml b/communityservice/pom.xml index 6e75395..2fb8b72 100644 --- a/communityservice/pom.xml +++ b/communityservice/pom.xml @@ -88,6 +88,13 @@ 1.3.3 + + + com.alibaba + fastjson + 1.2.62 + + @@ -108,6 +115,21 @@ org.springframework.boot spring-boot-maven-plugin + + org.mybatis.generator + mybatis-generator-maven-plugin + 1.3.7 + + ${basedir}/src/main/resources/generatorConfig.xml + + + + mysql + mysql-connector-java + 5.1.47 + + + diff --git a/communityservice/src/main/java/com/woniu/controller/DynamicController.java b/communityservice/src/main/java/com/woniu/controller/DynamicController.java index c8d0d53..e78a59c 100644 --- a/communityservice/src/main/java/com/woniu/controller/DynamicController.java +++ b/communityservice/src/main/java/com/woniu/controller/DynamicController.java @@ -1,30 +1,38 @@ package com.woniu.controller; +import com.alibaba.fastjson.JSONArray; import com.woniu.result.CommonResult; +import com.woniu.service.DynamicService; import com.woniu.util.QiniuUploadUtil; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.Map; import java.util.UUID; @Controller @RequestMapping("/dynamic") public class DynamicController { + @Autowired + private DynamicService dynamicService; /** * 文件上传 - * @param file 文件数组 + * @param file 文件 * @return */ @PostMapping("/upload") @ResponseBody public CommonResult upload(MultipartFile file){ - System.out.println("_________________"); if(file==null){ return CommonResult.failed("请选择上传图片"); } @@ -34,9 +42,7 @@ public class DynamicController { //UUID获取文件名(自己编写) String fileName = UUID.randomUUID().toString(); String imgurl = new QiniuUploadUtil().upload(fileName, file.getBytes()); -// System.out.println(imgurl); -// Map map=new HashMap(); -// map.put("src",imgurl); + //返回图片路径 return CommonResult.success(imgurl); } catch (IOException e) { e.printStackTrace(); @@ -44,11 +50,23 @@ public class DynamicController { } } - @RequestMapping("/test") + @PostMapping("/save") @ResponseBody - public String test(Integer aa){ - System.out.println(aa); - System.out.println("*******"); - return "tttt"; + public CommonResult save(@RequestBody String dynamic){ + try { + //转化成真实的值 + String act = URLDecoder.decode(dynamic,"UTF-8"); + //没有上传图片时参数多了一个 = ,不知道为啥 + act = act.replace("=",""); + //将数据转为map + Map map = JSONArray.parseObject(act); + //保存动态到数据库 + dynamicService.save(map); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return CommonResult.success(); } + } diff --git a/communityservice/src/main/resources/generatorConfig.xml b/communityservice/src/main/resources/generatorConfig.xml new file mode 100644 index 0000000..4877334 --- /dev/null +++ b/communityservice/src/main/resources/generatorConfig.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + +
+ +
+
\ No newline at end of file -- Gitee From c655e03663087376911e3572ca5682501615b066 Mon Sep 17 00:00:00 2001 From: starlbb Date: Tue, 24 Mar 2020 00:19:43 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/woniu/CommunityserviceApplication.java | 2 ++ .../java/com/woniu/controller/DynamicController.java | 4 ++-- communityservice/src/main/resources/application.yml | 2 +- .../src/main/resources/generatorConfig.xml | 12 +++++++----- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/communityservice/src/main/java/com/woniu/CommunityserviceApplication.java b/communityservice/src/main/java/com/woniu/CommunityserviceApplication.java index fa89363..6c5880e 100644 --- a/communityservice/src/main/java/com/woniu/CommunityserviceApplication.java +++ b/communityservice/src/main/java/com/woniu/CommunityserviceApplication.java @@ -1,10 +1,12 @@ package com.woniu; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; @SpringBootApplication +@MapperScan(value = "com.woniu.dao") @EnableEurekaClient //开启eureka客户端 public class CommunityserviceApplication { diff --git a/communityservice/src/main/java/com/woniu/controller/DynamicController.java b/communityservice/src/main/java/com/woniu/controller/DynamicController.java index e78a59c..bc2b3fe 100644 --- a/communityservice/src/main/java/com/woniu/controller/DynamicController.java +++ b/communityservice/src/main/java/com/woniu/controller/DynamicController.java @@ -62,11 +62,11 @@ public class DynamicController { Map map = JSONArray.parseObject(act); //保存动态到数据库 dynamicService.save(map); + return CommonResult.success("发布成功"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); + return CommonResult.failed("操作失败"); } - - return CommonResult.success(); } } diff --git a/communityservice/src/main/resources/application.yml b/communityservice/src/main/resources/application.yml index f5f5700..3bdff46 100644 --- a/communityservice/src/main/resources/application.yml +++ b/communityservice/src/main/resources/application.yml @@ -2,7 +2,7 @@ spring: datasource: password: 20200322 username: develop - url: jdbc:mysql://106.12.148.100:3307/happycommunity + url: jdbc:mysql://106.12.148.100:3307/happycommunity?useUnicode=true&characterEncoding=utf-8&useSSL=false driver-class-name: com.mysql.jdbc.Driver jackson: time-zone: GMT+8 diff --git a/communityservice/src/main/resources/generatorConfig.xml b/communityservice/src/main/resources/generatorConfig.xml index 4877334..d735ae9 100644 --- a/communityservice/src/main/resources/generatorConfig.xml +++ b/communityservice/src/main/resources/generatorConfig.xml @@ -19,11 +19,13 @@
+ enableDeleteByExample="false" + enableUpdateByExample="false" + enableSelectByExample="false" + enableCountByExample="false" + selectByExampleQueryId="false"> + + \ No newline at end of file -- Gitee From a9acde356ebc2f2654f4d90331c8b7b7bb286870 Mon Sep 17 00:00:00 2001 From: starlbb Date: Tue, 24 Mar 2020 00:21:10 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E9=80=86=E5=90=91=E5=B7=A5=E7=A8=8B?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=9A=84=E7=B1=BB=E4=BB=A5=E5=8F=8Aservice?= =?UTF-8?q?=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/woniu/dao/DynamicMapper.java | 19 +++ .../src/main/java/com/woniu/pojo/Dynamic.java | 89 ++++++++++++ .../com/woniu/service/DynamicService.java | 12 ++ .../service/impl/DynamicServiceImpl.java | 34 +++++ .../main/resources/mapper/DynamicMapper.xml | 133 ++++++++++++++++++ 5 files changed, 287 insertions(+) create mode 100644 communityservice/src/main/java/com/woniu/dao/DynamicMapper.java create mode 100644 communityservice/src/main/java/com/woniu/pojo/Dynamic.java create mode 100644 communityservice/src/main/java/com/woniu/service/DynamicService.java create mode 100644 communityservice/src/main/java/com/woniu/service/impl/DynamicServiceImpl.java create mode 100644 communityservice/src/main/resources/mapper/DynamicMapper.xml diff --git a/communityservice/src/main/java/com/woniu/dao/DynamicMapper.java b/communityservice/src/main/java/com/woniu/dao/DynamicMapper.java new file mode 100644 index 0000000..66cac53 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/dao/DynamicMapper.java @@ -0,0 +1,19 @@ +package com.woniu.dao; + +import com.woniu.pojo.Dynamic; + +public interface DynamicMapper { + int deleteByPrimaryKey(Integer id); + + int insert(Dynamic record); + + int insertSelective(Dynamic record); + + Dynamic selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(Dynamic record); + + int updateByPrimaryKeyWithBLOBs(Dynamic record); + + int updateByPrimaryKey(Dynamic record); +} \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/pojo/Dynamic.java b/communityservice/src/main/java/com/woniu/pojo/Dynamic.java new file mode 100644 index 0000000..4b51942 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/pojo/Dynamic.java @@ -0,0 +1,89 @@ +package com.woniu.pojo; + +import lombok.Data; + +import java.util.Date; + +@Data +public class Dynamic { + private Integer id; + + private Integer cdUserId; + + private String cdPicPath; + + private Integer cdType; + + private Integer cdFavor; + + private Date cdTime; + + public Dynamic() { + } + public Dynamic(Integer cdUserId, String cdPicPath, Integer cdType, Integer cdFavor, Date cdTime, String cdContent) { + this.cdUserId = cdUserId; + this.cdPicPath = cdPicPath; + this.cdType = cdType; + this.cdFavor = cdFavor; + this.cdTime = cdTime; + this.cdContent = cdContent; + } + + private String cdContent; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getCdUserId() { + return cdUserId; + } + + public void setCdUserId(Integer cdUserId) { + this.cdUserId = cdUserId; + } + + public String getCdPicPath() { + return cdPicPath; + } + + public void setCdPicPath(String cdPicPath) { + this.cdPicPath = cdPicPath; + } + + public Integer getCdType() { + return cdType; + } + + public void setCdType(Integer cdType) { + this.cdType = cdType; + } + + public Integer getCdFavor() { + return cdFavor; + } + + public void setCdFavor(Integer cdFavor) { + this.cdFavor = cdFavor; + } + + public Date getCdTime() { + return cdTime; + } + + public void setCdTime(Date cdTime) { + this.cdTime = cdTime; + } + + public String getCdContent() { + return cdContent; + } + + public void setCdContent(String cdContent) { + this.cdContent = cdContent; + } +} \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/service/DynamicService.java b/communityservice/src/main/java/com/woniu/service/DynamicService.java new file mode 100644 index 0000000..de225b2 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/service/DynamicService.java @@ -0,0 +1,12 @@ +package com.woniu.service; + +import java.util.Map; + +public interface DynamicService { + + /** + * 保存动态 + * @param map 动态数据 + */ + Integer save(Map map); +} diff --git a/communityservice/src/main/java/com/woniu/service/impl/DynamicServiceImpl.java b/communityservice/src/main/java/com/woniu/service/impl/DynamicServiceImpl.java new file mode 100644 index 0000000..0d7c85d --- /dev/null +++ b/communityservice/src/main/java/com/woniu/service/impl/DynamicServiceImpl.java @@ -0,0 +1,34 @@ +package com.woniu.service.impl; + +import com.woniu.dao.DynamicMapper; +import com.woniu.pojo.Dynamic; +import com.woniu.service.DynamicService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.Map; + +@Service +public class DynamicServiceImpl implements DynamicService { + + @Autowired + private DynamicMapper dynamicMapper; + + /** + * 保存动态 + * @param map + */ + @Override + public Integer save(Map map) { + //构造一个新的动态实体 + Integer userId = Integer.valueOf(map.get("userId").toString()); + String picPath = String.valueOf(map.get("picPath")); + Integer type = Integer.valueOf(map.get("type").toString()); + Integer favor = Integer.valueOf(map.get("favor").toString()); + Date time = new Date(); + String content = String.valueOf(map.get("content")); + Dynamic dynamic = new Dynamic(userId,picPath,type,favor,time,content); + return dynamicMapper.insertSelective(dynamic); + } +} diff --git a/communityservice/src/main/resources/mapper/DynamicMapper.xml b/communityservice/src/main/resources/mapper/DynamicMapper.xml new file mode 100644 index 0000000..b99674f --- /dev/null +++ b/communityservice/src/main/resources/mapper/DynamicMapper.xml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + id, cd_user_id, cd_pic_path, cd_type, cd_favor, cd_time + + + cd_content + + + + delete from community_dynamic + where id = #{id,jdbcType=INTEGER} + + + insert into community_dynamic (id, cd_user_id, cd_pic_path, + cd_type, cd_favor, cd_time, + cd_content) + values (#{id,jdbcType=INTEGER}, #{cdUserId,jdbcType=INTEGER}, #{cdPicPath,jdbcType=VARCHAR}, + #{cdType,jdbcType=INTEGER}, #{cdFavor,jdbcType=INTEGER}, #{cdTime,jdbcType=DATE}, + #{cdContent,jdbcType=LONGVARCHAR}) + + + insert into community_dynamic + + + id, + + + cd_user_id, + + + cd_pic_path, + + + cd_type, + + + cd_favor, + + + cd_time, + + + cd_content, + + + + + #{id,jdbcType=INTEGER}, + + + #{cdUserId,jdbcType=INTEGER}, + + + #{cdPicPath,jdbcType=VARCHAR}, + + + #{cdType,jdbcType=INTEGER}, + + + #{cdFavor,jdbcType=INTEGER}, + + + #{cdTime,jdbcType=DATE}, + + + #{cdContent,jdbcType=LONGVARCHAR}, + + + + + update community_dynamic + + + cd_user_id = #{cdUserId,jdbcType=INTEGER}, + + + cd_pic_path = #{cdPicPath,jdbcType=VARCHAR}, + + + cd_type = #{cdType,jdbcType=INTEGER}, + + + cd_favor = #{cdFavor,jdbcType=INTEGER}, + + + cd_time = #{cdTime,jdbcType=DATE}, + + + cd_content = #{cdContent,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + update community_dynamic + set cd_user_id = #{cdUserId,jdbcType=INTEGER}, + cd_pic_path = #{cdPicPath,jdbcType=VARCHAR}, + cd_type = #{cdType,jdbcType=INTEGER}, + cd_favor = #{cdFavor,jdbcType=INTEGER}, + cd_time = #{cdTime,jdbcType=DATE}, + cd_content = #{cdContent,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=INTEGER} + + + update community_dynamic + set cd_user_id = #{cdUserId,jdbcType=INTEGER}, + cd_pic_path = #{cdPicPath,jdbcType=VARCHAR}, + cd_type = #{cdType,jdbcType=INTEGER}, + cd_favor = #{cdFavor,jdbcType=INTEGER}, + cd_time = #{cdTime,jdbcType=DATE} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file -- Gitee From d66882ecf7825e615fa1b13d656c92f2da7cb643 Mon Sep 17 00:00:00 2001 From: starlbb Date: Tue, 24 Mar 2020 11:59:26 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E9=A1=B5=E9=9D=A2=E5=B1=95=E7=A4=BA=E5=8F=8A?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E5=AD=98=E5=82=A8=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../woniu/controller/DynamicController.java | 2 +- .../java/com/woniu/dao/DynamicMapper.java | 19 --- .../src/main/java/com/woniu/pojo/Dynamic.java | 89 ------------ .../service/impl/DynamicServiceImpl.java | 3 +- .../src/main/resources/application.yml | 2 +- .../main/resources/mapper/DynamicMapper.xml | 133 ------------------ 6 files changed, 3 insertions(+), 245 deletions(-) delete mode 100644 communityservice/src/main/java/com/woniu/dao/DynamicMapper.java delete mode 100644 communityservice/src/main/java/com/woniu/pojo/Dynamic.java delete mode 100644 communityservice/src/main/resources/mapper/DynamicMapper.xml diff --git a/communityservice/src/main/java/com/woniu/controller/DynamicController.java b/communityservice/src/main/java/com/woniu/controller/DynamicController.java index bc2b3fe..7c14e9e 100644 --- a/communityservice/src/main/java/com/woniu/controller/DynamicController.java +++ b/communityservice/src/main/java/com/woniu/controller/DynamicController.java @@ -52,7 +52,7 @@ public class DynamicController { @PostMapping("/save") @ResponseBody - public CommonResult save(@RequestBody String dynamic){ + public CommonResult save(@RequestBody String dynamic){ try { //转化成真实的值 String act = URLDecoder.decode(dynamic,"UTF-8"); diff --git a/communityservice/src/main/java/com/woniu/dao/DynamicMapper.java b/communityservice/src/main/java/com/woniu/dao/DynamicMapper.java deleted file mode 100644 index 66cac53..0000000 --- a/communityservice/src/main/java/com/woniu/dao/DynamicMapper.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.woniu.dao; - -import com.woniu.pojo.Dynamic; - -public interface DynamicMapper { - int deleteByPrimaryKey(Integer id); - - int insert(Dynamic record); - - int insertSelective(Dynamic record); - - Dynamic selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(Dynamic record); - - int updateByPrimaryKeyWithBLOBs(Dynamic record); - - int updateByPrimaryKey(Dynamic record); -} \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/pojo/Dynamic.java b/communityservice/src/main/java/com/woniu/pojo/Dynamic.java deleted file mode 100644 index 4b51942..0000000 --- a/communityservice/src/main/java/com/woniu/pojo/Dynamic.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.woniu.pojo; - -import lombok.Data; - -import java.util.Date; - -@Data -public class Dynamic { - private Integer id; - - private Integer cdUserId; - - private String cdPicPath; - - private Integer cdType; - - private Integer cdFavor; - - private Date cdTime; - - public Dynamic() { - } - public Dynamic(Integer cdUserId, String cdPicPath, Integer cdType, Integer cdFavor, Date cdTime, String cdContent) { - this.cdUserId = cdUserId; - this.cdPicPath = cdPicPath; - this.cdType = cdType; - this.cdFavor = cdFavor; - this.cdTime = cdTime; - this.cdContent = cdContent; - } - - private String cdContent; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getCdUserId() { - return cdUserId; - } - - public void setCdUserId(Integer cdUserId) { - this.cdUserId = cdUserId; - } - - public String getCdPicPath() { - return cdPicPath; - } - - public void setCdPicPath(String cdPicPath) { - this.cdPicPath = cdPicPath; - } - - public Integer getCdType() { - return cdType; - } - - public void setCdType(Integer cdType) { - this.cdType = cdType; - } - - public Integer getCdFavor() { - return cdFavor; - } - - public void setCdFavor(Integer cdFavor) { - this.cdFavor = cdFavor; - } - - public Date getCdTime() { - return cdTime; - } - - public void setCdTime(Date cdTime) { - this.cdTime = cdTime; - } - - public String getCdContent() { - return cdContent; - } - - public void setCdContent(String cdContent) { - this.cdContent = cdContent; - } -} \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/service/impl/DynamicServiceImpl.java b/communityservice/src/main/java/com/woniu/service/impl/DynamicServiceImpl.java index 0d7c85d..e722bf8 100644 --- a/communityservice/src/main/java/com/woniu/service/impl/DynamicServiceImpl.java +++ b/communityservice/src/main/java/com/woniu/service/impl/DynamicServiceImpl.java @@ -26,9 +26,8 @@ public class DynamicServiceImpl implements DynamicService { String picPath = String.valueOf(map.get("picPath")); Integer type = Integer.valueOf(map.get("type").toString()); Integer favor = Integer.valueOf(map.get("favor").toString()); - Date time = new Date(); String content = String.valueOf(map.get("content")); - Dynamic dynamic = new Dynamic(userId,picPath,type,favor,time,content); + Dynamic dynamic = new Dynamic(userId,picPath,type,favor,new Date(),content); return dynamicMapper.insertSelective(dynamic); } } diff --git a/communityservice/src/main/resources/application.yml b/communityservice/src/main/resources/application.yml index 3bdff46..208eab9 100644 --- a/communityservice/src/main/resources/application.yml +++ b/communityservice/src/main/resources/application.yml @@ -2,7 +2,7 @@ spring: datasource: password: 20200322 username: develop - url: jdbc:mysql://106.12.148.100:3307/happycommunity?useUnicode=true&characterEncoding=utf-8&useSSL=false + url: jdbc:mysql://106.12.148.100:3307/happycommunity?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8 driver-class-name: com.mysql.jdbc.Driver jackson: time-zone: GMT+8 diff --git a/communityservice/src/main/resources/mapper/DynamicMapper.xml b/communityservice/src/main/resources/mapper/DynamicMapper.xml deleted file mode 100644 index b99674f..0000000 --- a/communityservice/src/main/resources/mapper/DynamicMapper.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - - - - - - - - - - - id, cd_user_id, cd_pic_path, cd_type, cd_favor, cd_time - - - cd_content - - - - delete from community_dynamic - where id = #{id,jdbcType=INTEGER} - - - insert into community_dynamic (id, cd_user_id, cd_pic_path, - cd_type, cd_favor, cd_time, - cd_content) - values (#{id,jdbcType=INTEGER}, #{cdUserId,jdbcType=INTEGER}, #{cdPicPath,jdbcType=VARCHAR}, - #{cdType,jdbcType=INTEGER}, #{cdFavor,jdbcType=INTEGER}, #{cdTime,jdbcType=DATE}, - #{cdContent,jdbcType=LONGVARCHAR}) - - - insert into community_dynamic - - - id, - - - cd_user_id, - - - cd_pic_path, - - - cd_type, - - - cd_favor, - - - cd_time, - - - cd_content, - - - - - #{id,jdbcType=INTEGER}, - - - #{cdUserId,jdbcType=INTEGER}, - - - #{cdPicPath,jdbcType=VARCHAR}, - - - #{cdType,jdbcType=INTEGER}, - - - #{cdFavor,jdbcType=INTEGER}, - - - #{cdTime,jdbcType=DATE}, - - - #{cdContent,jdbcType=LONGVARCHAR}, - - - - - update community_dynamic - - - cd_user_id = #{cdUserId,jdbcType=INTEGER}, - - - cd_pic_path = #{cdPicPath,jdbcType=VARCHAR}, - - - cd_type = #{cdType,jdbcType=INTEGER}, - - - cd_favor = #{cdFavor,jdbcType=INTEGER}, - - - cd_time = #{cdTime,jdbcType=DATE}, - - - cd_content = #{cdContent,jdbcType=LONGVARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update community_dynamic - set cd_user_id = #{cdUserId,jdbcType=INTEGER}, - cd_pic_path = #{cdPicPath,jdbcType=VARCHAR}, - cd_type = #{cdType,jdbcType=INTEGER}, - cd_favor = #{cdFavor,jdbcType=INTEGER}, - cd_time = #{cdTime,jdbcType=DATE}, - cd_content = #{cdContent,jdbcType=LONGVARCHAR} - where id = #{id,jdbcType=INTEGER} - - - update community_dynamic - set cd_user_id = #{cdUserId,jdbcType=INTEGER}, - cd_pic_path = #{cdPicPath,jdbcType=VARCHAR}, - cd_type = #{cdType,jdbcType=INTEGER}, - cd_favor = #{cdFavor,jdbcType=INTEGER}, - cd_time = #{cdTime,jdbcType=DATE} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file -- Gitee From a5a19f4ec9475ba780b8e94fd4e53a960efb8ef3 Mon Sep 17 00:00:00 2001 From: starlbb Date: Tue, 24 Mar 2020 12:04:49 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=8A=A8=E6=80=81=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=BC=8F=E6=8E=89=E7=9A=84commit=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/woniu/dao/DynamicMapper.java | 19 +++ .../src/main/java/com/woniu/pojo/Dynamic.java | 35 +++++ .../main/resources/mapper/DynamicMapper.xml | 133 ++++++++++++++++++ 3 files changed, 187 insertions(+) create mode 100644 communityservice/src/main/java/com/woniu/dao/DynamicMapper.java create mode 100644 communityservice/src/main/java/com/woniu/pojo/Dynamic.java create mode 100644 communityservice/src/main/resources/mapper/DynamicMapper.xml diff --git a/communityservice/src/main/java/com/woniu/dao/DynamicMapper.java b/communityservice/src/main/java/com/woniu/dao/DynamicMapper.java new file mode 100644 index 0000000..66cac53 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/dao/DynamicMapper.java @@ -0,0 +1,19 @@ +package com.woniu.dao; + +import com.woniu.pojo.Dynamic; + +public interface DynamicMapper { + int deleteByPrimaryKey(Integer id); + + int insert(Dynamic record); + + int insertSelective(Dynamic record); + + Dynamic selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(Dynamic record); + + int updateByPrimaryKeyWithBLOBs(Dynamic record); + + int updateByPrimaryKey(Dynamic record); +} \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/pojo/Dynamic.java b/communityservice/src/main/java/com/woniu/pojo/Dynamic.java new file mode 100644 index 0000000..38b5f00 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/pojo/Dynamic.java @@ -0,0 +1,35 @@ +package com.woniu.pojo; + +import lombok.Data; + +import java.util.Date; + +@Data +public class Dynamic { + private Integer id; + + private Integer cdUserId; + + private String cdPicPath; + + private Integer cdType; + + private Integer cdFavor; + + private Date cdTime; + + private String cdContent; + + public Dynamic() { + } + + public Dynamic(Integer cdUserId, String cdPicPath, Integer cdType, Integer cdFavor, Date cdTime, String cdContent) { + this.cdUserId = cdUserId; + this.cdPicPath = cdPicPath; + this.cdType = cdType; + this.cdFavor = cdFavor; + this.cdTime = cdTime; + this.cdContent = cdContent; + } + +} \ No newline at end of file diff --git a/communityservice/src/main/resources/mapper/DynamicMapper.xml b/communityservice/src/main/resources/mapper/DynamicMapper.xml new file mode 100644 index 0000000..c4b51da --- /dev/null +++ b/communityservice/src/main/resources/mapper/DynamicMapper.xml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + id, cd_user_id, cd_pic_path, cd_type, cd_favor, cd_time + + + cd_content + + + + delete from community_dynamic + where id = #{id,jdbcType=INTEGER} + + + insert into community_dynamic (id, cd_user_id, cd_pic_path, + cd_type, cd_favor, cd_time, + cd_content) + values (#{id,jdbcType=INTEGER}, #{cdUserId,jdbcType=INTEGER}, #{cdPicPath,jdbcType=VARCHAR}, + #{cdType,jdbcType=INTEGER}, #{cdFavor,jdbcType=INTEGER}, #{cdTime,jdbcType=TIMESTAMP}, + #{cdContent,jdbcType=LONGVARCHAR}) + + + insert into community_dynamic + + + id, + + + cd_user_id, + + + cd_pic_path, + + + cd_type, + + + cd_favor, + + + cd_time, + + + cd_content, + + + + + #{id,jdbcType=INTEGER}, + + + #{cdUserId,jdbcType=INTEGER}, + + + #{cdPicPath,jdbcType=VARCHAR}, + + + #{cdType,jdbcType=INTEGER}, + + + #{cdFavor,jdbcType=INTEGER}, + + + #{cdTime,jdbcType=TIMESTAMP}, + + + #{cdContent,jdbcType=LONGVARCHAR}, + + + + + update community_dynamic + + + cd_user_id = #{cdUserId,jdbcType=INTEGER}, + + + cd_pic_path = #{cdPicPath,jdbcType=VARCHAR}, + + + cd_type = #{cdType,jdbcType=INTEGER}, + + + cd_favor = #{cdFavor,jdbcType=INTEGER}, + + + cd_time = #{cdTime,jdbcType=TIMESTAMP}, + + + cd_content = #{cdContent,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + update community_dynamic + set cd_user_id = #{cdUserId,jdbcType=INTEGER}, + cd_pic_path = #{cdPicPath,jdbcType=VARCHAR}, + cd_type = #{cdType,jdbcType=INTEGER}, + cd_favor = #{cdFavor,jdbcType=INTEGER}, + cd_time = #{cdTime,jdbcType=TIMESTAMP}, + cd_content = #{cdContent,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=INTEGER} + + + update community_dynamic + set cd_user_id = #{cdUserId,jdbcType=INTEGER}, + cd_pic_path = #{cdPicPath,jdbcType=VARCHAR}, + cd_type = #{cdType,jdbcType=INTEGER}, + cd_favor = #{cdFavor,jdbcType=INTEGER}, + cd_time = #{cdTime,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file -- Gitee From 0df64858149a9b4988d6ad3f73c39746a906ad47 Mon Sep 17 00:00:00 2001 From: starlbb Date: Tue, 24 Mar 2020 14:48:49 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=8A=95=E8=AF=89?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E9=A1=B5=E9=9D=A2=20=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E5=9C=A8=E5=A4=B1=E8=B4=A5=E5=90=8E=E5=86=8D=E6=AC=A1=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=97=A0=E6=95=88=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../woniu/controller/ActivityController.java | 46 +++++++ .../woniu/dao/ActivityComplaintMapper.java | 19 +++ .../com/woniu/pojo/ActivityComplaint.java | 31 +++++ .../com/woniu/service/ActivityService.java | 11 ++ .../com/woniu/service/DynamicService.java | 2 +- .../service/impl/ActivityServiceImpl.java | 32 +++++ .../service/impl/DynamicServiceImpl.java | 4 +- .../src/main/resources/generatorConfig.xml | 12 +- .../mapper/ActivityComplaintMapper.xml | 121 ++++++++++++++++++ 9 files changed, 273 insertions(+), 5 deletions(-) create mode 100644 communityservice/src/main/java/com/woniu/controller/ActivityController.java create mode 100644 communityservice/src/main/java/com/woniu/dao/ActivityComplaintMapper.java create mode 100644 communityservice/src/main/java/com/woniu/pojo/ActivityComplaint.java create mode 100644 communityservice/src/main/java/com/woniu/service/ActivityService.java create mode 100644 communityservice/src/main/java/com/woniu/service/impl/ActivityServiceImpl.java create mode 100644 communityservice/src/main/resources/mapper/ActivityComplaintMapper.xml diff --git a/communityservice/src/main/java/com/woniu/controller/ActivityController.java b/communityservice/src/main/java/com/woniu/controller/ActivityController.java new file mode 100644 index 0000000..4252fa1 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/controller/ActivityController.java @@ -0,0 +1,46 @@ +package com.woniu.controller; + +import com.alibaba.fastjson.JSONArray; +import com.woniu.result.CommonResult; +import com.woniu.service.ActivityService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.Map; + +@Controller +@RequestMapping("/activity") +public class ActivityController { + + @Autowired + private ActivityService activityService; + + /** + * 投诉活动 + * @param complaint 投诉信息 + * @return + */ + @RequestMapping("/complaintSave") + @ResponseBody + public CommonResult save(@RequestBody String complaint){ + try { + //转化成真实的值 + String act = URLDecoder.decode(complaint,"UTF-8"); + //没有上传图片时参数多了一个 = ,不知道为啥 + act = act.replace("=",""); + //将数据转为map + Map map = JSONArray.parseObject(act); + //保存动态到数据库 + activityService.save(map); + return CommonResult.success("发布成功"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + return CommonResult.failed("操作失败"); + } + } +} diff --git a/communityservice/src/main/java/com/woniu/dao/ActivityComplaintMapper.java b/communityservice/src/main/java/com/woniu/dao/ActivityComplaintMapper.java new file mode 100644 index 0000000..4015df1 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/dao/ActivityComplaintMapper.java @@ -0,0 +1,19 @@ +package com.woniu.dao; + +import com.woniu.pojo.ActivityComplaint; + +public interface ActivityComplaintMapper { + int deleteByPrimaryKey(Integer id); + + int insert(ActivityComplaint record); + + int insertSelective(ActivityComplaint record); + + ActivityComplaint selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(ActivityComplaint record); + + int updateByPrimaryKeyWithBLOBs(ActivityComplaint record); + + int updateByPrimaryKey(ActivityComplaint record); +} \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/pojo/ActivityComplaint.java b/communityservice/src/main/java/com/woniu/pojo/ActivityComplaint.java new file mode 100644 index 0000000..ee7f802 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/pojo/ActivityComplaint.java @@ -0,0 +1,31 @@ +package com.woniu.pojo; + +import lombok.Data; + +import java.util.Date; + +@Data +public class ActivityComplaint { + private Integer id; + + private Integer cacUserId; + + private Integer cacActivityId; + + private String cacPic; + + private Date ccTime; + + private String cacReason; + + public ActivityComplaint() { + } + + public ActivityComplaint(Integer cacUserId, Integer cacActivityId, String cacPic, Date ccTime, String cacReason) { + this.cacUserId = cacUserId; + this.cacActivityId = cacActivityId; + this.cacPic = cacPic; + this.ccTime = ccTime; + this.cacReason = cacReason; + } +} \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/service/ActivityService.java b/communityservice/src/main/java/com/woniu/service/ActivityService.java new file mode 100644 index 0000000..7136f11 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/service/ActivityService.java @@ -0,0 +1,11 @@ +package com.woniu.service; + +import java.util.Map; + +public interface ActivityService { + /** + * 投诉活动 + * @param map + */ + void save(Map map); +} diff --git a/communityservice/src/main/java/com/woniu/service/DynamicService.java b/communityservice/src/main/java/com/woniu/service/DynamicService.java index de225b2..9c73e37 100644 --- a/communityservice/src/main/java/com/woniu/service/DynamicService.java +++ b/communityservice/src/main/java/com/woniu/service/DynamicService.java @@ -8,5 +8,5 @@ public interface DynamicService { * 保存动态 * @param map 动态数据 */ - Integer save(Map map); + void save(Map map); } diff --git a/communityservice/src/main/java/com/woniu/service/impl/ActivityServiceImpl.java b/communityservice/src/main/java/com/woniu/service/impl/ActivityServiceImpl.java new file mode 100644 index 0000000..5f678f6 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/service/impl/ActivityServiceImpl.java @@ -0,0 +1,32 @@ +package com.woniu.service.impl; + +import com.woniu.dao.ActivityComplaintMapper; +import com.woniu.pojo.ActivityComplaint; +import com.woniu.service.ActivityService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.Map; + +@Service +public class ActivityServiceImpl implements ActivityService { + + @Autowired + private ActivityComplaintMapper activityComplaintMapper; + + /** + * 投诉活动 + * @param map 投诉数据 + */ + @Override + public void save(Map map) { + //构造一个新的投诉实体 + Integer userId = Integer.valueOf(map.get("userId").toString()); + String picPath = String.valueOf(map.get("picPath")); + Integer activityId = Integer.valueOf(map.get("activityId").toString()); + String content = String.valueOf(map.get("content")); + ActivityComplaint activityComplaint = new ActivityComplaint(userId,activityId,picPath,new Date(),content); + activityComplaintMapper.insertSelective(activityComplaint); + } +} diff --git a/communityservice/src/main/java/com/woniu/service/impl/DynamicServiceImpl.java b/communityservice/src/main/java/com/woniu/service/impl/DynamicServiceImpl.java index e722bf8..9d0b022 100644 --- a/communityservice/src/main/java/com/woniu/service/impl/DynamicServiceImpl.java +++ b/communityservice/src/main/java/com/woniu/service/impl/DynamicServiceImpl.java @@ -20,7 +20,7 @@ public class DynamicServiceImpl implements DynamicService { * @param map */ @Override - public Integer save(Map map) { + public void save(Map map) { //构造一个新的动态实体 Integer userId = Integer.valueOf(map.get("userId").toString()); String picPath = String.valueOf(map.get("picPath")); @@ -28,6 +28,6 @@ public class DynamicServiceImpl implements DynamicService { Integer favor = Integer.valueOf(map.get("favor").toString()); String content = String.valueOf(map.get("content")); Dynamic dynamic = new Dynamic(userId,picPath,type,favor,new Date(),content); - return dynamicMapper.insertSelective(dynamic); + dynamicMapper.insertSelective(dynamic); } } diff --git a/communityservice/src/main/resources/generatorConfig.xml b/communityservice/src/main/resources/generatorConfig.xml index d735ae9..2743894 100644 --- a/communityservice/src/main/resources/generatorConfig.xml +++ b/communityservice/src/main/resources/generatorConfig.xml @@ -18,13 +18,21 @@ - + + + + + + + +
- +
diff --git a/communityservice/src/main/resources/mapper/ActivityComplaintMapper.xml b/communityservice/src/main/resources/mapper/ActivityComplaintMapper.xml new file mode 100644 index 0000000..1b31790 --- /dev/null +++ b/communityservice/src/main/resources/mapper/ActivityComplaintMapper.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + id, cac_user_id, cac_activity_id, cac_pic, cc_time + + + cac_reason + + + + delete from community_activity_complaint + where id = #{id,jdbcType=INTEGER} + + + insert into community_activity_complaint (id, cac_user_id, cac_activity_id, + cac_pic, cc_time, cac_reason + ) + values (#{id,jdbcType=INTEGER}, #{cacUserId,jdbcType=INTEGER}, #{cacActivityId,jdbcType=INTEGER}, + #{cacPic,jdbcType=VARCHAR}, #{ccTime,jdbcType=TIMESTAMP}, #{cacReason,jdbcType=LONGVARCHAR} + ) + + + insert into community_activity_complaint + + + id, + + + cac_user_id, + + + cac_activity_id, + + + cac_pic, + + + cc_time, + + + cac_reason, + + + + + #{id,jdbcType=INTEGER}, + + + #{cacUserId,jdbcType=INTEGER}, + + + #{cacActivityId,jdbcType=INTEGER}, + + + #{cacPic,jdbcType=VARCHAR}, + + + #{ccTime,jdbcType=TIMESTAMP}, + + + #{cacReason,jdbcType=LONGVARCHAR}, + + + + + update community_activity_complaint + + + cac_user_id = #{cacUserId,jdbcType=INTEGER}, + + + cac_activity_id = #{cacActivityId,jdbcType=INTEGER}, + + + cac_pic = #{cacPic,jdbcType=VARCHAR}, + + + cc_time = #{ccTime,jdbcType=TIMESTAMP}, + + + cac_reason = #{cacReason,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + update community_activity_complaint + set cac_user_id = #{cacUserId,jdbcType=INTEGER}, + cac_activity_id = #{cacActivityId,jdbcType=INTEGER}, + cac_pic = #{cacPic,jdbcType=VARCHAR}, + cc_time = #{ccTime,jdbcType=TIMESTAMP}, + cac_reason = #{cacReason,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=INTEGER} + + + update community_activity_complaint + set cac_user_id = #{cacUserId,jdbcType=INTEGER}, + cac_activity_id = #{cacActivityId,jdbcType=INTEGER}, + cac_pic = #{cacPic,jdbcType=VARCHAR}, + cc_time = #{ccTime,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file -- Gitee From 8c583f0a569ab2d70dd9a962fc1e975f67b66e8c Mon Sep 17 00:00:00 2001 From: starlbb Date: Tue, 24 Mar 2020 16:24:55 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../woniu/controller/ActivityController.java | 27 ++- .../java/com/woniu/dao/ActivityMapper.java | 19 ++ .../com/woniu/dao/ActivityUserMapper.java | 17 ++ .../com/woniu/dao/DynamicCommentMapper.java | 17 ++ .../main/java/com/woniu/pojo/Activity.java | 53 +++++ .../java/com/woniu/pojo/ActivityUser.java | 33 +++ .../java/com/woniu/pojo/DynamicComment.java | 65 ++++++ .../com/woniu/service/ActivityService.java | 6 + .../service/impl/ActivityServiceImpl.java | 35 +++ .../src/main/resources/generatorConfig.xml | 19 +- .../main/resources/mapper/ActivityMapper.xml | 210 ++++++++++++++++++ .../resources/mapper/ActivityUserMapper.xml | 71 ++++++ .../resources/mapper/DynamicCommentMapper.xml | 106 +++++++++ 13 files changed, 676 insertions(+), 2 deletions(-) create mode 100644 communityservice/src/main/java/com/woniu/dao/ActivityMapper.java create mode 100644 communityservice/src/main/java/com/woniu/dao/ActivityUserMapper.java create mode 100644 communityservice/src/main/java/com/woniu/dao/DynamicCommentMapper.java create mode 100644 communityservice/src/main/java/com/woniu/pojo/Activity.java create mode 100644 communityservice/src/main/java/com/woniu/pojo/ActivityUser.java create mode 100644 communityservice/src/main/java/com/woniu/pojo/DynamicComment.java create mode 100644 communityservice/src/main/resources/mapper/ActivityMapper.xml create mode 100644 communityservice/src/main/resources/mapper/ActivityUserMapper.xml create mode 100644 communityservice/src/main/resources/mapper/DynamicCommentMapper.xml diff --git a/communityservice/src/main/java/com/woniu/controller/ActivityController.java b/communityservice/src/main/java/com/woniu/controller/ActivityController.java index 4252fa1..323b979 100644 --- a/communityservice/src/main/java/com/woniu/controller/ActivityController.java +++ b/communityservice/src/main/java/com/woniu/controller/ActivityController.java @@ -27,7 +27,7 @@ public class ActivityController { */ @RequestMapping("/complaintSave") @ResponseBody - public CommonResult save(@RequestBody String complaint){ + public CommonResult ComplaintSave(@RequestBody String complaint){ try { //转化成真实的值 String act = URLDecoder.decode(complaint,"UTF-8"); @@ -43,4 +43,29 @@ public class ActivityController { return CommonResult.failed("操作失败"); } } + + /** + * 发布活动 + * @param activity 活动信息 + * @return + */ + @RequestMapping("/activitySave") + @ResponseBody + public CommonResult ActivitySave(@RequestBody String activity){ + try { + //转化成真实的值 + String act = URLDecoder.decode(activity,"UTF-8"); + //没有上传图片时参数多了一个 = ,不知道为啥 + act = act.replace("=",""); + //将数据转为map + Map map = JSONArray.parseObject(act); + //保存动态到数据库 + activityService.ActivitySave(map); + return CommonResult.success("发布成功"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + return CommonResult.failed("操作失败"); + } + } + } diff --git a/communityservice/src/main/java/com/woniu/dao/ActivityMapper.java b/communityservice/src/main/java/com/woniu/dao/ActivityMapper.java new file mode 100644 index 0000000..b53eea0 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/dao/ActivityMapper.java @@ -0,0 +1,19 @@ +package com.woniu.dao; + +import com.woniu.pojo.Activity; + +public interface ActivityMapper { + int deleteByPrimaryKey(Integer id); + + int insert(Activity record); + + int insertSelective(Activity record); + + Activity selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(Activity record); + + int updateByPrimaryKeyWithBLOBs(Activity record); + + int updateByPrimaryKey(Activity record); +} \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/dao/ActivityUserMapper.java b/communityservice/src/main/java/com/woniu/dao/ActivityUserMapper.java new file mode 100644 index 0000000..11a0ec3 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/dao/ActivityUserMapper.java @@ -0,0 +1,17 @@ +package com.woniu.dao; + +import com.woniu.pojo.ActivityUser; + +public interface ActivityUserMapper { + int deleteByPrimaryKey(Integer id); + + int insert(ActivityUser record); + + int insertSelective(ActivityUser record); + + ActivityUser selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(ActivityUser record); + + int updateByPrimaryKey(ActivityUser record); +} \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/dao/DynamicCommentMapper.java b/communityservice/src/main/java/com/woniu/dao/DynamicCommentMapper.java new file mode 100644 index 0000000..8e77974 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/dao/DynamicCommentMapper.java @@ -0,0 +1,17 @@ +package com.woniu.dao; + +import com.woniu.pojo.DynamicComment; + +public interface DynamicCommentMapper { + int deleteByPrimaryKey(Integer id); + + int insert(DynamicComment record); + + int insertSelective(DynamicComment record); + + DynamicComment selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(DynamicComment record); + + int updateByPrimaryKey(DynamicComment record); +} \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/pojo/Activity.java b/communityservice/src/main/java/com/woniu/pojo/Activity.java new file mode 100644 index 0000000..183056f --- /dev/null +++ b/communityservice/src/main/java/com/woniu/pojo/Activity.java @@ -0,0 +1,53 @@ +package com.woniu.pojo; + +import lombok.Data; + +import java.util.Date; + +@Data +public class Activity { + private Integer id; + + private Integer caUserId; + + private String caPicPath; + + private Integer caType; + + private String caTitle; + + private Date caStartTime; + + private Date caEndTime; + + private Integer caStatus; + + private Double caMoney; + + private Integer caPeopelCount; + + private Integer caMaxPeopleCount; + + private Date caCreateTime; + + private String caContent; + + public Activity() { + } + + public Activity(Integer caUserId, String caPicPath, Integer caType, String caTitle, Date caStartTime, Date caEndTime, Integer caStatus, Double caMoney, Integer caPeopelCount, Integer caMaxPeopleCount, Date caCreateTime, String caContent) { + this.caUserId = caUserId; + this.caPicPath = caPicPath; + this.caType = caType; + this.caTitle = caTitle; + this.caStartTime = caStartTime; + this.caEndTime = caEndTime; + this.caStatus = caStatus; + this.caMoney = caMoney; + this.caPeopelCount = caPeopelCount; + this.caMaxPeopleCount = caMaxPeopleCount; + this.caCreateTime = caCreateTime; + this.caContent = caContent; + } + +} \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/pojo/ActivityUser.java b/communityservice/src/main/java/com/woniu/pojo/ActivityUser.java new file mode 100644 index 0000000..d64e8ed --- /dev/null +++ b/communityservice/src/main/java/com/woniu/pojo/ActivityUser.java @@ -0,0 +1,33 @@ +package com.woniu.pojo; + +public class ActivityUser { + private Integer id; + + private Integer cauActivityId; + + private Integer cauUserId; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getCauActivityId() { + return cauActivityId; + } + + public void setCauActivityId(Integer cauActivityId) { + this.cauActivityId = cauActivityId; + } + + public Integer getCauUserId() { + return cauUserId; + } + + public void setCauUserId(Integer cauUserId) { + this.cauUserId = cauUserId; + } +} \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/pojo/DynamicComment.java b/communityservice/src/main/java/com/woniu/pojo/DynamicComment.java new file mode 100644 index 0000000..6baad41 --- /dev/null +++ b/communityservice/src/main/java/com/woniu/pojo/DynamicComment.java @@ -0,0 +1,65 @@ +package com.woniu.pojo; + +import java.util.Date; + +public class DynamicComment { + private Integer id; + + private Integer cdcDynamicId; + + private Integer cdcUserId; + + private Integer cdcOtherUserId; + + private String cdcContent; + + private Date cdcTime; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getCdcDynamicId() { + return cdcDynamicId; + } + + public void setCdcDynamicId(Integer cdcDynamicId) { + this.cdcDynamicId = cdcDynamicId; + } + + public Integer getCdcUserId() { + return cdcUserId; + } + + public void setCdcUserId(Integer cdcUserId) { + this.cdcUserId = cdcUserId; + } + + public Integer getCdcOtherUserId() { + return cdcOtherUserId; + } + + public void setCdcOtherUserId(Integer cdcOtherUserId) { + this.cdcOtherUserId = cdcOtherUserId; + } + + public String getCdcContent() { + return cdcContent; + } + + public void setCdcContent(String cdcContent) { + this.cdcContent = cdcContent; + } + + public Date getCdcTime() { + return cdcTime; + } + + public void setCdcTime(Date cdcTime) { + this.cdcTime = cdcTime; + } +} \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/service/ActivityService.java b/communityservice/src/main/java/com/woniu/service/ActivityService.java index 7136f11..59e0c8b 100644 --- a/communityservice/src/main/java/com/woniu/service/ActivityService.java +++ b/communityservice/src/main/java/com/woniu/service/ActivityService.java @@ -8,4 +8,10 @@ public interface ActivityService { * @param map */ void save(Map map); + + /** + * 发布活动 + * @param map + */ + void ActivitySave(Map map); } diff --git a/communityservice/src/main/java/com/woniu/service/impl/ActivityServiceImpl.java b/communityservice/src/main/java/com/woniu/service/impl/ActivityServiceImpl.java index 5f678f6..4c781dd 100644 --- a/communityservice/src/main/java/com/woniu/service/impl/ActivityServiceImpl.java +++ b/communityservice/src/main/java/com/woniu/service/impl/ActivityServiceImpl.java @@ -1,11 +1,15 @@ package com.woniu.service.impl; import com.woniu.dao.ActivityComplaintMapper; +import com.woniu.dao.ActivityMapper; +import com.woniu.pojo.Activity; import com.woniu.pojo.ActivityComplaint; import com.woniu.service.ActivityService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; @@ -14,6 +18,8 @@ public class ActivityServiceImpl implements ActivityService { @Autowired private ActivityComplaintMapper activityComplaintMapper; + @Autowired + private ActivityMapper activityMapper; /** * 投诉活动 @@ -29,4 +35,33 @@ public class ActivityServiceImpl implements ActivityService { ActivityComplaint activityComplaint = new ActivityComplaint(userId,activityId,picPath,new Date(),content); activityComplaintMapper.insertSelective(activityComplaint); } + + /** + * 发布活动 + * @param map 活动数据 + */ + @Override + public void ActivitySave(Map map) { + //构造一个活动实体,从前端获取数据 + Integer userId = Integer.valueOf(map.get("userId").toString()); + String picPath = String.valueOf(map.get("picPath")); + Integer type = Integer.valueOf(map.get("type").toString()); + String title = String.valueOf(map.get("activityName")); + Date startTime=null,endTime=null; + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + startTime = sdf.parse(map.get("startTime").toString()); + endTime = sdf.parse(map.get("endTime").toString()); + } catch (ParseException e) { + e.printStackTrace(); + } + Integer statue = 0; + Double money = Double.valueOf(map.get("money").toString()); + Integer peopelCount = 0; + Integer maxCount = Integer.valueOf(map.get("maxCount").toString()); + Date createTime = new Date(); + String content = String.valueOf(map.get("content")); + Activity activity = new Activity(userId,picPath,type,title,startTime,endTime,statue,money,peopelCount,maxCount,createTime,content); + activityMapper.insertSelective(activity); + } } diff --git a/communityservice/src/main/resources/generatorConfig.xml b/communityservice/src/main/resources/generatorConfig.xml index 2743894..a1b409b 100644 --- a/communityservice/src/main/resources/generatorConfig.xml +++ b/communityservice/src/main/resources/generatorConfig.xml @@ -26,7 +26,15 @@ - + +
+
+ + +
+ \ No newline at end of file diff --git a/communityservice/src/main/resources/mapper/ActivityMapper.xml b/communityservice/src/main/resources/mapper/ActivityMapper.xml new file mode 100644 index 0000000..80512f4 --- /dev/null +++ b/communityservice/src/main/resources/mapper/ActivityMapper.xml @@ -0,0 +1,210 @@ + + + + + + + + + + + + + + + + + + + + + + id, ca_user_id, ca_pic_path, ca_type, ca_title, ca_start_time, ca_end_time, ca_status, + ca_money, ca_peopel_count, ca_max_people_count, ca_create_time + + + ca_content + + + + delete from community_activity + where id = #{id,jdbcType=INTEGER} + + + insert into community_activity (id, ca_user_id, ca_pic_path, + ca_type, ca_title, ca_start_time, + ca_end_time, ca_status, ca_money, + ca_peopel_count, ca_max_people_count, ca_create_time, + ca_content) + values (#{id,jdbcType=INTEGER}, #{caUserId,jdbcType=INTEGER}, #{caPicPath,jdbcType=VARCHAR}, + #{caType,jdbcType=INTEGER}, #{caTitle,jdbcType=VARCHAR}, #{caStartTime,jdbcType=TIMESTAMP}, + #{caEndTime,jdbcType=TIMESTAMP}, #{caStatus,jdbcType=INTEGER}, #{caMoney,jdbcType=DOUBLE}, + #{caPeopelCount,jdbcType=INTEGER}, #{caMaxPeopleCount,jdbcType=INTEGER}, #{caCreateTime,jdbcType=TIMESTAMP}, + #{caContent,jdbcType=LONGVARCHAR}) + + + insert into community_activity + + + id, + + + ca_user_id, + + + ca_pic_path, + + + ca_type, + + + ca_title, + + + ca_start_time, + + + ca_end_time, + + + ca_status, + + + ca_money, + + + ca_peopel_count, + + + ca_max_people_count, + + + ca_create_time, + + + ca_content, + + + + + #{id,jdbcType=INTEGER}, + + + #{caUserId,jdbcType=INTEGER}, + + + #{caPicPath,jdbcType=VARCHAR}, + + + #{caType,jdbcType=INTEGER}, + + + #{caTitle,jdbcType=VARCHAR}, + + + #{caStartTime,jdbcType=TIMESTAMP}, + + + #{caEndTime,jdbcType=TIMESTAMP}, + + + #{caStatus,jdbcType=INTEGER}, + + + #{caMoney,jdbcType=DOUBLE}, + + + #{caPeopelCount,jdbcType=INTEGER}, + + + #{caMaxPeopleCount,jdbcType=INTEGER}, + + + #{caCreateTime,jdbcType=TIMESTAMP}, + + + #{caContent,jdbcType=LONGVARCHAR}, + + + + + update community_activity + + + ca_user_id = #{caUserId,jdbcType=INTEGER}, + + + ca_pic_path = #{caPicPath,jdbcType=VARCHAR}, + + + ca_type = #{caType,jdbcType=INTEGER}, + + + ca_title = #{caTitle,jdbcType=VARCHAR}, + + + ca_start_time = #{caStartTime,jdbcType=TIMESTAMP}, + + + ca_end_time = #{caEndTime,jdbcType=TIMESTAMP}, + + + ca_status = #{caStatus,jdbcType=INTEGER}, + + + ca_money = #{caMoney,jdbcType=DOUBLE}, + + + ca_peopel_count = #{caPeopelCount,jdbcType=INTEGER}, + + + ca_max_people_count = #{caMaxPeopleCount,jdbcType=INTEGER}, + + + ca_create_time = #{caCreateTime,jdbcType=TIMESTAMP}, + + + ca_content = #{caContent,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + update community_activity + set ca_user_id = #{caUserId,jdbcType=INTEGER}, + ca_pic_path = #{caPicPath,jdbcType=VARCHAR}, + ca_type = #{caType,jdbcType=INTEGER}, + ca_title = #{caTitle,jdbcType=VARCHAR}, + ca_start_time = #{caStartTime,jdbcType=TIMESTAMP}, + ca_end_time = #{caEndTime,jdbcType=TIMESTAMP}, + ca_status = #{caStatus,jdbcType=INTEGER}, + ca_money = #{caMoney,jdbcType=DOUBLE}, + ca_peopel_count = #{caPeopelCount,jdbcType=INTEGER}, + ca_max_people_count = #{caMaxPeopleCount,jdbcType=INTEGER}, + ca_create_time = #{caCreateTime,jdbcType=TIMESTAMP}, + ca_content = #{caContent,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=INTEGER} + + + update community_activity + set ca_user_id = #{caUserId,jdbcType=INTEGER}, + ca_pic_path = #{caPicPath,jdbcType=VARCHAR}, + ca_type = #{caType,jdbcType=INTEGER}, + ca_title = #{caTitle,jdbcType=VARCHAR}, + ca_start_time = #{caStartTime,jdbcType=TIMESTAMP}, + ca_end_time = #{caEndTime,jdbcType=TIMESTAMP}, + ca_status = #{caStatus,jdbcType=INTEGER}, + ca_money = #{caMoney,jdbcType=DOUBLE}, + ca_peopel_count = #{caPeopelCount,jdbcType=INTEGER}, + ca_max_people_count = #{caMaxPeopleCount,jdbcType=INTEGER}, + ca_create_time = #{caCreateTime,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/communityservice/src/main/resources/mapper/ActivityUserMapper.xml b/communityservice/src/main/resources/mapper/ActivityUserMapper.xml new file mode 100644 index 0000000..e718364 --- /dev/null +++ b/communityservice/src/main/resources/mapper/ActivityUserMapper.xml @@ -0,0 +1,71 @@ + + + + + + + + + + id, cau_activity_id, cau_user_id + + + + delete from community_activity_user + where id = #{id,jdbcType=INTEGER} + + + insert into community_activity_user (id, cau_activity_id, cau_user_id + ) + values (#{id,jdbcType=INTEGER}, #{cauActivityId,jdbcType=INTEGER}, #{cauUserId,jdbcType=INTEGER} + ) + + + insert into community_activity_user + + + id, + + + cau_activity_id, + + + cau_user_id, + + + + + #{id,jdbcType=INTEGER}, + + + #{cauActivityId,jdbcType=INTEGER}, + + + #{cauUserId,jdbcType=INTEGER}, + + + + + update community_activity_user + + + cau_activity_id = #{cauActivityId,jdbcType=INTEGER}, + + + cau_user_id = #{cauUserId,jdbcType=INTEGER}, + + + where id = #{id,jdbcType=INTEGER} + + + update community_activity_user + set cau_activity_id = #{cauActivityId,jdbcType=INTEGER}, + cau_user_id = #{cauUserId,jdbcType=INTEGER} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/communityservice/src/main/resources/mapper/DynamicCommentMapper.xml b/communityservice/src/main/resources/mapper/DynamicCommentMapper.xml new file mode 100644 index 0000000..1e875be --- /dev/null +++ b/communityservice/src/main/resources/mapper/DynamicCommentMapper.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + id, cdc_dynamic_id, cdc_user_id, cdc_other_user_id, cdc_content, cdc_time + + + + delete from community_dynamic_comment + where id = #{id,jdbcType=INTEGER} + + + insert into community_dynamic_comment (id, cdc_dynamic_id, cdc_user_id, + cdc_other_user_id, cdc_content, cdc_time + ) + values (#{id,jdbcType=INTEGER}, #{cdcDynamicId,jdbcType=INTEGER}, #{cdcUserId,jdbcType=INTEGER}, + #{cdcOtherUserId,jdbcType=INTEGER}, #{cdcContent,jdbcType=VARCHAR}, #{cdcTime,jdbcType=TIMESTAMP} + ) + + + insert into community_dynamic_comment + + + id, + + + cdc_dynamic_id, + + + cdc_user_id, + + + cdc_other_user_id, + + + cdc_content, + + + cdc_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{cdcDynamicId,jdbcType=INTEGER}, + + + #{cdcUserId,jdbcType=INTEGER}, + + + #{cdcOtherUserId,jdbcType=INTEGER}, + + + #{cdcContent,jdbcType=VARCHAR}, + + + #{cdcTime,jdbcType=TIMESTAMP}, + + + + + update community_dynamic_comment + + + cdc_dynamic_id = #{cdcDynamicId,jdbcType=INTEGER}, + + + cdc_user_id = #{cdcUserId,jdbcType=INTEGER}, + + + cdc_other_user_id = #{cdcOtherUserId,jdbcType=INTEGER}, + + + cdc_content = #{cdcContent,jdbcType=VARCHAR}, + + + cdc_time = #{cdcTime,jdbcType=TIMESTAMP}, + + + where id = #{id,jdbcType=INTEGER} + + + update community_dynamic_comment + set cdc_dynamic_id = #{cdcDynamicId,jdbcType=INTEGER}, + cdc_user_id = #{cdcUserId,jdbcType=INTEGER}, + cdc_other_user_id = #{cdcOtherUserId,jdbcType=INTEGER}, + cdc_content = #{cdcContent,jdbcType=VARCHAR}, + cdc_time = #{cdcTime,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file -- Gitee From 64182c6e0d93fcbb22c3b4d789e48d073c6976c4 Mon Sep 17 00:00:00 2001 From: starlbb Date: Tue, 24 Mar 2020 18:07:04 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E7=9B=B8=E5=85=B3=E8=A1=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9A=84=E5=A2=9E=E5=8A=A0=EF=BC=8C=E5=89=8D=E7=AB=AF=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=97=B6=E9=97=B4=E8=8C=83=E5=9B=B4=E7=9A=84=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/woniu/pojo/ActivityUser.java | 23 ++++--------------- .../service/impl/ActivityServiceImpl.java | 14 ++++++++--- .../main/resources/mapper/ActivityMapper.xml | 2 +- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/communityservice/src/main/java/com/woniu/pojo/ActivityUser.java b/communityservice/src/main/java/com/woniu/pojo/ActivityUser.java index d64e8ed..4c1ddd8 100644 --- a/communityservice/src/main/java/com/woniu/pojo/ActivityUser.java +++ b/communityservice/src/main/java/com/woniu/pojo/ActivityUser.java @@ -1,5 +1,8 @@ package com.woniu.pojo; +import lombok.Data; + +@Data public class ActivityUser { private Integer id; @@ -7,27 +10,11 @@ public class ActivityUser { private Integer cauUserId; - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getCauActivityId() { - return cauActivityId; + public ActivityUser() { } - public void setCauActivityId(Integer cauActivityId) { + public ActivityUser(Integer cauActivityId, Integer cauUserId) { this.cauActivityId = cauActivityId; - } - - public Integer getCauUserId() { - return cauUserId; - } - - public void setCauUserId(Integer cauUserId) { this.cauUserId = cauUserId; } } \ No newline at end of file diff --git a/communityservice/src/main/java/com/woniu/service/impl/ActivityServiceImpl.java b/communityservice/src/main/java/com/woniu/service/impl/ActivityServiceImpl.java index 4c781dd..2df00e2 100644 --- a/communityservice/src/main/java/com/woniu/service/impl/ActivityServiceImpl.java +++ b/communityservice/src/main/java/com/woniu/service/impl/ActivityServiceImpl.java @@ -2,8 +2,10 @@ package com.woniu.service.impl; import com.woniu.dao.ActivityComplaintMapper; import com.woniu.dao.ActivityMapper; +import com.woniu.dao.ActivityUserMapper; import com.woniu.pojo.Activity; import com.woniu.pojo.ActivityComplaint; +import com.woniu.pojo.ActivityUser; import com.woniu.service.ActivityService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -20,7 +22,8 @@ public class ActivityServiceImpl implements ActivityService { private ActivityComplaintMapper activityComplaintMapper; @Autowired private ActivityMapper activityMapper; - + @Autowired + private ActivityUserMapper activityUserMapper; /** * 投诉活动 * @param map 投诉数据 @@ -57,11 +60,16 @@ public class ActivityServiceImpl implements ActivityService { } Integer statue = 0; Double money = Double.valueOf(map.get("money").toString()); - Integer peopelCount = 0; + Integer peopelCount = 1; Integer maxCount = Integer.valueOf(map.get("maxCount").toString()); Date createTime = new Date(); String content = String.valueOf(map.get("content")); Activity activity = new Activity(userId,picPath,type,title,startTime,endTime,statue,money,peopelCount,maxCount,createTime,content); - activityMapper.insertSelective(activity); + //保存活动到数据库 + Integer activityId = activityMapper.insertSelective(activity); + System.out.println(activity.getId()); + //保存当前发布人到活动用户中间表中,即报名表 + ActivityUser activityUser = new ActivityUser(activity.getId(),userId); + activityUserMapper.insertSelective(activityUser); } } diff --git a/communityservice/src/main/resources/mapper/ActivityMapper.xml b/communityservice/src/main/resources/mapper/ActivityMapper.xml index 80512f4..e5642ac 100644 --- a/communityservice/src/main/resources/mapper/ActivityMapper.xml +++ b/communityservice/src/main/resources/mapper/ActivityMapper.xml @@ -49,7 +49,7 @@ #{caPeopelCount,jdbcType=INTEGER}, #{caMaxPeopleCount,jdbcType=INTEGER}, #{caCreateTime,jdbcType=TIMESTAMP}, #{caContent,jdbcType=LONGVARCHAR}) - + insert into community_activity -- Gitee