Commit 473605c5672e749eb8ecc40d048733dfdbad4c53

Authored by 陈杰
1 parent fafdccdc
Exists in master

bug 修复

src/main/java/com/sincere/student/controller/AdminController.java
... ... @@ -86,6 +86,11 @@ public class AdminController {
86 86 @RequestMapping(value = "/submit/update" , method = RequestMethod.POST)
87 87 public BaseDto updateFile(@RequestBody SubmitFile submitFile){
88 88 BaseDto result = new BaseDto<>();
  89 + if(!submitFile.getFileUrl().contains("xls")){
  90 + result.setSuccess(false) ;
  91 + result.setMessage("请上传excel") ;
  92 + return result ;
  93 + }
89 94 try{
90 95 SubmitFile beforeFile = submitService.getById(submitFile.getId());
91 96 if(beforeFile.getFileUrl().equals(submitFile.getFileUrl())){
... ... @@ -121,6 +126,11 @@ public class AdminController {
121 126 @RequestMapping(value = "/submit/createFile" , method = RequestMethod.POST)
122 127 public BaseDto createFile(@RequestBody SubmitFile submitFile){
123 128 BaseDto result = new BaseDto();
  129 + if(!submitFile.getFileUrl().contains("xls")){
  130 + result.setSuccess(false);
  131 + result.setMessage("请上传excel");
  132 + return result ;
  133 + }
124 134 try{
125 135 List<Point> list = ExcelUtils.analysisExcel(submitFile.getFileUrl());
126 136 List<Point> points = new ArrayList<>();
... ... @@ -446,8 +456,15 @@ public class AdminController {
446 456 @ApiOperation("修改专业相关接口")
447 457 @RequestMapping(value = "/major/updateMajor" , method = RequestMethod.POST)
448 458 public BaseDto updateMajor(@RequestBody Major major){
449   - majorService.update(major);
450   - return new BaseDto() ;
  459 + BaseDto result = new BaseDto();
  460 + Major before = majorService.getById(major.getId());
  461 + if(before.getPid() == -1 && major.getPid() != -1){
  462 + result.setSuccess(false);
  463 + result.setMessage("一级专业不能被设置成二级");
  464 + }else {
  465 + majorService.update(major);
  466 + }
  467 + return result ;
451 468 }
452 469  
453 470 @MemberAccess
... ... @@ -470,7 +487,7 @@ public class AdminController {
470 487 public BaseDto<Page<Article>> getArticleList(@RequestBody ArticleSearchDto articleSearchDto){
471 488 BaseDto<Page<Article>> result = new BaseDto<>() ;
472 489 articleSearchDto.setStatus(0);
473   - Page<Article> page = articleService.getList(articleSearchDto);
  490 + Page<Article> page = articleService.getAdminList(articleSearchDto);
474 491 result.setData(page);
475 492 return result ;
476 493 }
... ...
src/main/java/com/sincere/student/mapper/MajorMapper.java
... ... @@ -8,6 +8,8 @@ public interface MajorMapper {
8 8  
9 9 List<Major> getList(Major major);
10 10  
  11 + Major getById(int id);
  12 +
11 13 int getListCount(Major major);
12 14  
13 15 int create(Major major);
... ...
src/main/java/com/sincere/student/model/Consult.java
... ... @@ -27,6 +27,8 @@ public class Consult {
27 27 private String columnTypeName;
28 28 @ApiModelProperty(value = "视频地址")
29 29 private String videoUrl;
  30 + @ApiModelProperty(value = "视频地址")
  31 + private List<String> videoUrlList;
30 32 @ApiModelProperty(value = "内容")
31 33 private String context;
32 34 @ApiModelProperty(value = "联系方式")
... ... @@ -36,6 +38,14 @@ public class Consult {
36 38 @ApiModelProperty(value = "4个栏目")
37 39 private List<UniversityConsultDetail> list ;
38 40  
  41 + public List<String> getVideoUrlList() {
  42 + return videoUrlList;
  43 + }
  44 +
  45 + public void setVideoUrlList(List<String> videoUrlList) {
  46 + this.videoUrlList = videoUrlList;
  47 + }
  48 +
39 49 public String getColumnTypeName() {
40 50 return columnTypeName;
41 51 }
... ...
src/main/java/com/sincere/student/model/Video.java
... ... @@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
4 4 import io.swagger.annotations.ApiModelProperty;
5 5  
6 6 import java.util.Date;
  7 +import java.util.List;
7 8  
8 9 @ApiModel
9 10 public class Video {
... ... @@ -16,6 +17,9 @@ public class Video {
16 17 private int columnType ;
17 18 @ApiModelProperty(value = "视频路径")
18 19 private String videoUrl ;
  20 +
  21 + @ApiModelProperty(value = "视频路径")
  22 + private List<String> videoUrlList ;
19 23 @ApiModelProperty(value = "排序")
20 24 private int sort ;
21 25 @ApiModelProperty(value = "创建时间")
... ... @@ -35,6 +39,14 @@ public class Video {
35 39 @ApiModelProperty(value = "视频封面")
36 40 private String coverUrl ;
37 41  
  42 + public List<String> getVideoUrlList() {
  43 + return videoUrlList;
  44 + }
  45 +
  46 + public void setVideoUrlList(List<String> videoUrlList) {
  47 + this.videoUrlList = videoUrlList;
  48 + }
  49 +
38 50 public String getCoverUrl() {
39 51 return coverUrl;
40 52 }
... ...
src/main/java/com/sincere/student/service/ArticleService.java
... ... @@ -11,6 +11,8 @@ public interface ArticleService {
11 11  
12 12 Page<Article> getList(ArticleSearchDto articleSearchDto);
13 13  
  14 + Page<Article> getAdminList(ArticleSearchDto articleSearchDto);
  15 +
14 16 List<Article> getRelationList(int universityId);
15 17  
16 18 Article selectById(int id);
... ...
src/main/java/com/sincere/student/service/MajorService.java
... ... @@ -10,6 +10,8 @@ public interface MajorService {
10 10  
11 11 Page<Major> getList(MajorSearchDto majorSearchDto);
12 12  
  13 + Major getById(int id);
  14 +
13 15 int create(Major major);
14 16  
15 17 int update(Major major);
... ...
src/main/java/com/sincere/student/service/impl/ArticleServiceImpl.java
... ... @@ -37,7 +37,7 @@ public class ArticleServiceImpl implements ArticleService {
37 37 List<Article> addAdvertList = new ArrayList<>();
38 38 for(int i = 0 ; i < list.size() ;i++){
39 39 addAdvertList.add(list.get(i));
40   - if(i % 5 ==4){
  40 + if(i % 6 ==5){
41 41 Article advert =articleMapper.getAdvert();
42 42 String[] urlList = advert.getImageUrl().split(",");
43 43 advert.setImageUrlList(Arrays.asList(urlList));
... ... @@ -51,6 +51,24 @@ public class ArticleServiceImpl implements ArticleService {
51 51 }
52 52  
53 53 @Override
  54 + public Page<Article> getAdminList(ArticleSearchDto articleSearchDto) {
  55 + Page<Article> result = new Page<>(articleSearchDto.getPage(),articleSearchDto.getPageSize());
  56 + if(StringUtils.isNotBlank(articleSearchDto.getTitle())){
  57 + articleSearchDto.setTitle("%"+articleSearchDto.getTitle()+"%");
  58 + }
  59 + PageHelper.startPage(articleSearchDto.getPage(),articleSearchDto.getPageSize());
  60 + List<Article> list = articleMapper.getList(articleSearchDto) ;
  61 + for(Article article : list){
  62 + String[] urlList = article.getImageUrl().split(",");
  63 + article.setImageUrlList(Arrays.asList(urlList));
  64 + article.setImageCount(urlList.length);
  65 + }
  66 + result.setList(list);
  67 + result.setCount(articleMapper.getListCount(articleSearchDto));
  68 + return result;
  69 + }
  70 +
  71 + @Override
54 72 public List<Article> getRelationList(int universityId) {
55 73 return articleMapper.getRelationList(universityId);
56 74 }
... ...
src/main/java/com/sincere/student/service/impl/ConsultServiceImpl.java
... ... @@ -17,6 +17,7 @@ import org.apache.commons.lang3.StringUtils;
17 17 import org.springframework.beans.factory.annotation.Autowired;
18 18 import org.springframework.stereotype.Service;
19 19  
  20 +import java.util.Arrays;
20 21 import java.util.List;
21 22  
22 23 @Service
... ... @@ -77,6 +78,7 @@ public class ConsultServiceImpl implements ConsultService {
77 78 @Override
78 79 public Consult getDetail(int id) {
79 80 Consult consult = universityConsultMapper.selectByPrimaryKey(id);
  81 + consult.setVideoUrlList(Arrays.asList(consult.getVideoUrl().split(",")));
80 82 consult.setList(universityConsultDetailMapper.selectByConsult(id));
81 83 return consult ;
82 84 }
... ...
src/main/java/com/sincere/student/service/impl/MajorServiceImpl.java
... ... @@ -36,6 +36,11 @@ public class MajorServiceImpl implements MajorService {
36 36 }
37 37  
38 38 @Override
  39 + public Major getById(int id) {
  40 + return majorMapper.getById(id);
  41 + }
  42 +
  43 + @Override
39 44 public int create(Major major) {
40 45 if(major.getPid() == 0){ //说明是一级专业
41 46 major.setPid(-1);
... ...
src/main/java/com/sincere/student/service/impl/VideoServiceImpl.java
... ... @@ -10,6 +10,7 @@ import org.apache.commons.lang3.StringUtils;
10 10 import org.springframework.beans.factory.annotation.Autowired;
11 11 import org.springframework.stereotype.Service;
12 12  
  13 +import java.util.Arrays;
13 14 import java.util.List;
14 15  
15 16 @Service
... ... @@ -40,6 +41,10 @@ public class VideoServiceImpl implements VideoService {
40 41  
41 42 PageHelper.startPage(dto.getPage(),dto.getPageSize());
42 43 List<Video> list = videoMapper.getList(dto);
  44 + for(Video video : list){
  45 + String[] array = video.getVideoUrl().split(",");
  46 + video.setVideoUrlList(Arrays.asList(array));
  47 + }
43 48 page.setList(list);
44 49 page.setCount(videoMapper.getListCount(dto));
45 50 return page;
... ...
src/main/resources/mapper/MajorMapper.xml
... ... @@ -10,6 +10,11 @@
10 10 <result column="create_time" property="createTime"/>
11 11 </resultMap>
12 12  
  13 + <select id="getById" parameterType="java.lang.Integer" resultMap="MajorMap">
  14 + select * from university_major
  15 + where id =#{id}
  16 + </select>
  17 +
13 18 <select id="getList" parameterType="com.sincere.student.model.Major" resultMap="MajorMap">
14 19 select * from university_major
15 20 <where>
... ...