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,6 +12,7 @@ import com.sincere.student.utils.Page; | ||
12 | import com.sincere.student.utils.ResultException; | 12 | import com.sincere.student.utils.ResultException; |
13 | import com.sincere.student.utils.TokenUtils; | 13 | import com.sincere.student.utils.TokenUtils; |
14 | import io.swagger.annotations.ApiOperation; | 14 | import io.swagger.annotations.ApiOperation; |
15 | +import io.swagger.models.auth.In; | ||
15 | import org.apache.commons.lang3.StringUtils; | 16 | import org.apache.commons.lang3.StringUtils; |
16 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
17 | import org.springframework.web.bind.annotation.RequestBody; | 18 | import org.springframework.web.bind.annotation.RequestBody; |
@@ -248,9 +249,20 @@ public class AdminController { | @@ -248,9 +249,20 @@ public class AdminController { | ||
248 | @MemberAccess | 249 | @MemberAccess |
249 | @ApiOperation("新建招生咨询会相关接口") | 250 | @ApiOperation("新建招生咨询会相关接口") |
250 | @RequestMapping(value = "/consult/createConsult" , method = RequestMethod.POST) | 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 | return result ; | 266 | return result ; |
255 | } | 267 | } |
256 | 268 | ||
@@ -289,9 +301,14 @@ public class AdminController { | @@ -289,9 +301,14 @@ public class AdminController { | ||
289 | @MemberAccess | 301 | @MemberAccess |
290 | @ApiOperation("新建视频相关接口") | 302 | @ApiOperation("新建视频相关接口") |
291 | @RequestMapping(value = "/video/createVideo" , method = RequestMethod.POST) | 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 | return result ; | 312 | return result ; |
296 | } | 313 | } |
297 | 314 | ||
@@ -461,13 +478,14 @@ public class AdminController { | @@ -461,13 +478,14 @@ public class AdminController { | ||
461 | @MemberAccess | 478 | @MemberAccess |
462 | @ApiOperation("新建权威解读(文章广告)相关接口") | 479 | @ApiOperation("新建权威解读(文章广告)相关接口") |
463 | @RequestMapping(value = "/article/createArticle" , method = RequestMethod.POST) | 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 | if(StringUtils.isBlank(article.getImageUrl())){ | 483 | if(StringUtils.isBlank(article.getImageUrl())){ |
467 | result.setSuccess(false); | 484 | result.setSuccess(false); |
468 | result.setMessage("请上传封面图片"); | 485 | result.setMessage("请上传封面图片"); |
469 | }else { | 486 | }else { |
470 | - articleService.create(article); | 487 | + int id = articleService.create(article); |
488 | + result.setData(id); | ||
471 | } | 489 | } |
472 | return result ; | 490 | return result ; |
473 | } | 491 | } |
@@ -0,0 +1,23 @@ | @@ -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
@@ -24,4 +24,6 @@ public interface UniversityConsultMapper { | @@ -24,4 +24,6 @@ public interface UniversityConsultMapper { | ||
24 | 24 | ||
25 | int updateByPrimaryKeySelective(UniversityConsult record); | 25 | int updateByPrimaryKeySelective(UniversityConsult record); |
26 | 26 | ||
27 | + List<Consult> selectByUniversityIdAndColumnType(UniversityConsult consult); | ||
28 | + | ||
27 | } | 29 | } |
28 | \ No newline at end of file | 30 | \ No newline at end of file |
src/main/java/com/sincere/student/mapper/UniversityMapper.java
@@ -15,6 +15,8 @@ public interface UniversityMapper { | @@ -15,6 +15,8 @@ public interface UniversityMapper { | ||
15 | 15 | ||
16 | int delete(int id); | 16 | int delete(int id); |
17 | 17 | ||
18 | + University getById(int id); | ||
19 | + | ||
18 | int update(University university); | 20 | int update(University university); |
19 | 21 | ||
20 | Integer selectByName(String name); | 22 | Integer selectByName(String name); |
src/main/java/com/sincere/student/model/Reply.java
@@ -16,6 +16,17 @@ public class Reply { | @@ -16,6 +16,17 @@ public class Reply { | ||
16 | @ApiModelProperty(value = "不用传") | 16 | @ApiModelProperty(value = "不用传") |
17 | private Date createTime; | 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 | public Integer getId() { | 30 | public Integer getId() { |
20 | return id; | 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,11 +5,15 @@ import com.sincere.student.model.Consult; | ||
5 | import com.sincere.student.model.UniversityConsult; | 5 | import com.sincere.student.model.UniversityConsult; |
6 | import com.sincere.student.utils.Page; | 6 | import com.sincere.student.utils.Page; |
7 | 7 | ||
8 | +import java.util.List; | ||
9 | + | ||
8 | 10 | ||
9 | public interface ConsultService { | 11 | public interface ConsultService { |
10 | 12 | ||
11 | Page<Consult> getList(ConsultSearchDto consultSearchDto); | 13 | Page<Consult> getList(ConsultSearchDto consultSearchDto); |
12 | 14 | ||
15 | + List<Consult> selectByUniversityIdAndColumnType(int universityId , int columnType); | ||
16 | + | ||
13 | Page<Consult> getColumnList(int columnType ,int page ,int pageSize); | 17 | Page<Consult> getColumnList(int columnType ,int page ,int pageSize); |
14 | 18 | ||
15 | Consult getDetail(int id); | 19 | Consult getDetail(int id); |
src/main/java/com/sincere/student/service/UniversityService.java
@@ -16,6 +16,8 @@ public interface UniversityService { | @@ -16,6 +16,8 @@ public interface UniversityService { | ||
16 | 16 | ||
17 | int delete(int id); | 17 | int delete(int id); |
18 | 18 | ||
19 | + University getById(int id); | ||
20 | + | ||
19 | int update(University university); | 21 | int update(University university); |
20 | 22 | ||
21 | int addMajor(List<UniversityMajor> list); | 23 | int addMajor(List<UniversityMajor> list); |
src/main/java/com/sincere/student/service/impl/ArticleServiceImpl.java
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; | @@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; | ||
12 | 12 | ||
13 | import java.util.ArrayList; | 13 | import java.util.ArrayList; |
14 | import java.util.Arrays; | 14 | import java.util.Arrays; |
15 | +import java.util.LinkedList; | ||
15 | import java.util.List; | 16 | import java.util.List; |
16 | 17 | ||
17 | @Service | 18 | @Service |
@@ -33,7 +34,18 @@ public class ArticleServiceImpl implements ArticleService { | @@ -33,7 +34,18 @@ public class ArticleServiceImpl implements ArticleService { | ||
33 | article.setImageUrlList(Arrays.asList(urlList)); | 34 | article.setImageUrlList(Arrays.asList(urlList)); |
34 | article.setImageCount(urlList.length); | 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 | result.setCount(articleMapper.getListCount(articleSearchDto)); | 49 | result.setCount(articleMapper.getListCount(articleSearchDto)); |
38 | return result; | 50 | return result; |
39 | } | 51 | } |
@@ -57,7 +69,8 @@ public class ArticleServiceImpl implements ArticleService { | @@ -57,7 +69,8 @@ public class ArticleServiceImpl implements ArticleService { | ||
57 | if(article.getType() == 1){ | 69 | if(article.getType() == 1){ |
58 | article.setColumnType(0); | 70 | article.setColumnType(0); |
59 | } | 71 | } |
60 | - return articleMapper.create(article); | 72 | + articleMapper.create(article); |
73 | + return article.getId() ; | ||
61 | } | 74 | } |
62 | 75 | ||
63 | @Override | 76 | @Override |
src/main/java/com/sincere/student/service/impl/ConsultServiceImpl.java
@@ -32,6 +32,14 @@ public class ConsultServiceImpl implements ConsultService { | @@ -32,6 +32,14 @@ public class ConsultServiceImpl implements ConsultService { | ||
32 | ColumnMapper columnMapper ; | 32 | ColumnMapper columnMapper ; |
33 | 33 | ||
34 | @Override | 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 | public Page<Consult> getList(ConsultSearchDto consultSearchDto) { | 43 | public Page<Consult> getList(ConsultSearchDto consultSearchDto) { |
36 | Page<Consult> page = new Page<>(consultSearchDto.getPage(),consultSearchDto.getPageSize()); | 44 | Page<Consult> page = new Page<>(consultSearchDto.getPage(),consultSearchDto.getPageSize()); |
37 | if(StringUtils.isNotBlank(consultSearchDto.getUniversityName())){ | 45 | if(StringUtils.isNotBlank(consultSearchDto.getUniversityName())){ |
@@ -80,7 +88,7 @@ public class ConsultServiceImpl implements ConsultService { | @@ -80,7 +88,7 @@ public class ConsultServiceImpl implements ConsultService { | ||
80 | detail.setConsultId(consult.getId()); | 88 | detail.setConsultId(consult.getId()); |
81 | universityConsultDetailMapper.insert(detail); | 89 | universityConsultDetailMapper.insert(detail); |
82 | } | 90 | } |
83 | - return 1 ; | 91 | + return consult.getId() ; |
84 | } | 92 | } |
85 | 93 | ||
86 | @Override | 94 | @Override |
src/main/java/com/sincere/student/service/impl/MessageServiceImpl.java
@@ -35,7 +35,11 @@ public class MessageServiceImpl implements MessageService { | @@ -35,7 +35,11 @@ public class MessageServiceImpl implements MessageService { | ||
35 | List<Message> list = messageMapper.getList(messageSearchDto) ; | 35 | List<Message> list = messageMapper.getList(messageSearchDto) ; |
36 | for(Message message : list){ | 36 | for(Message message : list){ |
37 | message.setDistanceTimes(DateUtils.getDistanceTimes(new Date(),message.getCreateTime())); | 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 | page.setList(list); | 44 | page.setList(list); |
41 | page.setCount(messageMapper.getListCount(messageSearchDto)); | 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,6 +56,11 @@ public class UniversityServiceImpl implements UniversityService { | ||
56 | } | 56 | } |
57 | 57 | ||
58 | @Override | 58 | @Override |
59 | + public University getById(int id) { | ||
60 | + return universityMapper.getById(id); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
59 | public int update(University university) { | 64 | public int update(University university) { |
60 | return universityMapper.update(university); | 65 | return universityMapper.update(university); |
61 | } | 66 | } |
src/main/java/com/sincere/student/service/impl/VideoServiceImpl.java
@@ -52,7 +52,8 @@ public class VideoServiceImpl implements VideoService { | @@ -52,7 +52,8 @@ public class VideoServiceImpl implements VideoService { | ||
52 | 52 | ||
53 | @Override | 53 | @Override |
54 | public int create(Video video) { | 54 | public int create(Video video) { |
55 | - return videoMapper.create(video); | 55 | + videoMapper.create(video); |
56 | + return video.getId(); | ||
56 | } | 57 | } |
57 | 58 | ||
58 | @Override | 59 | @Override |
src/main/resources/mapper/ArticleMapper.xml
@@ -64,6 +64,10 @@ | @@ -64,6 +64,10 @@ | ||
64 | order by sort | 64 | order by sort |
65 | </select> | 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 | <select id="getRelationList" parameterType="java.lang.Integer" resultMap="ArticleMap"> | 71 | <select id="getRelationList" parameterType="java.lang.Integer" resultMap="ArticleMap"> |
68 | select top 3 * from university_article where university_id = #{universityId} | 72 | select top 3 * from university_article where university_id = #{universityId} |
69 | </select> | 73 | </select> |
@@ -72,7 +76,7 @@ | @@ -72,7 +76,7 @@ | ||
72 | select * from university_article where id = #{id} | 76 | select * from university_article where id = #{id} |
73 | </select> | 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 | 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) | 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 | values (#{title},#{columnType},#{universityId},#{sort},#{context},#{author},#{imageUrl},#{videoUrl},#{articleLink},#{goodNumber},#{lookNumber},GETDATE(),#{type},#{status}) | 81 | values (#{title},#{columnType},#{universityId},#{sort},#{context},#{author},#{imageUrl},#{videoUrl},#{articleLink},#{goodNumber},#{lookNumber},GETDATE(),#{type},#{status}) |
78 | </insert> | 82 | </insert> |
src/main/resources/mapper/UniversityConsultMapper.xml
@@ -86,6 +86,11 @@ | @@ -86,6 +86,11 @@ | ||
86 | order by c.sort | 86 | order by c.sort |
87 | </select> | 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 | <select id="getColumnListCount" parameterType="java.lang.Integer" resultType="java.lang.Integer"> | 94 | <select id="getColumnListCount" parameterType="java.lang.Integer" resultType="java.lang.Integer"> |
90 | select count(DISTINCT c.id) from university_consult c | 95 | select count(DISTINCT c.id) from university_consult c |
91 | join university_info info on c.university_id = info.id | 96 | join university_info info on c.university_id = info.id |
src/main/resources/mapper/UniversityMapper.xml
@@ -34,6 +34,11 @@ | @@ -34,6 +34,11 @@ | ||
34 | </where> | 34 | </where> |
35 | </select> | 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 | <insert id="create" parameterType="com.sincere.student.model.University" > | 42 | <insert id="create" parameterType="com.sincere.student.model.University" > |
38 | insert into university_info (name,code,university_type,department,province,city,level,create_time,phone,logo_url) | 43 | insert into university_info (name,code,university_type,department,province,city,level,create_time,phone,logo_url) |
39 | values (#{name},#{code},#{universityType},#{department},#{province},#{city},#{level},GETDATE(),#{phone},#{logoUrl}) | 44 | values (#{name},#{code},#{universityType},#{department},#{province},#{city},#{level},GETDATE(),#{phone},#{logoUrl}) |
@@ -80,4 +85,5 @@ | @@ -80,4 +85,5 @@ | ||
80 | <select id="selectByName" parameterType="java.lang.String" resultType="java.lang.Integer"> | 85 | <select id="selectByName" parameterType="java.lang.String" resultType="java.lang.Integer"> |
81 | select id from university_info where name = #{name} | 86 | select id from university_info where name = #{name} |
82 | </select> | 87 | </select> |
88 | + | ||
83 | </mapper> | 89 | </mapper> |
src/main/resources/mapper/UniversityReplyMapper.xml
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | <include refid="Base_Column_List" /> | 15 | <include refid="Base_Column_List" /> |
16 | from university_reply | 16 | from university_reply |
17 | where message_id = #{id,jdbcType=INTEGER} | 17 | where message_id = #{id,jdbcType=INTEGER} |
18 | + order by create_time | ||
18 | </select> | 19 | </select> |
19 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> | 20 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> |
20 | delete from university_reply | 21 | delete from university_reply |
src/main/resources/mapper/VideoMapper.xml
@@ -108,7 +108,7 @@ | @@ -108,7 +108,7 @@ | ||
108 | order by sort | 108 | order by sort |
109 | </select> | 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 | insert into university_video (column_type,university_id,sort,video_url,create_time,status,duration,cover_url,video_name) | 112 | insert into university_video (column_type,university_id,sort,video_url,create_time,status,duration,cover_url,video_name) |
113 | values (#{columnType},#{universityId},#{sort},#{videoUrl},GETDATE(),#{status},#{duration},#{coverUrl},#{videoName}) | 113 | values (#{columnType},#{universityId},#{sort},#{videoUrl},GETDATE(),#{status},#{duration},#{coverUrl},#{videoName}) |
114 | </insert> | 114 | </insert> |