├── .idea ├── compiler.xml ├── encodings.xml ├── misc.xml ├── uiDesigner.xml └── vcs.xml ├── README.md ├── pom.xml ├── tensquare_article ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── tensquare │ │ └── article │ │ ├── ArticleApplication.java │ │ ├── controller │ │ ├── ArticleController.java │ │ ├── BaseExceptionHandler.java │ │ ├── ChannelController.java │ │ └── ColumnController.java │ │ ├── dao │ │ ├── ArticleDao.java │ │ ├── ChannelDao.java │ │ └── ColumnDao.java │ │ ├── pojo │ │ ├── Article.java │ │ ├── Channel.java │ │ └── Column.java │ │ └── service │ │ ├── ArticleService.java │ │ ├── ChannelService.java │ │ └── ColumnService.java │ └── resources │ └── application.yml ├── tensquare_base ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── tensquare │ │ └── base │ │ ├── BaseApplication.java │ │ ├── controller │ │ ├── BaseExceptionHandler.java │ │ └── LabelController.java │ │ ├── dao │ │ └── LabelDao.java │ │ ├── pojo │ │ └── Label.java │ │ └── service │ │ └── LabelService.java │ └── resources │ └── application.yml ├── tensquare_common ├── pom.xml └── src │ ├── main │ └── java │ │ ├── entity │ │ ├── PageResult.java │ │ ├── Result.java │ │ └── StatusCode.java │ │ └── util │ │ ├── IdWorker.java │ │ └── JwtUtil.java │ └── test │ └── java │ └── com │ └── tensquare │ └── jwt │ ├── CreateJwt.java │ └── ParseJwtTest.java ├── tensquare_eureka ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── tensquare │ │ └── eureka │ │ └── EurekaServer.java │ └── resources │ └── application.yml ├── tensquare_friend ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── tensquare │ │ └── friend │ │ ├── FriendApplication.java │ │ ├── client │ │ └── UserClient.java │ │ ├── config │ │ └── InterceptorConfig.java │ │ ├── controller │ │ └── FriendController.java │ │ ├── dao │ │ ├── FriendDao.java │ │ └── NoFriendDao.java │ │ ├── interceptor │ │ └── JwtInterceptor.java │ │ ├── pojo │ │ ├── Friend.java │ │ └── NoFriend.java │ │ └── service │ │ └── FriendService.java │ └── resources │ └── application.yml ├── tensquare_gathering ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── tensquare │ │ └── gathering │ │ ├── GatheringApplication.java │ │ ├── controller │ │ ├── BaseExceptionHandler.java │ │ └── GatheringController.java │ │ ├── dao │ │ └── GatheringDao.java │ │ ├── pojo │ │ └── Gathering.java │ │ └── service │ │ └── GatheringService.java │ └── resources │ └── application.yml ├── tensquare_manager ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── tensquare │ │ └── manager │ │ ├── ManagerApplication.java │ │ └── filter │ │ └── ManagerFilter.java │ └── resources │ └── application.yml ├── tensquare_parent52.iml ├── tensquare_qa ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── tensquare │ │ └── qa │ │ ├── QaApplication.java │ │ ├── client │ │ ├── BaseClient.java │ │ └── impl │ │ │ └── BaseClientImpl.java │ │ ├── config │ │ └── InterceptorConfig.java │ │ ├── controller │ │ ├── BaseExceptionHandler.java │ │ ├── ProblemController.java │ │ └── ReplyController.java │ │ ├── dao │ │ ├── ProblemDao.java │ │ └── ReplyDao.java │ │ ├── interceptor │ │ └── JwtInterceptor.java │ │ ├── pojo │ │ ├── Problem.java │ │ └── Reply.java │ │ └── service │ │ ├── ProblemService.java │ │ └── ReplyService.java │ └── resources │ └── application.yml ├── tensquare_rabbitmqtest ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── tensquare │ │ │ └── rabbit │ │ │ ├── RabbitApplication.java │ │ │ └── customer │ │ │ ├── Customer1.java │ │ │ ├── Customer2.java │ │ │ └── Customer3.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── tensquare │ └── test │ └── ProductTest.java ├── tensquare_recruit ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── tensquare │ │ └── recruit │ │ ├── RecruitApplication.java │ │ ├── controller │ │ ├── BaseExceptionHandler.java │ │ ├── EnterpriseController.java │ │ └── RecruitController.java │ │ ├── dao │ │ ├── EnterpriseDao.java │ │ └── RecruitDao.java │ │ ├── pojo │ │ ├── Enterprise.java │ │ └── Recruit.java │ │ └── service │ │ ├── EnterpriseService.java │ │ └── RecruitService.java │ └── resources │ └── application.yml ├── tensquare_search ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── tensquare │ │ └── search │ │ ├── SearchApplication.java │ │ ├── controller │ │ └── ArticleController.java │ │ ├── dao │ │ └── ArticleDao.java │ │ ├── pojo │ │ └── Article.java │ │ └── service │ │ └── ArticleService.java │ └── resources │ └── application.yml ├── tensquare_sms ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── tensquare │ │ └── sms │ │ ├── SmsApplication.java │ │ └── listener │ │ └── SmsListener.java │ └── resources │ └── application.yml ├── tensquare_spit ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── tensquare │ │ └── spit │ │ ├── SpitApplication.java │ │ ├── controller │ │ └── SpitController.java │ │ ├── dao │ │ └── SpitDao.java │ │ ├── pojo │ │ └── Spit.java │ │ └── service │ │ └── SpitService.java │ └── resources │ └── application.yml ├── tensquare_user ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── tensquare │ │ └── user │ │ ├── UserApplication.java │ │ ├── config │ │ ├── InterceptorConfig.java │ │ └── WebSecurityConfig.java │ │ ├── controller │ │ ├── AdminController.java │ │ ├── BaseExceptionHandler.java │ │ └── UserController.java │ │ ├── dao │ │ ├── AdminDao.java │ │ └── UserDao.java │ │ ├── interceptor │ │ └── JwtInterceptor.java │ │ ├── pojo │ │ ├── Admin.java │ │ └── User.java │ │ └── service │ │ ├── AdminService.java │ │ └── UserService.java │ └── resources │ └── application.yml └── tensquare_web ├── pom.xml └── src └── main ├── java └── com │ └── tensquare │ └── web │ ├── WebApplication.java │ └── filter │ └── WebFilter.java └── resources └── application.yml /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 45 | 46 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tensquare_parent52 2 | 十次方项目:springboot+springcloud社交项目 3 | 4 | 配置资料: 5 | 链接:https://pan.baidu.com/s/1Sfk1Nq0Jiab6dKEJP71otQ 6 | 提取码:yikf 7 | 8 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.tensquare 8 | tensquare_parent52 9 | 1.0-SNAPSHOT 10 | 11 | tensquare_common 12 | tensquare_base 13 | tensquare_recruit 14 | tensquare_qa 15 | tensquare_article 16 | tensquare_gathering 17 | tensquare_spit 18 | tensquare_search 19 | tensquare_rabbitmqtest 20 | tensquare_user 21 | tensquare_sms 22 | tensquare_eureka 23 | tensquare_friend 24 | tensquare_manager 25 | tensquare_web 26 | 27 | pom 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-parent 32 | 2.1.6.RELEASE 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-dependencies 41 | Greenwich.RELEASE 42 | pom 43 | import 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-starter-web 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-starter-test 56 | test 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | org.projectlombok 66 | lombok 67 | 1.18.4 68 | provided 69 | 70 | 71 | 72 | org.springframework.boot 73 | spring-boot-devtools 74 | 75 | 76 | 77 | 78 | 79 | spring-snapshots 80 | Spring Snapshots 81 | https://repo.spring.io/snapshot 82 | 83 | true 84 | 85 | 86 | 87 | spring-milestones 88 | Spring Milestones 89 | https://repo.spring.io/milestone 90 | 91 | false 92 | 93 | 94 | 95 | 96 | 97 | 98 | spring-snapshots 99 | Spring Snapshots 100 | https://repo.spring.io/snapshot 101 | 102 | true 103 | 104 | 105 | 106 | spring-milestones 107 | Spring Milestones 108 | https://repo.spring.io/milestone 109 | 110 | false 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /tensquare_article/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.tensquare 5 | tensquare_parent52 6 | 1.0-SNAPSHOT 7 | 8 | tensquare_article 9 | 10 | 11 | org.springframework.boot 12 | spring-boot-starter-data-jpa 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-data-redis 17 | 18 | 19 | mysql 20 | mysql-connector-java 21 | 22 | 23 | com.tensquare 24 | tensquare_common 25 | 1.0-SNAPSHOT 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-netflix-eureka-client 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /tensquare_article/src/main/java/com/tensquare/article/ArticleApplication.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.article; 2 | import org.springframework.boot.SpringApplication; 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 5 | import org.springframework.context.annotation.Bean; 6 | import util.IdWorker; 7 | @SpringBootApplication 8 | @EnableEurekaClient 9 | public class ArticleApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ArticleApplication.class, args); 13 | } 14 | 15 | @Bean 16 | public IdWorker idWorkker(){ 17 | return new IdWorker(1, 1); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /tensquare_article/src/main/java/com/tensquare/article/controller/ArticleController.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.article.controller; 2 | import java.util.List; 3 | import java.util.Map; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.web.bind.annotation.CrossOrigin; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestBody; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import com.tensquare.article.pojo.Article; 15 | import com.tensquare.article.service.ArticleService; 16 | 17 | import entity.PageResult; 18 | import entity.Result; 19 | import entity.StatusCode; 20 | /** 21 | * 控制器层 22 | * @author Administrator 23 | * 24 | */ 25 | @RestController 26 | @CrossOrigin 27 | @RequestMapping("/article") 28 | public class ArticleController { 29 | 30 | @Autowired 31 | private ArticleService articleService; 32 | 33 | @RequestMapping(value="/examine/{articleId}",method=RequestMethod.PUT) 34 | public Result examine(@PathVariable String articleId){ 35 | articleService.updateState(articleId); 36 | return new Result(true,StatusCode.OK,"审核成功"); 37 | } 38 | 39 | @RequestMapping(value="/thumbup/{articleId}",method=RequestMethod.PUT) 40 | public Result thumbup(@PathVariable String articleId){ 41 | articleService.addThumbup(articleId); 42 | return new Result(true,StatusCode.OK,"点赞成功"); 43 | 44 | } 45 | 46 | 47 | /** 48 | * 查询全部数据 49 | * @return 50 | */ 51 | @RequestMapping(method= RequestMethod.GET) 52 | public Result findAll(){ 53 | return new Result(true,StatusCode.OK,"查询成功",articleService.findAll()); 54 | } 55 | 56 | /** 57 | * 根据ID查询 58 | * @param id ID 59 | * @return 60 | */ 61 | @RequestMapping(value="/{id}",method= RequestMethod.GET) 62 | public Result findById(@PathVariable String id){ 63 | return new Result(true,StatusCode.OK,"查询成功",articleService.findById(id)); 64 | } 65 | 66 | 67 | /** 68 | * 分页+多条件查询 69 | * @param searchMap 查询条件封装 70 | * @param page 页码 71 | * @param size 页大小 72 | * @return 分页结果 73 | */ 74 | @RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST) 75 | public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){ 76 | Page
pageList = articleService.findSearch(searchMap, page, size); 77 | return new Result(true,StatusCode.OK,"查询成功", new PageResult
(pageList.getTotalElements(), pageList.getContent()) ); 78 | } 79 | 80 | /** 81 | * 根据条件查询 82 | * @param searchMap 83 | * @return 84 | */ 85 | @RequestMapping(value="/search",method = RequestMethod.POST) 86 | public Result findSearch( @RequestBody Map searchMap){ 87 | return new Result(true,StatusCode.OK,"查询成功",articleService.findSearch(searchMap)); 88 | } 89 | 90 | /** 91 | * 增加 92 | * @param article 93 | */ 94 | @RequestMapping(method=RequestMethod.POST) 95 | public Result add(@RequestBody Article article ){ 96 | articleService.add(article); 97 | return new Result(true,StatusCode.OK,"增加成功"); 98 | } 99 | 100 | /** 101 | * 修改 102 | * @param article 103 | */ 104 | @RequestMapping(value="/{id}",method= RequestMethod.PUT) 105 | public Result update(@RequestBody Article article, @PathVariable String id ){ 106 | article.setId(id); 107 | articleService.update(article); 108 | return new Result(true,StatusCode.OK,"修改成功"); 109 | } 110 | 111 | /** 112 | * 删除 113 | * @param id 114 | */ 115 | @RequestMapping(value="/{id}",method= RequestMethod.DELETE) 116 | public Result delete(@PathVariable String id ){ 117 | articleService.deleteById(id); 118 | return new Result(true,StatusCode.OK,"删除成功"); 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /tensquare_article/src/main/java/com/tensquare/article/controller/BaseExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.article.controller; 2 | import entity.Result; 3 | import entity.StatusCode; 4 | import org.springframework.web.bind.annotation.ControllerAdvice; 5 | import org.springframework.web.bind.annotation.ExceptionHandler; 6 | import org.springframework.web.bind.annotation.ResponseBody; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServletResponse; 9 | import java.io.IOException; 10 | /** 11 | * 统一异常处理类 12 | */ 13 | @ControllerAdvice 14 | public class BaseExceptionHandler { 15 | 16 | @ExceptionHandler(value = Exception.class) 17 | @ResponseBody 18 | public Result error(Exception e){ 19 | e.printStackTrace(); 20 | return new Result(false, StatusCode.ERROR, "执行出错"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tensquare_article/src/main/java/com/tensquare/article/controller/ChannelController.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.article.controller; 2 | import java.util.List; 3 | import java.util.Map; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.web.bind.annotation.CrossOrigin; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestBody; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import com.tensquare.article.pojo.Channel; 15 | import com.tensquare.article.service.ChannelService; 16 | 17 | import entity.PageResult; 18 | import entity.Result; 19 | import entity.StatusCode; 20 | /** 21 | * 控制器层 22 | * @author Administrator 23 | * 24 | */ 25 | @RestController 26 | @CrossOrigin 27 | @RequestMapping("/channel") 28 | public class ChannelController { 29 | 30 | @Autowired 31 | private ChannelService channelService; 32 | 33 | 34 | /** 35 | * 查询全部数据 36 | * @return 37 | */ 38 | @RequestMapping(method= RequestMethod.GET) 39 | public Result findAll(){ 40 | return new Result(true,StatusCode.OK,"查询成功",channelService.findAll()); 41 | } 42 | 43 | /** 44 | * 根据ID查询 45 | * @param id ID 46 | * @return 47 | */ 48 | @RequestMapping(value="/{id}",method= RequestMethod.GET) 49 | public Result findById(@PathVariable String id){ 50 | return new Result(true,StatusCode.OK,"查询成功",channelService.findById(id)); 51 | } 52 | 53 | 54 | /** 55 | * 分页+多条件查询 56 | * @param searchMap 查询条件封装 57 | * @param page 页码 58 | * @param size 页大小 59 | * @return 分页结果 60 | */ 61 | @RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST) 62 | public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){ 63 | Page pageList = channelService.findSearch(searchMap, page, size); 64 | return new Result(true,StatusCode.OK,"查询成功", new PageResult(pageList.getTotalElements(), pageList.getContent()) ); 65 | } 66 | 67 | /** 68 | * 根据条件查询 69 | * @param searchMap 70 | * @return 71 | */ 72 | @RequestMapping(value="/search",method = RequestMethod.POST) 73 | public Result findSearch( @RequestBody Map searchMap){ 74 | return new Result(true,StatusCode.OK,"查询成功",channelService.findSearch(searchMap)); 75 | } 76 | 77 | /** 78 | * 增加 79 | * @param channel 80 | */ 81 | @RequestMapping(method=RequestMethod.POST) 82 | public Result add(@RequestBody Channel channel ){ 83 | channelService.add(channel); 84 | return new Result(true,StatusCode.OK,"增加成功"); 85 | } 86 | 87 | /** 88 | * 修改 89 | * @param channel 90 | */ 91 | @RequestMapping(value="/{id}",method= RequestMethod.PUT) 92 | public Result update(@RequestBody Channel channel, @PathVariable String id ){ 93 | channel.setId(id); 94 | channelService.update(channel); 95 | return new Result(true,StatusCode.OK,"修改成功"); 96 | } 97 | 98 | /** 99 | * 删除 100 | * @param id 101 | */ 102 | @RequestMapping(value="/{id}",method= RequestMethod.DELETE) 103 | public Result delete(@PathVariable String id ){ 104 | channelService.deleteById(id); 105 | return new Result(true,StatusCode.OK,"删除成功"); 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /tensquare_article/src/main/java/com/tensquare/article/controller/ColumnController.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.article.controller; 2 | import java.util.List; 3 | import java.util.Map; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.web.bind.annotation.CrossOrigin; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestBody; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import com.tensquare.article.pojo.Column; 15 | import com.tensquare.article.service.ColumnService; 16 | 17 | import entity.PageResult; 18 | import entity.Result; 19 | import entity.StatusCode; 20 | /** 21 | * 控制器层 22 | * @author Administrator 23 | * 24 | */ 25 | @RestController 26 | @CrossOrigin 27 | @RequestMapping("/column") 28 | public class ColumnController { 29 | 30 | @Autowired 31 | private ColumnService columnService; 32 | 33 | 34 | /** 35 | * 查询全部数据 36 | * @return 37 | */ 38 | @RequestMapping(method= RequestMethod.GET) 39 | public Result findAll(){ 40 | return new Result(true,StatusCode.OK,"查询成功",columnService.findAll()); 41 | } 42 | 43 | /** 44 | * 根据ID查询 45 | * @param id ID 46 | * @return 47 | */ 48 | @RequestMapping(value="/{id}",method= RequestMethod.GET) 49 | public Result findById(@PathVariable String id){ 50 | return new Result(true,StatusCode.OK,"查询成功",columnService.findById(id)); 51 | } 52 | 53 | 54 | /** 55 | * 分页+多条件查询 56 | * @param searchMap 查询条件封装 57 | * @param page 页码 58 | * @param size 页大小 59 | * @return 分页结果 60 | */ 61 | @RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST) 62 | public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){ 63 | Page pageList = columnService.findSearch(searchMap, page, size); 64 | return new Result(true,StatusCode.OK,"查询成功", new PageResult(pageList.getTotalElements(), pageList.getContent()) ); 65 | } 66 | 67 | /** 68 | * 根据条件查询 69 | * @param searchMap 70 | * @return 71 | */ 72 | @RequestMapping(value="/search",method = RequestMethod.POST) 73 | public Result findSearch( @RequestBody Map searchMap){ 74 | return new Result(true,StatusCode.OK,"查询成功",columnService.findSearch(searchMap)); 75 | } 76 | 77 | /** 78 | * 增加 79 | * @param column 80 | */ 81 | @RequestMapping(method=RequestMethod.POST) 82 | public Result add(@RequestBody Column column ){ 83 | columnService.add(column); 84 | return new Result(true,StatusCode.OK,"增加成功"); 85 | } 86 | 87 | /** 88 | * 修改 89 | * @param column 90 | */ 91 | @RequestMapping(value="/{id}",method= RequestMethod.PUT) 92 | public Result update(@RequestBody Column column, @PathVariable String id ){ 93 | column.setId(id); 94 | columnService.update(column); 95 | return new Result(true,StatusCode.OK,"修改成功"); 96 | } 97 | 98 | /** 99 | * 删除 100 | * @param id 101 | */ 102 | @RequestMapping(value="/{id}",method= RequestMethod.DELETE) 103 | public Result delete(@PathVariable String id ){ 104 | columnService.deleteById(id); 105 | return new Result(true,StatusCode.OK,"删除成功"); 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /tensquare_article/src/main/java/com/tensquare/article/dao/ArticleDao.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.article.dao; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 | 6 | import com.tensquare.article.pojo.Article; 7 | import org.springframework.data.jpa.repository.Modifying; 8 | import org.springframework.data.jpa.repository.Query; 9 | 10 | /** 11 | * 数据访问接口 12 | * @author Administrator 13 | * 14 | */ 15 | public interface ArticleDao extends JpaRepository,JpaSpecificationExecutor
{ 16 | 17 | @Modifying 18 | @Query(value="UPDATE tb_article SET state=1 WHERE id=?",nativeQuery = true) 19 | public void updateState(String id); 20 | 21 | @Modifying 22 | @Query(value="UPDATE tb_article SET thumbup=thumbup+1 WHERE id=?",nativeQuery = true) 23 | public void addThumbup(String id); 24 | } 25 | -------------------------------------------------------------------------------- /tensquare_article/src/main/java/com/tensquare/article/dao/ChannelDao.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.article.dao; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 | 6 | import com.tensquare.article.pojo.Channel; 7 | /** 8 | * 数据访问接口 9 | * @author Administrator 10 | * 11 | */ 12 | public interface ChannelDao extends JpaRepository,JpaSpecificationExecutor{ 13 | 14 | } 15 | -------------------------------------------------------------------------------- /tensquare_article/src/main/java/com/tensquare/article/dao/ColumnDao.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.article.dao; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 | 6 | import com.tensquare.article.pojo.Column; 7 | /** 8 | * 数据访问接口 9 | * @author Administrator 10 | * 11 | */ 12 | public interface ColumnDao extends JpaRepository,JpaSpecificationExecutor{ 13 | 14 | } 15 | -------------------------------------------------------------------------------- /tensquare_article/src/main/java/com/tensquare/article/pojo/Article.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.article.pojo; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | import javax.persistence.Table; 6 | import java.io.Serializable; 7 | /** 8 | * 实体类 9 | * @author Administrator 10 | * 11 | */ 12 | @Entity 13 | @Table(name="tb_article") 14 | public class Article implements Serializable{ 15 | 16 | @Id 17 | private String id;//ID 18 | 19 | 20 | 21 | private String columnid;//专栏ID 22 | private String userid;//用户ID 23 | private String title;//标题 24 | private String content;//文章正文 25 | private String image;//文章封面 26 | private java.util.Date createtime;//发表日期 27 | private java.util.Date updatetime;//修改日期 28 | private String ispublic;//是否公开 29 | private String istop;//是否置顶 30 | private Integer visits;//浏览量 31 | private Integer thumbup;//点赞数 32 | private Integer comment;//评论数 33 | private String state;//审核状态 34 | private String channelid;//所属频道 35 | private String url;//URL 36 | private String type;//类型 37 | 38 | 39 | public String getId() { 40 | return id; 41 | } 42 | public void setId(String id) { 43 | this.id = id; 44 | } 45 | 46 | public String getColumnid() { 47 | return columnid; 48 | } 49 | public void setColumnid(String columnid) { 50 | this.columnid = columnid; 51 | } 52 | 53 | public String getUserid() { 54 | return userid; 55 | } 56 | public void setUserid(String userid) { 57 | this.userid = userid; 58 | } 59 | 60 | public String getTitle() { 61 | return title; 62 | } 63 | public void setTitle(String title) { 64 | this.title = title; 65 | } 66 | 67 | public String getContent() { 68 | return content; 69 | } 70 | public void setContent(String content) { 71 | this.content = content; 72 | } 73 | 74 | public String getImage() { 75 | return image; 76 | } 77 | public void setImage(String image) { 78 | this.image = image; 79 | } 80 | 81 | public java.util.Date getCreatetime() { 82 | return createtime; 83 | } 84 | public void setCreatetime(java.util.Date createtime) { 85 | this.createtime = createtime; 86 | } 87 | 88 | public java.util.Date getUpdatetime() { 89 | return updatetime; 90 | } 91 | public void setUpdatetime(java.util.Date updatetime) { 92 | this.updatetime = updatetime; 93 | } 94 | 95 | public String getIspublic() { 96 | return ispublic; 97 | } 98 | public void setIspublic(String ispublic) { 99 | this.ispublic = ispublic; 100 | } 101 | 102 | public String getIstop() { 103 | return istop; 104 | } 105 | public void setIstop(String istop) { 106 | this.istop = istop; 107 | } 108 | 109 | public Integer getVisits() { 110 | return visits; 111 | } 112 | public void setVisits(Integer visits) { 113 | this.visits = visits; 114 | } 115 | 116 | public Integer getThumbup() { 117 | return thumbup; 118 | } 119 | public void setThumbup(Integer thumbup) { 120 | this.thumbup = thumbup; 121 | } 122 | 123 | public Integer getComment() { 124 | return comment; 125 | } 126 | public void setComment(Integer comment) { 127 | this.comment = comment; 128 | } 129 | 130 | public String getState() { 131 | return state; 132 | } 133 | public void setState(String state) { 134 | this.state = state; 135 | } 136 | 137 | public String getChannelid() { 138 | return channelid; 139 | } 140 | public void setChannelid(String channelid) { 141 | this.channelid = channelid; 142 | } 143 | 144 | public String getUrl() { 145 | return url; 146 | } 147 | public void setUrl(String url) { 148 | this.url = url; 149 | } 150 | 151 | public String getType() { 152 | return type; 153 | } 154 | public void setType(String type) { 155 | this.type = type; 156 | } 157 | 158 | 159 | 160 | } 161 | -------------------------------------------------------------------------------- /tensquare_article/src/main/java/com/tensquare/article/pojo/Channel.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.article.pojo; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | import javax.persistence.Table; 6 | import java.io.Serializable; 7 | /** 8 | * 实体类 9 | * @author Administrator 10 | * 11 | */ 12 | @Entity 13 | @Table(name="tb_channel") 14 | public class Channel implements Serializable{ 15 | 16 | @Id 17 | private String id;//ID 18 | 19 | 20 | 21 | private String name;//频道名称 22 | private String state;//状态 23 | 24 | 25 | public String getId() { 26 | return id; 27 | } 28 | public void setId(String id) { 29 | this.id = id; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | 39 | public String getState() { 40 | return state; 41 | } 42 | public void setState(String state) { 43 | this.state = state; 44 | } 45 | 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /tensquare_article/src/main/java/com/tensquare/article/pojo/Column.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.article.pojo; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | import javax.persistence.Table; 6 | import java.io.Serializable; 7 | /** 8 | * 实体类 9 | * @author Administrator 10 | * 11 | */ 12 | @Entity 13 | @Table(name="tb_column") 14 | public class Column implements Serializable{ 15 | 16 | @Id 17 | private String id;//ID 18 | 19 | 20 | 21 | private String name;//专栏名称 22 | private String summary;//专栏简介 23 | private String userid;//用户ID 24 | private java.util.Date createtime;//申请日期 25 | private java.util.Date checktime;//审核日期 26 | private String state;//状态 27 | 28 | 29 | public String getId() { 30 | return id; 31 | } 32 | public void setId(String id) { 33 | this.id = id; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | public String getSummary() { 44 | return summary; 45 | } 46 | public void setSummary(String summary) { 47 | this.summary = summary; 48 | } 49 | 50 | public String getUserid() { 51 | return userid; 52 | } 53 | public void setUserid(String userid) { 54 | this.userid = userid; 55 | } 56 | 57 | public java.util.Date getCreatetime() { 58 | return createtime; 59 | } 60 | public void setCreatetime(java.util.Date createtime) { 61 | this.createtime = createtime; 62 | } 63 | 64 | public java.util.Date getChecktime() { 65 | return checktime; 66 | } 67 | public void setChecktime(java.util.Date checktime) { 68 | this.checktime = checktime; 69 | } 70 | 71 | public String getState() { 72 | return state; 73 | } 74 | public void setState(String state) { 75 | this.state = state; 76 | } 77 | 78 | 79 | 80 | } 81 | -------------------------------------------------------------------------------- /tensquare_article/src/main/java/com/tensquare/article/service/ChannelService.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.article.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import javax.persistence.criteria.CriteriaBuilder; 9 | import javax.persistence.criteria.CriteriaQuery; 10 | import javax.persistence.criteria.Expression; 11 | import javax.persistence.criteria.Predicate; 12 | import javax.persistence.criteria.Root; 13 | import javax.persistence.criteria.Selection; 14 | 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.data.domain.Page; 17 | import org.springframework.data.domain.PageRequest; 18 | import org.springframework.data.domain.Sort; 19 | import org.springframework.data.jpa.domain.Specification; 20 | import org.springframework.stereotype.Service; 21 | 22 | import util.IdWorker; 23 | 24 | import com.tensquare.article.dao.ChannelDao; 25 | import com.tensquare.article.pojo.Channel; 26 | 27 | /** 28 | * 服务层 29 | * 30 | * @author Administrator 31 | * 32 | */ 33 | @Service 34 | public class ChannelService { 35 | 36 | @Autowired 37 | private ChannelDao channelDao; 38 | 39 | @Autowired 40 | private IdWorker idWorker; 41 | 42 | /** 43 | * 查询全部列表 44 | * @return 45 | */ 46 | public List findAll() { 47 | return channelDao.findAll(); 48 | } 49 | 50 | 51 | /** 52 | * 条件查询+分页 53 | * @param whereMap 54 | * @param page 55 | * @param size 56 | * @return 57 | */ 58 | public Page findSearch(Map whereMap, int page, int size) { 59 | Specification specification = createSpecification(whereMap); 60 | PageRequest pageRequest = PageRequest.of(page-1, size); 61 | return channelDao.findAll(specification, pageRequest); 62 | } 63 | 64 | 65 | /** 66 | * 条件查询 67 | * @param whereMap 68 | * @return 69 | */ 70 | public List findSearch(Map whereMap) { 71 | Specification specification = createSpecification(whereMap); 72 | return channelDao.findAll(specification); 73 | } 74 | 75 | /** 76 | * 根据ID查询实体 77 | * @param id 78 | * @return 79 | */ 80 | public Channel findById(String id) { 81 | return channelDao.findById(id).get(); 82 | } 83 | 84 | /** 85 | * 增加 86 | * @param channel 87 | */ 88 | public void add(Channel channel) { 89 | channel.setId( idWorker.nextId()+"" ); 90 | channelDao.save(channel); 91 | } 92 | 93 | /** 94 | * 修改 95 | * @param channel 96 | */ 97 | public void update(Channel channel) { 98 | channelDao.save(channel); 99 | } 100 | 101 | /** 102 | * 删除 103 | * @param id 104 | */ 105 | public void deleteById(String id) { 106 | channelDao.deleteById(id); 107 | } 108 | 109 | /** 110 | * 动态条件构建 111 | * @param searchMap 112 | * @return 113 | */ 114 | private Specification createSpecification(Map searchMap) { 115 | 116 | return new Specification() { 117 | 118 | @Override 119 | public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb) { 120 | List predicateList = new ArrayList(); 121 | // ID 122 | if (searchMap.get("id")!=null && !"".equals(searchMap.get("id"))) { 123 | predicateList.add(cb.like(root.get("id").as(String.class), "%"+(String)searchMap.get("id")+"%")); 124 | } 125 | // 频道名称 126 | if (searchMap.get("name")!=null && !"".equals(searchMap.get("name"))) { 127 | predicateList.add(cb.like(root.get("name").as(String.class), "%"+(String)searchMap.get("name")+"%")); 128 | } 129 | // 状态 130 | if (searchMap.get("state")!=null && !"".equals(searchMap.get("state"))) { 131 | predicateList.add(cb.like(root.get("state").as(String.class), "%"+(String)searchMap.get("state")+"%")); 132 | } 133 | 134 | return cb.and( predicateList.toArray(new Predicate[predicateList.size()])); 135 | 136 | } 137 | }; 138 | 139 | } 140 | 141 | } 142 | -------------------------------------------------------------------------------- /tensquare_article/src/main/java/com/tensquare/article/service/ColumnService.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.article.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import javax.persistence.criteria.CriteriaBuilder; 9 | import javax.persistence.criteria.CriteriaQuery; 10 | import javax.persistence.criteria.Expression; 11 | import javax.persistence.criteria.Predicate; 12 | import javax.persistence.criteria.Root; 13 | import javax.persistence.criteria.Selection; 14 | 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.data.domain.Page; 17 | import org.springframework.data.domain.PageRequest; 18 | import org.springframework.data.domain.Sort; 19 | import org.springframework.data.jpa.domain.Specification; 20 | import org.springframework.stereotype.Service; 21 | 22 | import util.IdWorker; 23 | 24 | import com.tensquare.article.dao.ColumnDao; 25 | import com.tensquare.article.pojo.Column; 26 | 27 | /** 28 | * 服务层 29 | * 30 | * @author Administrator 31 | * 32 | */ 33 | @Service 34 | public class ColumnService { 35 | 36 | @Autowired 37 | private ColumnDao columnDao; 38 | 39 | @Autowired 40 | private IdWorker idWorker; 41 | 42 | /** 43 | * 查询全部列表 44 | * @return 45 | */ 46 | public List findAll() { 47 | return columnDao.findAll(); 48 | } 49 | 50 | 51 | /** 52 | * 条件查询+分页 53 | * @param whereMap 54 | * @param page 55 | * @param size 56 | * @return 57 | */ 58 | public Page findSearch(Map whereMap, int page, int size) { 59 | Specification specification = createSpecification(whereMap); 60 | PageRequest pageRequest = PageRequest.of(page-1, size); 61 | return columnDao.findAll(specification, pageRequest); 62 | } 63 | 64 | 65 | /** 66 | * 条件查询 67 | * @param whereMap 68 | * @return 69 | */ 70 | public List findSearch(Map whereMap) { 71 | Specification specification = createSpecification(whereMap); 72 | return columnDao.findAll(specification); 73 | } 74 | 75 | /** 76 | * 根据ID查询实体 77 | * @param id 78 | * @return 79 | */ 80 | public Column findById(String id) { 81 | return columnDao.findById(id).get(); 82 | } 83 | 84 | /** 85 | * 增加 86 | * @param column 87 | */ 88 | public void add(Column column) { 89 | column.setId( idWorker.nextId()+"" ); 90 | columnDao.save(column); 91 | } 92 | 93 | /** 94 | * 修改 95 | * @param column 96 | */ 97 | public void update(Column column) { 98 | columnDao.save(column); 99 | } 100 | 101 | /** 102 | * 删除 103 | * @param id 104 | */ 105 | public void deleteById(String id) { 106 | columnDao.deleteById(id); 107 | } 108 | 109 | /** 110 | * 动态条件构建 111 | * @param searchMap 112 | * @return 113 | */ 114 | private Specification createSpecification(Map searchMap) { 115 | 116 | return new Specification() { 117 | 118 | @Override 119 | public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb) { 120 | List predicateList = new ArrayList(); 121 | // ID 122 | if (searchMap.get("id")!=null && !"".equals(searchMap.get("id"))) { 123 | predicateList.add(cb.like(root.get("id").as(String.class), "%"+(String)searchMap.get("id")+"%")); 124 | } 125 | // 专栏名称 126 | if (searchMap.get("name")!=null && !"".equals(searchMap.get("name"))) { 127 | predicateList.add(cb.like(root.get("name").as(String.class), "%"+(String)searchMap.get("name")+"%")); 128 | } 129 | // 专栏简介 130 | if (searchMap.get("summary")!=null && !"".equals(searchMap.get("summary"))) { 131 | predicateList.add(cb.like(root.get("summary").as(String.class), "%"+(String)searchMap.get("summary")+"%")); 132 | } 133 | // 用户ID 134 | if (searchMap.get("userid")!=null && !"".equals(searchMap.get("userid"))) { 135 | predicateList.add(cb.like(root.get("userid").as(String.class), "%"+(String)searchMap.get("userid")+"%")); 136 | } 137 | // 状态 138 | if (searchMap.get("state")!=null && !"".equals(searchMap.get("state"))) { 139 | predicateList.add(cb.like(root.get("state").as(String.class), "%"+(String)searchMap.get("state")+"%")); 140 | } 141 | 142 | return cb.and( predicateList.toArray(new Predicate[predicateList.size()])); 143 | 144 | } 145 | }; 146 | 147 | } 148 | 149 | } 150 | -------------------------------------------------------------------------------- /tensquare_article/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9004 3 | spring: 4 | application: 5 | name: tensquare-article #指定服务名 6 | datasource: 7 | driverClassName: com.mysql.jdbc.Driver 8 | url: jdbc:mysql://192.168.213.135:3306/tensquare_article?characterEncoding=UTF8 9 | username: root 10 | password: root 11 | jpa: 12 | database: MySQL 13 | show-sql: true 14 | redis: 15 | host: 192.168.213.135 16 | eureka: 17 | client: 18 | service-url: 19 | defaultZone: http://127.0.0.1:6868/eureka/ 20 | instance: 21 | prefer-ip-address: true 22 | 23 | -------------------------------------------------------------------------------- /tensquare_base/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | tensquare_parent52 7 | com.tensquare 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | tensquare_base 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-data-jpa 18 | 19 | 20 | com.tensquare 21 | tensquare_common 22 | 1.0-SNAPSHOT 23 | 24 | 25 | mysql 26 | mysql-connector-java 27 | 28 | 29 | org.springframework.cloud 30 | spring-cloud-starter-netflix-eureka-client 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /tensquare_base/src/main/java/com/tensquare/base/BaseApplication.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.base; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 6 | import org.springframework.context.annotation.Bean; 7 | import util.IdWorker; 8 | 9 | @SpringBootApplication 10 | @EnableEurekaClient 11 | public class BaseApplication { 12 | public static void main(String[] args) { 13 | SpringApplication.run(BaseApplication.class,args); 14 | } 15 | 16 | @Bean 17 | public IdWorker idWorker(){ 18 | return new IdWorker(1,1); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tensquare_base/src/main/java/com/tensquare/base/controller/BaseExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.base.controller; 2 | 3 | 4 | import entity.Result; 5 | import entity.StatusCode; 6 | import org.springframework.web.bind.annotation.ExceptionHandler; 7 | import org.springframework.web.bind.annotation.RestControllerAdvice; 8 | 9 | @RestControllerAdvice 10 | public class BaseExceptionHandler { 11 | 12 | @ExceptionHandler(value = Exception.class) 13 | public Result exception(Exception e){ 14 | e.printStackTrace(); 15 | return new Result(false, StatusCode.ERROR,e.getMessage()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tensquare_base/src/main/java/com/tensquare/base/controller/LabelController.java: -------------------------------------------------------------------------------- 1 | package com.tensquare.base.controller; 2 | 3 | import com.tensquare.base.pojo.Label; 4 | import com.tensquare.base.service.LabelService; 5 | import entity.PageResult; 6 | import entity.Result; 7 | import entity.StatusCode; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.data.domain.Page; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | import javax.servlet.http.HttpServletRequest; 13 | import java.util.List; 14 | 15 | @RestController //ResponseBody+Controller 16 | @CrossOrigin //跨域 17 | @RequestMapping("/label") 18 | public class LabelController { 19 | 20 | @Autowired 21 | private LabelService labelService; 22 | @Autowired 23 | private HttpServletRequest request; 24 | 25 | @RequestMapping(method= RequestMethod.GET) 26 | public Result findAll(){ 27 | //获取头信息 28 | String header = request.getHeader("Authorization"); 29 | System.out.println(header); 30 | 31 | return new Result(true,StatusCode.OK,"查询成功",labelService.findAll()); 32 | } 33 | 34 | @RequestMapping(value="/{labelId}",method= RequestMethod.GET) 35 | public Result findById(@PathVariable("labelId") String labelId){ 36 | int i = 1/0; 37 | return new Result(true,StatusCode.OK,"查询成功",labelService.findById(labelId)); 38 | } 39 | 40 | @RequestMapping(method=RequestMethod.POST) 41 | public Result save(@RequestBody Label label){ 42 | labelService.save(label); 43 | return new Result(true,StatusCode.OK,"添加成功"); 44 | } 45 | 46 | @RequestMapping(value="/{labelId}",method=RequestMethod.PUT) 47 | public Result update(@PathVariable String labelId,@RequestBody Label label){ 48 | label.setId(labelId); 49 | labelService.update(label); 50 | return new Result(true,StatusCode.OK,"更新成功"); 51 | } 52 | 53 | @RequestMapping(value="/{labelId}",method=RequestMethod.DELETE) 54 | public Result deleteById(@PathVariable String labelId){ 55 | labelService.deleteById(labelId); 56 | return new Result(true,StatusCode.OK,"删除成功"); 57 | } 58 | 59 | @RequestMapping(value="/search",method=RequestMethod.POST) 60 | public Result findSearch(@RequestBody Label label){ 61 | List