├── README.md ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── cun │ │ └── itaem │ │ ├── ItaemApplication.java │ │ ├── conf │ │ └── CorsConfig.java │ │ ├── controller │ │ ├── BlogController.java │ │ ├── DirectionController.java │ │ ├── HonorController.java │ │ ├── MemberController.java │ │ └── ProductionController.java │ │ ├── dao │ │ ├── BlogDao.java │ │ ├── DirectionDao.java │ │ ├── HonorDao.java │ │ ├── MemberDao.java │ │ └── ProductionDao.java │ │ ├── entity │ │ ├── Blog.java │ │ ├── Direction.java │ │ ├── Honor.java │ │ ├── Member.java │ │ └── Production.java │ │ ├── service │ │ ├── BlogService.java │ │ ├── DirectionService.java │ │ ├── HonorService.java │ │ ├── MemberService.java │ │ ├── ProductionService.java │ │ └── impl │ │ │ ├── BlogServiceImpl.java │ │ │ ├── DirectionServiceImpl.java │ │ │ ├── HonorServiceImpl.java │ │ │ ├── MemberServiceImpl.java │ │ │ └── ProductionServiceImpl.java │ │ └── utils │ │ ├── Json.java │ │ └── Oss.java └── resources │ ├── application.properties │ └── application.yml └── test └── java └── com └── cun └── itaem └── ItaemApplicationTests.java /README.md: -------------------------------------------------------------------------------- 1 | # springboot_Vue 2 | springboot for VueCRUD 3 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.cun 7 | itaem 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | itaem 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.15.BUILD-SNAPSHOT 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-data-jpa 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | 38 | mysql 39 | mysql-connector-java 40 | runtime 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | 49 | 50 | io.springfox 51 | springfox-swagger2 52 | 2.7.0 53 | 54 | 55 | 56 | io.springfox 57 | springfox-swagger-ui 58 | 2.6.1 59 | 60 | 61 | 62 | 63 | com.aliyun.oss 64 | aliyun-sdk-oss 65 | 2.8.2 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | org.springframework.boot 74 | spring-boot-maven-plugin 75 | 76 | 77 | 78 | 79 | 80 | 81 | spring-snapshots 82 | Spring Snapshots 83 | https://repo.spring.io/snapshot 84 | 85 | true 86 | 87 | 88 | 89 | spring-milestones 90 | Spring Milestones 91 | https://repo.spring.io/milestone 92 | 93 | false 94 | 95 | 96 | 97 | 98 | 99 | 100 | spring-snapshots 101 | Spring Snapshots 102 | https://repo.spring.io/snapshot 103 | 104 | true 105 | 106 | 107 | 108 | spring-milestones 109 | Spring Milestones 110 | https://repo.spring.io/milestone 111 | 112 | false 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/ItaemApplication.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ItaemApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ItaemApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/conf/CorsConfig.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.conf; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.cors.CorsConfiguration; 6 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; 7 | import org.springframework.web.filter.CorsFilter; 8 | /** 9 | * 实现基本的跨域请求 10 | * @author linhongcun 11 | * 12 | */ 13 | @Configuration 14 | public class CorsConfig { 15 | private CorsConfiguration buildConfig() { 16 | CorsConfiguration corsConfiguration = new CorsConfiguration(); 17 | corsConfiguration.addAllowedOrigin("*"); // 允许任何域名使用 18 | corsConfiguration.addAllowedHeader("*"); // 允许任何头 19 | corsConfiguration.addAllowedMethod("*"); // 允许任何方法(post、get等) 20 | return corsConfiguration; 21 | } 22 | @Bean 23 | public CorsFilter corsFilter() { 24 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 25 | source.registerCorsConfiguration("/**", buildConfig()); // 对接口配置跨域设置 26 | return new CorsFilter(source); 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/controller/BlogController.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.controller; 2 | 3 | import com.cun.itaem.entity.Blog; 4 | import com.cun.itaem.service.BlogService; 5 | import com.cun.itaem.utils.Json; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.*; 8 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 9 | 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | @RestController 14 | @EnableSwagger2 15 | public class BlogController { 16 | 17 | @Autowired 18 | private BlogService blogService; 19 | 20 | @GetMapping("getBlogById/{id}") 21 | public Map getBlogById(@PathVariable Integer id) { 22 | Blog blogById = blogService.getBlogById(id); 23 | if (blogById == null) { 24 | return Json.fail(); 25 | } else { 26 | return Json.success(blogById); 27 | } 28 | 29 | } 30 | 31 | @DeleteMapping("deleteBlogById/{id}") 32 | public Map deleteBlogById(@PathVariable Integer id) { 33 | Blog blogById = blogService.getBlogById(id); 34 | if (blogById == null) { 35 | return Json.fail(); 36 | } else { 37 | blogService.deleteBlogById(id); 38 | return Json.success(blogById); 39 | } 40 | } 41 | 42 | @GetMapping("getAllBlogs") 43 | public Map getAllBlogs() { 44 | List allBlogs = blogService.getAllBlogs(); 45 | if (allBlogs.size() == 0) { 46 | return Json.fail(); 47 | } else { 48 | return Json.success(blogService.getAllBlogs()); 49 | } 50 | } 51 | 52 | @PostMapping("insertBlog") 53 | public Map insertBlog(Blog blog) { 54 | blogService.insertBlog(blog); 55 | return Json.success(blog); 56 | } 57 | 58 | @PutMapping("updateBlog") 59 | public Map updateBlog(Blog blog) { 60 | blogService.updateBlog(blog); 61 | return Json.success(blog); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/controller/DirectionController.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.controller; 2 | 3 | import com.aliyun.oss.ClientException; 4 | import com.aliyun.oss.OSSException; 5 | import com.cun.itaem.entity.Direction; 6 | import com.cun.itaem.service.DirectionService; 7 | import com.cun.itaem.utils.Json; 8 | import com.cun.itaem.utils.Oss; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.*; 11 | import org.springframework.web.multipart.MultipartFile; 12 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 13 | 14 | import java.io.IOException; 15 | import java.util.List; 16 | import java.util.Map; 17 | 18 | @RestController 19 | @EnableSwagger2 20 | public class DirectionController { 21 | 22 | @Autowired 23 | private DirectionService directionService; 24 | 25 | @GetMapping("getDirectionById/{id}") 26 | public Map getDirectionById(@PathVariable Integer id) { 27 | Direction directionById = directionService.getDirectionById(id); 28 | if(directionById==null){ 29 | return Json.fail(); 30 | }else { 31 | return Json.success(directionById); 32 | } 33 | 34 | } 35 | 36 | @DeleteMapping("deleteDirectionById/{id}") 37 | public Map deleteDirectionById(@PathVariable Integer id) { 38 | Direction directionById = directionService.getDirectionById(id); 39 | if(directionById==null){ 40 | return Json.fail(); 41 | }else{ 42 | directionService.deleteDirectionById(id); 43 | return Json.success(directionById); 44 | } 45 | } 46 | 47 | @GetMapping("getAllDirections") 48 | public Map getAllDirections() { 49 | List allDirections = directionService.getAllDirections(); 50 | if (allDirections.size() == 0) { 51 | return Json.fail(); 52 | } else { 53 | return Json.success(allDirections); 54 | } 55 | } 56 | 57 | @PostMapping("insertDirection") 58 | public Map insertDirection(Direction direction, 59 | @RequestParam(value = "fileupload", required = false) MultipartFile fileupload) 60 | throws OSSException, ClientException, IOException { 61 | if (fileupload != null) { 62 | direction.setPath(Oss.getUrl(fileupload)); 63 | } 64 | directionService.insertDirection(direction); 65 | return Json.success(direction); 66 | } 67 | 68 | @PutMapping("updateDirection") 69 | public Map updateDirection(Direction direction, 70 | @RequestParam(value = "fileupload", required = false) MultipartFile fileupload) 71 | throws OSSException, ClientException, IOException { 72 | if (fileupload != null) { 73 | direction.setPath(Oss.getUrl(fileupload)); 74 | } 75 | directionService.updateDirection(direction); 76 | return Json.success(direction); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/controller/HonorController.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.controller; 2 | 3 | import com.aliyun.oss.ClientException; 4 | import com.aliyun.oss.OSSException; 5 | import com.cun.itaem.entity.Honor; 6 | import com.cun.itaem.entity.Honor; 7 | import com.cun.itaem.service.HonorService; 8 | import com.cun.itaem.utils.Json; 9 | import com.cun.itaem.utils.Oss; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.*; 12 | import org.springframework.web.multipart.MultipartFile; 13 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 14 | 15 | import java.io.IOException; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | @RestController 20 | @EnableSwagger2 21 | public class HonorController { 22 | 23 | @Autowired 24 | private HonorService honorService; 25 | 26 | @GetMapping("getHonorById/{id}") 27 | public Map getHonorById(@PathVariable Integer id) { 28 | Honor honorById = honorService.getHonorById(id); 29 | if(honorById==null){ 30 | return Json.fail(); 31 | }else { 32 | return Json.success(honorById); 33 | } 34 | 35 | } 36 | 37 | @DeleteMapping("deleteHonorById/{id}") 38 | public Map deleteHonorById(@PathVariable Integer id) { 39 | Honor honorById = honorService.getHonorById(id); 40 | if(honorById==null){ 41 | return Json.fail(); 42 | }else{ 43 | honorService.deleteHonorById(id); 44 | return Json.success(honorById); 45 | } 46 | } 47 | 48 | @GetMapping("getAllHonors") 49 | public Map getAllHonors() { 50 | List allHonors = honorService.getAllHonors(); 51 | if (allHonors.size() == 0) { 52 | return Json.fail(); 53 | } else { 54 | return Json.success(allHonors); 55 | } 56 | } 57 | 58 | @PostMapping("insertHonor") 59 | public Map insertHonor(Honor honor, 60 | @RequestParam(value = "fileupload", required = false) MultipartFile fileupload) 61 | throws OSSException, ClientException, IOException { 62 | if (fileupload != null) { 63 | honor.setPath(Oss.getUrl(fileupload)); 64 | } 65 | honorService.insertHonor(honor); 66 | return Json.success(honor); 67 | } 68 | 69 | @PutMapping("updateHonor") 70 | public Map updateHonor(Honor honor, 71 | @RequestParam(value = "fileupload", required = false) MultipartFile fileupload) 72 | throws OSSException, ClientException, IOException { 73 | if (fileupload != null) { 74 | honor.setPath(Oss.getUrl(fileupload)); 75 | } 76 | honorService.updateHonor(honor); 77 | return Json.success(honor); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/controller/MemberController.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.controller; 2 | 3 | import com.aliyun.oss.ClientException; 4 | import com.aliyun.oss.OSSException; 5 | import com.cun.itaem.entity.Member; 6 | import com.cun.itaem.entity.Member; 7 | import com.cun.itaem.service.MemberService; 8 | import com.cun.itaem.utils.Json; 9 | import com.cun.itaem.utils.Oss; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.*; 12 | import org.springframework.web.multipart.MultipartFile; 13 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 14 | 15 | import java.io.IOException; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | @RestController 20 | @EnableSwagger2 21 | public class MemberController { 22 | 23 | @Autowired 24 | private MemberService memberService; 25 | 26 | @GetMapping("getMemberById/{id}") 27 | public Map getMemberById(@PathVariable Integer id) { 28 | Member memberById = memberService.getMemberById(id); 29 | if(memberById==null){ 30 | return Json.fail(); 31 | }else { 32 | return Json.success(memberById); 33 | } 34 | 35 | } 36 | 37 | @DeleteMapping("deleteMemberById/{id}") 38 | public Map deleteMemberById(@PathVariable Integer id) { 39 | Member memberById = memberService.getMemberById(id); 40 | if(memberById==null){ 41 | return Json.fail(); 42 | }else{ 43 | memberService.deleteMemberById(id); 44 | return Json.success(memberById); 45 | } 46 | } 47 | 48 | @GetMapping("getAllMembers") 49 | public Map getAllMembers() { 50 | List allMembers = memberService.getAllMembers(); 51 | if (allMembers.size() == 0) { 52 | return Json.fail(); 53 | } else { 54 | return Json.success(allMembers); 55 | } 56 | } 57 | 58 | @PostMapping("insertMember") 59 | public Map insertMember(Member member, 60 | @RequestParam(value = "fileupload", required = false) MultipartFile fileupload) 61 | throws OSSException, ClientException, IOException { 62 | if (fileupload != null) { 63 | member.setPath(Oss.getUrl(fileupload)); 64 | } 65 | memberService.insertMember(member); 66 | return Json.success(member); 67 | } 68 | 69 | @PutMapping("updateMember") 70 | public Map updateMember(Member member, 71 | @RequestParam(value = "fileupload", required = false) MultipartFile fileupload) 72 | throws OSSException, ClientException, IOException { 73 | if (fileupload != null) { 74 | member.setPath(Oss.getUrl(fileupload)); 75 | } 76 | memberService.updateMember(member); 77 | return Json.success(member); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/controller/ProductionController.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.controller; 2 | 3 | import com.aliyun.oss.ClientException; 4 | import com.aliyun.oss.OSSException; 5 | import com.cun.itaem.entity.Production; 6 | import com.cun.itaem.service.ProductionService; 7 | import com.cun.itaem.utils.Json; 8 | import com.cun.itaem.utils.Oss; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.*; 11 | import org.springframework.web.multipart.MultipartFile; 12 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 13 | 14 | import java.io.IOException; 15 | import java.util.List; 16 | import java.util.Map; 17 | 18 | @RestController 19 | @EnableSwagger2 20 | public class ProductionController { 21 | 22 | @Autowired 23 | private ProductionService productionService; 24 | 25 | @GetMapping("getProductionById/{id}") 26 | public Map getProductionById(@PathVariable Integer id) { 27 | Production productionById = productionService.getProductionById(id); 28 | if(productionById==null){ 29 | return Json.fail(); 30 | }else { 31 | return Json.success(productionById); 32 | } 33 | 34 | } 35 | 36 | @DeleteMapping("deleteProductionById/{id}") 37 | public Map deleteProductionById(@PathVariable Integer id) { 38 | Production productionById = productionService.getProductionById(id); 39 | if(productionById==null){ 40 | return Json.fail(); 41 | }else{ 42 | productionService.deleteProductionById(id); 43 | return Json.success(productionById); 44 | } 45 | } 46 | 47 | @GetMapping("getAllProductions") 48 | public Map getAllProductions() { 49 | List allProductions = productionService.getAllProductions(); 50 | if (allProductions.size() == 0) { 51 | return Json.fail(); 52 | } else { 53 | return Json.success(allProductions); 54 | } 55 | } 56 | 57 | @PostMapping("insertProduction") 58 | public Map insertProduction(Production production, 59 | @RequestParam(value = "fileupload", required = false) MultipartFile fileupload) 60 | throws OSSException, ClientException, IOException { 61 | if (fileupload != null) { 62 | production.setPath(Oss.getUrl(fileupload)); 63 | } 64 | productionService.insertProduction(production); 65 | return Json.success(production); 66 | } 67 | 68 | @PutMapping("updateProduction") 69 | public Map updateProduction(Production production, 70 | @RequestParam(value = "fileupload", required = false) MultipartFile fileupload) 71 | throws OSSException, ClientException, IOException { 72 | if (fileupload != null) { 73 | production.setPath(Oss.getUrl(fileupload)); 74 | } 75 | productionService.updateProduction(production); 76 | return Json.success(production); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/dao/BlogDao.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.dao; 2 | 3 | import com.cun.itaem.entity.Blog; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface BlogDao extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/dao/DirectionDao.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.dao; 2 | 3 | import com.cun.itaem.entity.Direction; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface DirectionDao extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/dao/HonorDao.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.dao; 2 | 3 | import com.cun.itaem.entity.Honor; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface HonorDao extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.dao; 2 | 3 | import com.cun.itaem.entity.Member; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface MemberDao extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/dao/ProductionDao.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.dao; 2 | 3 | import com.cun.itaem.entity.Production; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface ProductionDao extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/entity/Blog.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.entity; 2 | 3 | import java.util.Date; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.Id; 9 | import javax.persistence.Table; 10 | 11 | import io.swagger.annotations.ApiModelProperty; 12 | 13 | @Entity 14 | @Table(name = "t_blog") 15 | public class Blog { 16 | 17 | @Id 18 | @GeneratedValue 19 | @ApiModelProperty(value = "博客id") 20 | private Integer id; 21 | 22 | @ApiModelProperty(value = "标题") 23 | @Column(length = 200) 24 | private String title; 25 | 26 | @ApiModelProperty(value = "文章链接") 27 | @Column(length = 200) 28 | private String link; 29 | 30 | @ApiModelProperty(value = "博客发表时间") 31 | private Date date; 32 | 33 | @ApiModelProperty(value = "作者") 34 | @Column(length = 200) 35 | private String author; 36 | 37 | @ApiModelProperty(value = "是否展示:1展示 0隐藏") 38 | private Integer tag; 39 | 40 | public Integer getTag() { 41 | return tag; 42 | } 43 | 44 | public void setTag(Integer tag) { 45 | this.tag = tag; 46 | } 47 | public Integer getId() { 48 | return id; 49 | } 50 | 51 | public void setId(Integer id) { 52 | this.id = id; 53 | } 54 | 55 | public String getTitle() { 56 | return title; 57 | } 58 | 59 | public void setTitle(String title) { 60 | this.title = title; 61 | } 62 | 63 | public String getLink() { 64 | return link; 65 | } 66 | 67 | public void setLink(String link) { 68 | this.link = link; 69 | } 70 | 71 | public Date getDate() { 72 | return date; 73 | } 74 | 75 | public void setDate(Date date) { 76 | this.date = date; 77 | } 78 | 79 | public String getAuthor() { 80 | return author; 81 | } 82 | 83 | public void setAuthor(String author) { 84 | this.author = author; 85 | } 86 | 87 | 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/entity/Direction.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.entity; 2 | 3 | import java.util.Date; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.Id; 9 | import javax.persistence.Table; 10 | 11 | import io.swagger.annotations.ApiModelProperty; 12 | 13 | @Entity 14 | @Table(name = "t_direction") 15 | public class Direction { 16 | 17 | @Id 18 | @GeneratedValue 19 | @ApiModelProperty(value = "方向id") 20 | private Integer id; 21 | 22 | @ApiModelProperty(value = "方向名称") 23 | @Column(length = 200) 24 | private String name; 25 | 26 | @ApiModelProperty(value = "图片路径,后台根据传来的图片自动生成,不用用户输入") 27 | @Column(length = 200) 28 | private String path; 29 | 30 | @ApiModelProperty(value = "方向描述") 31 | @Column(length = 200) 32 | private String description; 33 | 34 | @ApiModelProperty(value = "时间") 35 | private Date date; 36 | 37 | public Integer getId() { 38 | return id; 39 | } 40 | 41 | public void setId(Integer id) { 42 | this.id = id; 43 | } 44 | 45 | public String getName() { 46 | return name; 47 | } 48 | 49 | public void setName(String name) { 50 | this.name = name; 51 | } 52 | 53 | public String getPath() { 54 | return path; 55 | } 56 | 57 | public void setPath(String path) { 58 | this.path = path; 59 | } 60 | 61 | public String getDescription() { 62 | return description; 63 | } 64 | 65 | public void setDescription(String description) { 66 | this.description = description; 67 | } 68 | 69 | public Date getDate() { 70 | return date; 71 | } 72 | 73 | public void setDate(Date date) { 74 | this.date = date; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/entity/Honor.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.entity; 2 | 3 | import java.util.Date; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.Id; 9 | import javax.persistence.Table; 10 | 11 | import io.swagger.annotations.ApiModelProperty; 12 | 13 | @Entity 14 | @Table(name = "t_honor") 15 | public class Honor { 16 | 17 | @Id 18 | @GeneratedValue 19 | @ApiModelProperty(value = "荣誉 id") 20 | private Integer id; 21 | 22 | @ApiModelProperty(value = "标题") 23 | @Column(length = 200) 24 | private String title; 25 | 26 | @ApiModelProperty(value = "图片路径,后台根据传来的图片自动生成,不用用户输入") 27 | @Column(length = 200) 28 | private String path; 29 | 30 | @ApiModelProperty(value = "荣誉描述") 31 | @Column(length = 200) 32 | private String description; 33 | 34 | @ApiModelProperty(value = "时间") 35 | private Date date; 36 | 37 | @ApiModelProperty(value = "是否展示:1展示 0隐藏") 38 | private Integer tag; 39 | 40 | public Integer getTag() { 41 | return tag; 42 | } 43 | 44 | public void setTag(Integer tag) { 45 | this.tag = tag; 46 | } 47 | 48 | 49 | public Integer getId() { 50 | return id; 51 | } 52 | 53 | public void setId(Integer id) { 54 | this.id = id; 55 | } 56 | 57 | public String getTitle() { 58 | return title; 59 | } 60 | 61 | public void setTitle(String title) { 62 | this.title = title; 63 | } 64 | 65 | public String getPath() { 66 | return path; 67 | } 68 | 69 | public void setPath(String path) { 70 | this.path = path; 71 | } 72 | 73 | public String getDescription() { 74 | return description; 75 | } 76 | 77 | public void setDescription(String description) { 78 | this.description = description; 79 | } 80 | 81 | public Date getDate() { 82 | return date; 83 | } 84 | 85 | public void setDate(Date date) { 86 | this.date = date; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/entity/Member.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.entity; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.Id; 7 | import javax.persistence.Table; 8 | 9 | import io.swagger.annotations.ApiModelProperty; 10 | 11 | @Entity 12 | @Table(name = "t_member") 13 | public class Member { 14 | 15 | @Id 16 | @GeneratedValue 17 | @ApiModelProperty(value = "成员id") 18 | private Integer id; 19 | 20 | @ApiModelProperty(value = "成员名称") 21 | @Column(length = 200) 22 | private String name; 23 | 24 | @ApiModelProperty(value = "成员介绍") 25 | @Column(length = 200) 26 | private String description; 27 | 28 | @ApiModelProperty(value = "图片路径,后台根据传来的图片自动生成,不用用户输入") 29 | @Column(length = 200) 30 | private String path; 31 | 32 | @ApiModelProperty(value = "方向名称") 33 | @Column(length = 200) 34 | private String direction; 35 | 36 | @ApiModelProperty(value = "第几届") 37 | @Column(length = 20) 38 | private String year; 39 | 40 | @ApiModelProperty(value = "博主链接") 41 | @Column(length = 200) 42 | private String link; 43 | 44 | @ApiModelProperty(value = "职位") 45 | @Column(length = 20) 46 | private String position; 47 | 48 | @ApiModelProperty(value = "是否展示:1展示 0隐藏") 49 | private Integer tag; 50 | 51 | public Integer getTag() { 52 | return tag; 53 | } 54 | 55 | public void setTag(Integer tag) { 56 | this.tag = tag; 57 | } 58 | 59 | 60 | public Integer getId() { 61 | return id; 62 | } 63 | 64 | public void setId(Integer id) { 65 | this.id = id; 66 | } 67 | 68 | public String getName() { 69 | return name; 70 | } 71 | 72 | public void setName(String name) { 73 | this.name = name; 74 | } 75 | 76 | public String getDescription() { 77 | return description; 78 | } 79 | 80 | public void setDescription(String description) { 81 | this.description = description; 82 | } 83 | 84 | public String getPath() { 85 | return path; 86 | } 87 | 88 | public void setPath(String path) { 89 | this.path = path; 90 | } 91 | 92 | public String getDirection() { 93 | return direction; 94 | } 95 | 96 | public void setDirection(String direction) { 97 | this.direction = direction; 98 | } 99 | 100 | public String getYear() { 101 | return year; 102 | } 103 | 104 | public void setYear(String year) { 105 | this.year = year; 106 | } 107 | 108 | public String getLink() { 109 | return link; 110 | } 111 | 112 | public void setLink(String link) { 113 | this.link = link; 114 | } 115 | 116 | public String getPosition() { 117 | return position; 118 | } 119 | 120 | public void setPosition(String position) { 121 | this.position = position; 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/entity/Production.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.entity; 2 | 3 | import java.util.Date; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.Id; 9 | import javax.persistence.Table; 10 | 11 | import io.swagger.annotations.ApiModelProperty; 12 | 13 | @Entity 14 | @Table(name = "t_production") 15 | public class Production { 16 | 17 | @Id 18 | @GeneratedValue 19 | @ApiModelProperty(value = "作品id") 20 | private Integer id; 21 | 22 | @ApiModelProperty(value = "作品名称") 23 | @Column(length = 200) 24 | private String name; 25 | 26 | @ApiModelProperty(value = "作品介绍") 27 | @Column(length = 200) 28 | private String description; 29 | 30 | @ApiModelProperty(value = "图片路径,后台根据传来的图片自动生成,不用用户输入") 31 | @Column(length = 200) 32 | private String path; 33 | 34 | @ApiModelProperty(value = "时间") 35 | private Date date; 36 | 37 | @ApiModelProperty(value = "作品链接") 38 | @Column(length = 200) 39 | private String link; 40 | 41 | @ApiModelProperty(value = "是否展示:1展示 0隐藏") 42 | private Integer tag; 43 | 44 | public Integer getTag() { 45 | return tag; 46 | } 47 | 48 | public void setTag(Integer tag) { 49 | this.tag = tag; 50 | } 51 | 52 | 53 | public Integer getId() { 54 | return id; 55 | } 56 | 57 | public void setId(Integer id) { 58 | this.id = id; 59 | } 60 | 61 | public String getName() { 62 | return name; 63 | } 64 | 65 | public void setName(String name) { 66 | this.name = name; 67 | } 68 | 69 | public String getDescription() { 70 | return description; 71 | } 72 | 73 | public void setDescription(String description) { 74 | this.description = description; 75 | } 76 | 77 | public String getPath() { 78 | return path; 79 | } 80 | 81 | public void setPath(String path) { 82 | this.path = path; 83 | } 84 | 85 | public Date getDate() { 86 | return date; 87 | } 88 | 89 | public void setDate(Date date) { 90 | this.date = date; 91 | } 92 | 93 | public String getLink() { 94 | return link; 95 | } 96 | 97 | public void setLink(String link) { 98 | this.link = link; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/service/BlogService.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.service; 2 | 3 | import com.cun.itaem.entity.Blog; 4 | 5 | import java.util.List; 6 | 7 | public interface BlogService { 8 | 9 | // 查 10 | Blog getBlogById(Integer id); 11 | 12 | // 删 13 | void deleteBlogById(Integer id); 14 | 15 | // 全 16 | List getAllBlogs(); 17 | 18 | // 增 19 | void insertBlog(Blog blog); 20 | 21 | // 改 22 | void updateBlog(Blog blog); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/service/DirectionService.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.service; 2 | 3 | import com.cun.itaem.entity.Blog; 4 | import com.cun.itaem.entity.Direction; 5 | 6 | import java.util.List; 7 | 8 | public interface DirectionService { 9 | 10 | // 查 11 | Direction getDirectionById(Integer id); 12 | 13 | // 删 14 | void deleteDirectionById(Integer id); 15 | 16 | // 全 17 | List getAllDirections(); 18 | 19 | // 增 20 | void insertDirection(Direction direction); 21 | 22 | // 改 23 | void updateDirection(Direction direction); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/service/HonorService.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.service; 2 | 3 | import com.cun.itaem.entity.Honor; 4 | 5 | import java.util.List; 6 | 7 | public interface HonorService { 8 | 9 | // 查 10 | Honor getHonorById(Integer id); 11 | 12 | // 删 13 | void deleteHonorById(Integer id); 14 | 15 | // 全 16 | List getAllHonors(); 17 | 18 | // 增 19 | void insertHonor(Honor honor); 20 | 21 | // 改 22 | void updateHonor(Honor honor); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/service/MemberService.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.service; 2 | 3 | import com.cun.itaem.entity.Blog; 4 | import com.cun.itaem.entity.Member; 5 | 6 | import java.util.List; 7 | 8 | public interface MemberService { 9 | 10 | // 查 11 | Member getMemberById(Integer id); 12 | 13 | // 删 14 | void deleteMemberById(Integer id); 15 | 16 | // 全 17 | List getAllMembers(); 18 | 19 | // 增 20 | void insertMember(Member member); 21 | 22 | // 改 23 | void updateMember(Member member); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/service/ProductionService.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.service; 2 | 3 | import com.cun.itaem.entity.Blog; 4 | import com.cun.itaem.entity.Production; 5 | 6 | import java.util.List; 7 | 8 | public interface ProductionService { 9 | 10 | // 查 11 | Production getProductionById(Integer id); 12 | 13 | // 删 14 | void deleteProductionById(Integer id); 15 | 16 | // 全 17 | List getAllProductions(); 18 | 19 | // 增 20 | void insertProduction(Production production); 21 | 22 | // 改 23 | void updateProduction(Production production); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/service/impl/BlogServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.service.impl; 2 | 3 | import com.cun.itaem.dao.BlogDao; 4 | import com.cun.itaem.entity.Blog; 5 | import com.cun.itaem.service.BlogService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | @Service 12 | public class BlogServiceImpl implements BlogService { 13 | 14 | @Autowired 15 | private BlogDao blogDao; 16 | 17 | @Override 18 | public Blog getBlogById(Integer id) { 19 | return blogDao.getOne(id); 20 | } 21 | 22 | @Override 23 | public void deleteBlogById(Integer id) { 24 | blogDao.delete(id); 25 | } 26 | 27 | @Override 28 | public List getAllBlogs() { 29 | return blogDao.findAll(); 30 | } 31 | 32 | @Override 33 | public void insertBlog(Blog blog) { 34 | blogDao.save(blog); 35 | } 36 | 37 | @Override 38 | public void updateBlog(Blog blog) { 39 | blogDao.save(blog); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/service/impl/DirectionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.service.impl; 2 | 3 | import com.cun.itaem.dao.DirectionDao; 4 | import com.cun.itaem.entity.Blog; 5 | import com.cun.itaem.entity.Direction; 6 | import com.cun.itaem.service.DirectionService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | 12 | @Service 13 | public class DirectionServiceImpl implements DirectionService { 14 | 15 | @Autowired 16 | private DirectionDao directionDao; 17 | 18 | @Override 19 | public Direction getDirectionById(Integer id) { 20 | return directionDao.findOne(id); 21 | } 22 | 23 | @Override 24 | public void deleteDirectionById(Integer id) { 25 | directionDao.delete(id); 26 | } 27 | 28 | @Override 29 | public List getAllDirections() { 30 | return directionDao.findAll(); 31 | } 32 | 33 | @Override 34 | public void insertDirection(Direction direction) { 35 | directionDao.save(direction); 36 | } 37 | 38 | @Override 39 | public void updateDirection(Direction direction) { 40 | directionDao.save(direction); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/service/impl/HonorServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.service.impl; 2 | 3 | import com.cun.itaem.dao.HonorDao; 4 | import com.cun.itaem.entity.Honor; 5 | import com.cun.itaem.service.HonorService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | @Service 12 | public class HonorServiceImpl implements HonorService { 13 | 14 | @Autowired 15 | private HonorDao honorDao; 16 | 17 | @Override 18 | public Honor getHonorById(Integer id) { 19 | return honorDao.findOne(id); 20 | } 21 | 22 | @Override 23 | public void deleteHonorById(Integer id) { 24 | honorDao.delete(id); 25 | } 26 | 27 | @Override 28 | public List getAllHonors() { 29 | return honorDao.findAll(); 30 | } 31 | 32 | @Override 33 | public void insertHonor(Honor honor) { 34 | honorDao.save(honor); 35 | } 36 | 37 | @Override 38 | public void updateHonor(Honor honor) { 39 | honorDao.save(honor); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/service/impl/MemberServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.service.impl; 2 | 3 | import com.cun.itaem.dao.MemberDao; 4 | import com.cun.itaem.entity.Member; 5 | import com.cun.itaem.service.MemberService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | @Service 12 | public class MemberServiceImpl implements MemberService { 13 | 14 | @Autowired 15 | private MemberDao memberDao; 16 | 17 | @Override 18 | public Member getMemberById(Integer id) { 19 | return memberDao.findOne(id); 20 | } 21 | 22 | @Override 23 | public void deleteMemberById(Integer id) { 24 | memberDao.delete(id); 25 | } 26 | 27 | @Override 28 | public List getAllMembers() { 29 | return memberDao.findAll(); 30 | } 31 | 32 | @Override 33 | public void insertMember(Member member) { 34 | memberDao.save(member); 35 | } 36 | 37 | @Override 38 | public void updateMember(Member member) { 39 | memberDao.save(member); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/service/impl/ProductionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.service.impl; 2 | 3 | import com.cun.itaem.dao.ProductionDao; 4 | import com.cun.itaem.entity.Production; 5 | import com.cun.itaem.service.ProductionService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | @Service 12 | public class ProductionServiceImpl implements ProductionService { 13 | 14 | @Autowired 15 | private ProductionDao productionDao; 16 | 17 | @Override 18 | public Production getProductionById(Integer id) { 19 | return productionDao.findOne(id); 20 | } 21 | 22 | @Override 23 | public void deleteProductionById(Integer id) { 24 | productionDao.delete(id); 25 | } 26 | 27 | @Override 28 | public List getAllProductions() { 29 | return productionDao.findAll(); 30 | } 31 | 32 | @Override 33 | public void insertProduction(Production production) { 34 | productionDao.save(production); 35 | } 36 | 37 | @Override 38 | public void updateProduction(Production production) { 39 | productionDao.save(production); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/utils/Json.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.utils; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | public class Json { 6 | 7 | public static Map success(Object data) { 8 | Map map = new HashMap(); 9 | map.put("code", 200); 10 | map.put("msg", "ok"); 11 | map.put("data", data); 12 | return map; 13 | } 14 | 15 | public static Map fail() { 16 | Map map = new HashMap(); 17 | map.put("code", 400); 18 | map.put("msg", "error"); 19 | return map; 20 | } 21 | } -------------------------------------------------------------------------------- /src/main/java/com/cun/itaem/utils/Oss.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem.utils; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.IOException; 5 | import java.net.URL; 6 | import java.text.SimpleDateFormat; 7 | import java.util.Date; 8 | import org.springframework.web.multipart.MultipartFile; 9 | import com.aliyun.oss.ClientException; 10 | import com.aliyun.oss.OSSClient; 11 | import com.aliyun.oss.OSSException; 12 | /** 13 | * 把文件保存到阿里云OSS,返回图片访问路径 14 | * @author linhongcun 15 | * 16 | */ 17 | public class Oss { 18 | 19 | public static String getUrl(MultipartFile fileupload) throws OSSException, ClientException, IOException { 20 | String endpoint = "oss-cn-shenzhen.aliyuncs.com"; 21 | // 填自己的帐号 22 | String accessKeyId = "LTAxxxxxxxxxR"; 23 | // 填自己的帐号 24 | String accessKeySecret = "VuCGxxxxxxxxxxxxR9QKR"; 25 | // 创建OSSClient实例 26 | OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret); 27 | // 文件桶 28 | String bucketName = "itaem"; 29 | // 文件名格式 30 | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss"); 31 | // 该桶中的文件key 32 | String dateString = sdf.format(new Date()) + ".jpg";// 20180322010634.jpg 33 | // 上传文件 34 | ossClient.putObject("itaem", dateString, new ByteArrayInputStream(fileupload.getBytes())); 35 | // 设置URL过期时间为100年,默认这里是int型,转换为long型即可 36 | Date expiration = new Date(new Date().getTime() + 3600l * 1000 * 24 * 365 * 100); 37 | // 生成URL 38 | URL url = ossClient.generatePresignedUrl(bucketName, dateString, expiration); 39 | return url.toString(); 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.http.multipart.maxFileSize=100Mb 2 | spring.http.multipart.maxRequestSize=1000Mb -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | context-path: / 4 | spring: 5 | datasource: 6 | driver-class-name: com.mysql.jdbc.Driver 7 | url: jdbc:mysql://120.79.197.130:3307/itaem?useUnicode=true&characterEncoding=utf-8 8 | username: root 9 | password: 123 10 | jpa: 11 | hibernate: 12 | ddl-auto: update 13 | show-sql: true -------------------------------------------------------------------------------- /src/test/java/com/cun/itaem/ItaemApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.cun.itaem; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ItaemApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | --------------------------------------------------------------------------------