Commit fafdccdcc2e4f04253b56e73d3cad99fedea8a1d
1 parent
d10218de
Exists in
master
bug 修复
Showing
18 changed files
with
127 additions
and
16 deletions
Show diff stats
src/main/java/com/sincere/student/controller/AdminController.java
... | ... | @@ -12,6 +12,7 @@ import com.sincere.student.utils.Page; |
12 | 12 | import com.sincere.student.utils.ResultException; |
13 | 13 | import com.sincere.student.utils.TokenUtils; |
14 | 14 | import io.swagger.annotations.ApiOperation; |
15 | +import io.swagger.models.auth.In; | |
15 | 16 | import org.apache.commons.lang3.StringUtils; |
16 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
17 | 18 | import org.springframework.web.bind.annotation.RequestBody; |
... | ... | @@ -248,9 +249,20 @@ public class AdminController { |
248 | 249 | @MemberAccess |
249 | 250 | @ApiOperation("新建招生咨询会相关接口") |
250 | 251 | @RequestMapping(value = "/consult/createConsult" , method = RequestMethod.POST) |
251 | - public BaseDto createConsult(@RequestBody UniversityConsult universityConsult){ | |
252 | - BaseDto result = new BaseDto() ; | |
253 | - consultService.create(universityConsult); | |
252 | + public BaseDto<ReturnDto> createConsult(@RequestBody UniversityConsult universityConsult){ | |
253 | + BaseDto<ReturnDto> result = new BaseDto() ; | |
254 | + ReturnDto dto = new ReturnDto(); | |
255 | + List<Consult> list = consultService.selectByUniversityIdAndColumnType(universityConsult.getUniversityId(),universityConsult.getColumnType()); | |
256 | + if(list != null && list.size() > 0){ | |
257 | + result.setSuccess(false); | |
258 | + result.setMessage("同一栏目下,已有该学校招生咨询"); | |
259 | + }else { | |
260 | + int id = consultService.create(universityConsult); | |
261 | + String name = universityService.getById(universityConsult.getUniversityId()).getName(); | |
262 | + dto.setId(id); | |
263 | + dto.setName(name); | |
264 | + result.setData(dto); | |
265 | + } | |
254 | 266 | return result ; |
255 | 267 | } |
256 | 268 | |
... | ... | @@ -289,9 +301,14 @@ public class AdminController { |
289 | 301 | @MemberAccess |
290 | 302 | @ApiOperation("新建视频相关接口") |
291 | 303 | @RequestMapping(value = "/video/createVideo" , method = RequestMethod.POST) |
292 | - public BaseDto createVideo(@RequestBody Video video){ | |
293 | - BaseDto result = new BaseDto() ; | |
294 | - videoService.create(video); | |
304 | + public BaseDto<ReturnDto> createVideo(@RequestBody Video video){ | |
305 | + BaseDto<ReturnDto> result = new BaseDto() ; | |
306 | + ReturnDto dto = new ReturnDto(); | |
307 | + int id = videoService.create(video); | |
308 | + String name = universityService.getById(video.getUniversityId()).getName(); | |
309 | + dto.setName(name); | |
310 | + dto.setId(id); | |
311 | + result.setData(dto); | |
295 | 312 | return result ; |
296 | 313 | } |
297 | 314 | |
... | ... | @@ -461,13 +478,14 @@ public class AdminController { |
461 | 478 | @MemberAccess |
462 | 479 | @ApiOperation("新建权威解读(文章广告)相关接口") |
463 | 480 | @RequestMapping(value = "/article/createArticle" , method = RequestMethod.POST) |
464 | - public BaseDto createArticle(@RequestBody Article article){ | |
465 | - BaseDto result = new BaseDto() ; | |
481 | + public BaseDto<Integer> createArticle(@RequestBody Article article){ | |
482 | + BaseDto<Integer> result = new BaseDto() ; | |
466 | 483 | if(StringUtils.isBlank(article.getImageUrl())){ |
467 | 484 | result.setSuccess(false); |
468 | 485 | result.setMessage("请上传封面图片"); |
469 | 486 | }else { |
470 | - articleService.create(article); | |
487 | + int id = articleService.create(article); | |
488 | + result.setData(id); | |
471 | 489 | } |
472 | 490 | return result ; |
473 | 491 | } | ... | ... |
... | ... | @@ -0,0 +1,23 @@ |
1 | +package com.sincere.student.dto; | |
2 | + | |
3 | +public class ReturnDto { | |
4 | + | |
5 | + private int id ; | |
6 | + private String name ; | |
7 | + | |
8 | + public int getId() { | |
9 | + return id; | |
10 | + } | |
11 | + | |
12 | + public void setId(int id) { | |
13 | + this.id = id; | |
14 | + } | |
15 | + | |
16 | + public String getName() { | |
17 | + return name; | |
18 | + } | |
19 | + | |
20 | + public void setName(String name) { | |
21 | + this.name = name; | |
22 | + } | |
23 | +} | ... | ... |
src/main/java/com/sincere/student/mapper/ArticleMapper.java
src/main/java/com/sincere/student/mapper/UniversityConsultMapper.java
src/main/java/com/sincere/student/mapper/UniversityMapper.java
src/main/java/com/sincere/student/model/Reply.java
... | ... | @@ -16,6 +16,17 @@ public class Reply { |
16 | 16 | @ApiModelProperty(value = "不用传") |
17 | 17 | private Date createTime; |
18 | 18 | |
19 | + @ApiModelProperty(value = "相差的时间") | |
20 | + private Long[] distanceTimes ; | |
21 | + | |
22 | + public Long[] getDistanceTimes() { | |
23 | + return distanceTimes; | |
24 | + } | |
25 | + | |
26 | + public void setDistanceTimes(Long[] distanceTimes) { | |
27 | + this.distanceTimes = distanceTimes; | |
28 | + } | |
29 | + | |
19 | 30 | public Integer getId() { |
20 | 31 | return id; |
21 | 32 | } | ... | ... |
src/main/java/com/sincere/student/service/ConsultService.java
... | ... | @@ -5,11 +5,15 @@ import com.sincere.student.model.Consult; |
5 | 5 | import com.sincere.student.model.UniversityConsult; |
6 | 6 | import com.sincere.student.utils.Page; |
7 | 7 | |
8 | +import java.util.List; | |
9 | + | |
8 | 10 | |
9 | 11 | public interface ConsultService { |
10 | 12 | |
11 | 13 | Page<Consult> getList(ConsultSearchDto consultSearchDto); |
12 | 14 | |
15 | + List<Consult> selectByUniversityIdAndColumnType(int universityId , int columnType); | |
16 | + | |
13 | 17 | Page<Consult> getColumnList(int columnType ,int page ,int pageSize); |
14 | 18 | |
15 | 19 | Consult getDetail(int id); | ... | ... |
src/main/java/com/sincere/student/service/UniversityService.java
src/main/java/com/sincere/student/service/impl/ArticleServiceImpl.java
... | ... | @@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; |
12 | 12 | |
13 | 13 | import java.util.ArrayList; |
14 | 14 | import java.util.Arrays; |
15 | +import java.util.LinkedList; | |
15 | 16 | import java.util.List; |
16 | 17 | |
17 | 18 | @Service |
... | ... | @@ -33,7 +34,18 @@ public class ArticleServiceImpl implements ArticleService { |
33 | 34 | article.setImageUrlList(Arrays.asList(urlList)); |
34 | 35 | article.setImageCount(urlList.length); |
35 | 36 | } |
36 | - result.setList(list); | |
37 | + List<Article> addAdvertList = new ArrayList<>(); | |
38 | + for(int i = 0 ; i < list.size() ;i++){ | |
39 | + addAdvertList.add(list.get(i)); | |
40 | + if(i % 5 ==4){ | |
41 | + Article advert =articleMapper.getAdvert(); | |
42 | + String[] urlList = advert.getImageUrl().split(","); | |
43 | + advert.setImageUrlList(Arrays.asList(urlList)); | |
44 | + advert.setImageCount(urlList.length); | |
45 | + addAdvertList.add(advert); | |
46 | + } | |
47 | + } | |
48 | + result.setList(addAdvertList); | |
37 | 49 | result.setCount(articleMapper.getListCount(articleSearchDto)); |
38 | 50 | return result; |
39 | 51 | } |
... | ... | @@ -57,7 +69,8 @@ public class ArticleServiceImpl implements ArticleService { |
57 | 69 | if(article.getType() == 1){ |
58 | 70 | article.setColumnType(0); |
59 | 71 | } |
60 | - return articleMapper.create(article); | |
72 | + articleMapper.create(article); | |
73 | + return article.getId() ; | |
61 | 74 | } |
62 | 75 | |
63 | 76 | @Override | ... | ... |
src/main/java/com/sincere/student/service/impl/ConsultServiceImpl.java
... | ... | @@ -32,6 +32,14 @@ public class ConsultServiceImpl implements ConsultService { |
32 | 32 | ColumnMapper columnMapper ; |
33 | 33 | |
34 | 34 | @Override |
35 | + public List<Consult> selectByUniversityIdAndColumnType(int universityId, int columnType) { | |
36 | + UniversityConsult consult = new UniversityConsult(); | |
37 | + consult.setColumnType(columnType); | |
38 | + consult.setUniversityId(universityId); | |
39 | + return universityConsultMapper.selectByUniversityIdAndColumnType(consult); | |
40 | + } | |
41 | + | |
42 | + @Override | |
35 | 43 | public Page<Consult> getList(ConsultSearchDto consultSearchDto) { |
36 | 44 | Page<Consult> page = new Page<>(consultSearchDto.getPage(),consultSearchDto.getPageSize()); |
37 | 45 | if(StringUtils.isNotBlank(consultSearchDto.getUniversityName())){ |
... | ... | @@ -80,7 +88,7 @@ public class ConsultServiceImpl implements ConsultService { |
80 | 88 | detail.setConsultId(consult.getId()); |
81 | 89 | universityConsultDetailMapper.insert(detail); |
82 | 90 | } |
83 | - return 1 ; | |
91 | + return consult.getId() ; | |
84 | 92 | } |
85 | 93 | |
86 | 94 | @Override | ... | ... |
src/main/java/com/sincere/student/service/impl/MessageServiceImpl.java
... | ... | @@ -35,7 +35,11 @@ public class MessageServiceImpl implements MessageService { |
35 | 35 | List<Message> list = messageMapper.getList(messageSearchDto) ; |
36 | 36 | for(Message message : list){ |
37 | 37 | message.setDistanceTimes(DateUtils.getDistanceTimes(new Date(),message.getCreateTime())); |
38 | - message.setList(replyMapper.selectByMessageId(message.getId())); | |
38 | + List<Reply> replies = replyMapper.selectByMessageId(message.getId()); | |
39 | + for(Reply reply : replies){ | |
40 | + reply.setDistanceTimes(DateUtils.getDistanceTimes(new Date(),reply.getCreateTime())); | |
41 | + } | |
42 | + message.setList(replies); | |
39 | 43 | } |
40 | 44 | page.setList(list); |
41 | 45 | page.setCount(messageMapper.getListCount(messageSearchDto)); | ... | ... |
src/main/java/com/sincere/student/service/impl/UniversityServiceImpl.java
... | ... | @@ -56,6 +56,11 @@ public class UniversityServiceImpl implements UniversityService { |
56 | 56 | } |
57 | 57 | |
58 | 58 | @Override |
59 | + public University getById(int id) { | |
60 | + return universityMapper.getById(id); | |
61 | + } | |
62 | + | |
63 | + @Override | |
59 | 64 | public int update(University university) { |
60 | 65 | return universityMapper.update(university); |
61 | 66 | } | ... | ... |
src/main/java/com/sincere/student/service/impl/VideoServiceImpl.java
src/main/resources/mapper/ArticleMapper.xml
... | ... | @@ -64,6 +64,10 @@ |
64 | 64 | order by sort |
65 | 65 | </select> |
66 | 66 | |
67 | + <select id="getAdvert" resultMap="ArticleMap"> | |
68 | + select top 1 * from university_article where type = 1 ORDER BY NEWID() | |
69 | + </select> | |
70 | + | |
67 | 71 | <select id="getRelationList" parameterType="java.lang.Integer" resultMap="ArticleMap"> |
68 | 72 | select top 3 * from university_article where university_id = #{universityId} |
69 | 73 | </select> |
... | ... | @@ -72,7 +76,7 @@ |
72 | 76 | select * from university_article where id = #{id} |
73 | 77 | </select> |
74 | 78 | |
75 | - <insert id="create" parameterType="com.sincere.student.model.Article" > | |
79 | + <insert id="create" parameterType="com.sincere.student.model.Article" useGeneratedKeys="true" keyProperty="id"> | |
76 | 80 | insert into university_article (title,column_type,university_id,sort,context,author,image_url,video_url,article_link,good_number,look_number,create_time,type,status) |
77 | 81 | values (#{title},#{columnType},#{universityId},#{sort},#{context},#{author},#{imageUrl},#{videoUrl},#{articleLink},#{goodNumber},#{lookNumber},GETDATE(),#{type},#{status}) |
78 | 82 | </insert> | ... | ... |
src/main/resources/mapper/UniversityConsultMapper.xml
... | ... | @@ -86,6 +86,11 @@ |
86 | 86 | order by c.sort |
87 | 87 | </select> |
88 | 88 | |
89 | + <select id="selectByUniversityIdAndColumnType" parameterType="com.sincere.student.model.UniversityConsult" resultMap="DetailMap"> | |
90 | + select * from university_consult | |
91 | + where university_id =#{universityId} and column_type = #{columnType} | |
92 | + </select> | |
93 | + | |
89 | 94 | <select id="getColumnListCount" parameterType="java.lang.Integer" resultType="java.lang.Integer"> |
90 | 95 | select count(DISTINCT c.id) from university_consult c |
91 | 96 | join university_info info on c.university_id = info.id | ... | ... |
src/main/resources/mapper/UniversityMapper.xml
... | ... | @@ -34,6 +34,11 @@ |
34 | 34 | </where> |
35 | 35 | </select> |
36 | 36 | |
37 | + | |
38 | + <select id="getById" parameterType="java.lang.Integer" resultMap="UniversityMap"> | |
39 | + select * from university_info where id = #{id} | |
40 | + </select> | |
41 | + | |
37 | 42 | <insert id="create" parameterType="com.sincere.student.model.University" > |
38 | 43 | insert into university_info (name,code,university_type,department,province,city,level,create_time,phone,logo_url) |
39 | 44 | values (#{name},#{code},#{universityType},#{department},#{province},#{city},#{level},GETDATE(),#{phone},#{logoUrl}) |
... | ... | @@ -80,4 +85,5 @@ |
80 | 85 | <select id="selectByName" parameterType="java.lang.String" resultType="java.lang.Integer"> |
81 | 86 | select id from university_info where name = #{name} |
82 | 87 | </select> |
88 | + | |
83 | 89 | </mapper> | ... | ... |
src/main/resources/mapper/UniversityReplyMapper.xml
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | <include refid="Base_Column_List" /> |
16 | 16 | from university_reply |
17 | 17 | where message_id = #{id,jdbcType=INTEGER} |
18 | + order by create_time | |
18 | 19 | </select> |
19 | 20 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> |
20 | 21 | delete from university_reply | ... | ... |
src/main/resources/mapper/VideoMapper.xml
... | ... | @@ -108,7 +108,7 @@ |
108 | 108 | order by sort |
109 | 109 | </select> |
110 | 110 | |
111 | - <insert id="create" parameterType="com.sincere.student.model.Video" > | |
111 | + <insert id="create" parameterType="com.sincere.student.model.Video" useGeneratedKeys="true" keyProperty="id"> | |
112 | 112 | insert into university_video (column_type,university_id,sort,video_url,create_time,status,duration,cover_url,video_name) |
113 | 113 | values (#{columnType},#{universityId},#{sort},#{videoUrl},GETDATE(),#{status},#{duration},#{coverUrl},#{videoName}) |
114 | 114 | </insert> | ... | ... |