Commit 4dbd6f3841ef92266492fabf8dfcfbd9ba21a4b2
1 parent
05508d96
Exists in
master
bug 修复
Showing
19 changed files
with
240 additions
and
61 deletions
Show diff stats
pom.xml
... | ... | @@ -32,7 +32,11 @@ |
32 | 32 | <scope>test</scope> |
33 | 33 | </dependency> |
34 | 34 | |
35 | - | |
35 | + <dependency> | |
36 | + <groupId>com.aliyun.oss</groupId> | |
37 | + <artifactId>aliyun-sdk-oss</artifactId> | |
38 | + <version>2.8.3</version> | |
39 | + </dependency> | |
36 | 40 | <dependency> |
37 | 41 | <groupId>org.mybatis.generator</groupId> |
38 | 42 | <artifactId>mybatis-generator-core</artifactId> | ... | ... |
src/main/java/com/sincere/student/controller/AdminController.java
... | ... | @@ -112,6 +112,7 @@ public class AdminController { |
112 | 112 | submitFile.setList(points); |
113 | 113 | submitService.create(submitFile); |
114 | 114 | }catch (ResultException e){ |
115 | + e.printStackTrace(); | |
115 | 116 | result.setSuccess(false); |
116 | 117 | result.setMessage(e.getMessage()); |
117 | 118 | } |
... | ... | @@ -383,9 +384,6 @@ public class AdminController { |
383 | 384 | @ApiOperation("新增专业相关接口") |
384 | 385 | @RequestMapping(value = "/major/createMajor" , method = RequestMethod.POST) |
385 | 386 | public BaseDto createMajor(@RequestBody Major major){ |
386 | - if(major.getpId() == 0){ | |
387 | - major.setpId(-1); | |
388 | - } | |
389 | 387 | majorService.create(major); |
390 | 388 | return new BaseDto() ; |
391 | 389 | } | ... | ... |
src/main/java/com/sincere/student/controller/AppController.java
... | ... | @@ -255,13 +255,13 @@ public class AppController { |
255 | 255 | return result ; |
256 | 256 | } |
257 | 257 | |
258 | - @ApiOperation("留言板详情,管理回复 接口") | |
259 | - @RequestMapping(value = "/message/getDetail" , method = RequestMethod.POST) | |
260 | - public BaseDto<Message> getMessageDetail(@RequestBody IdDto idDto){ | |
261 | - BaseDto<Message> result = new BaseDto<>(); | |
262 | - result.setData(messageService.getDetail(idDto.getId())); | |
263 | - return result ; | |
264 | - } | |
258 | +// @ApiOperation("留言板详情,管理回复 接口") | |
259 | +// @RequestMapping(value = "/message/getDetail" , method = RequestMethod.POST) | |
260 | +// public BaseDto<Message> getMessageDetail(@RequestBody IdDto idDto){ | |
261 | +// BaseDto<Message> result = new BaseDto<>(); | |
262 | +// result.setData(messageService.getDetail(idDto.getId())); | |
263 | +// return result ; | |
264 | +// } | |
265 | 265 | |
266 | 266 | @ApiOperation("留言") |
267 | 267 | @RequestMapping(value = "/message/create" , method = RequestMethod.POST) | ... | ... |
src/main/java/com/sincere/student/controller/CommonController.java
1 | 1 | package com.sincere.student.controller; |
2 | 2 | |
3 | +import com.alibaba.fastjson.JSON; | |
4 | +import com.sincere.student.dto.Province; | |
3 | 5 | import com.sincere.student.model.Area; |
4 | 6 | import com.sincere.student.service.CommonService; |
5 | 7 | import io.swagger.annotations.ApiOperation; |
... | ... | @@ -21,6 +23,8 @@ public class CommonController { |
21 | 23 | |
22 | 24 | private static List<Area> list = new ArrayList<>(); |
23 | 25 | |
26 | + private static List<Province> provinces = new ArrayList<>(); | |
27 | + | |
24 | 28 | @ApiOperation("省份") |
25 | 29 | @RequestMapping(value = "getProvince",method = RequestMethod.GET) |
26 | 30 | public List<Area> getProvince(){ |
... | ... | @@ -47,6 +51,48 @@ public class CommonController { |
47 | 51 | return list ; |
48 | 52 | } |
49 | 53 | |
54 | + @ApiOperation("省份") | |
55 | + @RequestMapping(value = "getProvince2",method = RequestMethod.GET) | |
56 | + public List<Province> getProvince2(){ | |
57 | + if(provinces.size() == 0){ | |
58 | + if(list.size() == 0){ | |
59 | + List<Area> areas = commonService.getProvince(); | |
60 | + for(Area area : areas){ | |
61 | + List<Area> cityList = commonService.getCity(area.getCode()); | |
62 | + if(area.getName().contains("市")){ | |
63 | + //获取全部 | |
64 | + area.setList(cityList); | |
65 | + }else { | |
66 | + //获取4位的市 | |
67 | + List<Area> trueCityList = new ArrayList<>(); | |
68 | + for(Area city : cityList){ | |
69 | + if(city.getCode().length() < 6){ | |
70 | + trueCityList.add(city); | |
71 | + } | |
72 | + } | |
73 | + area.setList(trueCityList); | |
74 | + } | |
75 | + } | |
76 | + list = areas ; | |
77 | + } | |
78 | + for(Area area : list){ | |
79 | + Province province = new Province() ; | |
80 | + province.setValue(area.getName()); | |
81 | + province.setLabel(area.getName()); | |
82 | + List<Province> cityList = new ArrayList<>(); | |
83 | + for(Area city : area.getList()){ | |
84 | + Province newCity = new Province(); | |
85 | + newCity.setLabel(city.getName()); | |
86 | + newCity.setValue(city.getName()); | |
87 | + cityList.add(newCity); | |
88 | + } | |
89 | + province.setChildren(cityList); | |
90 | + provinces.add(province); | |
91 | + } | |
92 | + } | |
93 | + return provinces ; | |
94 | + } | |
95 | + | |
50 | 96 | @ApiOperation("市") |
51 | 97 | @RequestMapping(value = "getCity",method = RequestMethod.GET) |
52 | 98 | public List<Area> getCity(String code){ | ... | ... |
... | ... | @@ -0,0 +1,34 @@ |
1 | +package com.sincere.student.dto; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +public class Province { | |
6 | + | |
7 | + private String value ; | |
8 | + private String label ; | |
9 | + private List<Province> children ; | |
10 | + | |
11 | + public String getValue() { | |
12 | + return value; | |
13 | + } | |
14 | + | |
15 | + public void setValue(String value) { | |
16 | + this.value = value; | |
17 | + } | |
18 | + | |
19 | + public String getLabel() { | |
20 | + return label; | |
21 | + } | |
22 | + | |
23 | + public void setLabel(String label) { | |
24 | + this.label = label; | |
25 | + } | |
26 | + | |
27 | + public List<Province> getChildren() { | |
28 | + return children; | |
29 | + } | |
30 | + | |
31 | + public void setChildren(List<Province> children) { | |
32 | + this.children = children; | |
33 | + } | |
34 | +} | ... | ... |
src/main/java/com/sincere/student/mapper/UniversityMajorMapper.java
1 | 1 | package com.sincere.student.mapper; |
2 | 2 | |
3 | +import com.sincere.student.model.Major; | |
3 | 4 | import com.sincere.student.model.UniversityMajor; |
4 | 5 | |
5 | 6 | import java.util.List; |
... | ... | @@ -11,7 +12,7 @@ public interface UniversityMajorMapper { |
11 | 12 | |
12 | 13 | int deleteByUniversityId(int universityId); |
13 | 14 | |
14 | - List<String> selectUniversityMajor(int universityId); | |
15 | + List<Major> selectUniversityMajor(int universityId); | |
15 | 16 | |
16 | 17 | Integer selectIdByMajor(Map<String,String> map); |
17 | 18 | } | ... | ... |
src/main/java/com/sincere/student/model/Major.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 Major { |
... | ... | @@ -15,10 +16,20 @@ public class Major { |
15 | 16 | @ApiModelProperty(value = "必传 专业编码") |
16 | 17 | private String majorCode ; |
17 | 18 | @ApiModelProperty(value = "父级专业id") //-1 说明是一级专业 |
18 | - private int pId ; | |
19 | + private int pid ; | |
19 | 20 | @ApiModelProperty(value = "创建时间") |
20 | 21 | private Date createTime ; |
21 | 22 | |
23 | + private List<Major> children ; | |
24 | + | |
25 | + public List<Major> getChildren() { | |
26 | + return children; | |
27 | + } | |
28 | + | |
29 | + public void setChildren(List<Major> children) { | |
30 | + this.children = children; | |
31 | + } | |
32 | + | |
22 | 33 | public Date getCreateTime() { |
23 | 34 | return createTime; |
24 | 35 | } |
... | ... | @@ -51,11 +62,11 @@ public class Major { |
51 | 62 | this.majorCode = majorCode; |
52 | 63 | } |
53 | 64 | |
54 | - public int getpId() { | |
55 | - return pId; | |
65 | + public int getPid() { | |
66 | + return pid; | |
56 | 67 | } |
57 | 68 | |
58 | - public void setpId(int pId) { | |
59 | - this.pId = pId; | |
69 | + public void setPid(int pid) { | |
70 | + this.pid = pid; | |
60 | 71 | } |
61 | 72 | } | ... | ... |
src/main/java/com/sincere/student/model/Message.java
... | ... | @@ -18,7 +18,16 @@ public class Message { |
18 | 18 | private String phone; |
19 | 19 | @ApiModelProperty(value = "不用传") |
20 | 20 | private Date createTime; |
21 | + @ApiModelProperty(value = "相差的时间") | |
22 | + private Long[] distanceTimes ; | |
21 | 23 | |
24 | + public Long[] getDistanceTimes() { | |
25 | + return distanceTimes; | |
26 | + } | |
27 | + | |
28 | + public void setDistanceTimes(Long[] distanceTimes) { | |
29 | + this.distanceTimes = distanceTimes; | |
30 | + } | |
22 | 31 | |
23 | 32 | private List<Reply> list ; |
24 | 33 | ... | ... |
src/main/java/com/sincere/student/model/University.java
... | ... | @@ -32,7 +32,7 @@ public class University { |
32 | 32 | @ApiModelProperty(value = "创建时间") |
33 | 33 | private Date createTime ; |
34 | 34 | @ApiModelProperty(value = "专业列表,展示用") |
35 | - private List<String> majorList ; | |
35 | + private List<Major> majorList ; | |
36 | 36 | |
37 | 37 | public String getLogoUrl() { |
38 | 38 | return logoUrl; |
... | ... | @@ -122,11 +122,11 @@ public class University { |
122 | 122 | this.createTime = createTime; |
123 | 123 | } |
124 | 124 | |
125 | - public List<String> getMajorList() { | |
125 | + public List<Major> getMajorList() { | |
126 | 126 | return majorList; |
127 | 127 | } |
128 | 128 | |
129 | - public void setMajorList(List<String> majorList) { | |
129 | + public void setMajorList(List<Major> majorList) { | |
130 | 130 | this.majorList = majorList; |
131 | 131 | } |
132 | 132 | } | ... | ... |
src/main/java/com/sincere/student/model/Video.java
... | ... | @@ -30,6 +30,16 @@ public class Video { |
30 | 30 | private String imgUrl ; |
31 | 31 | @ApiModelProperty(value = "视频时长") |
32 | 32 | private String duration ; |
33 | + @ApiModelProperty(value = "视频名称 展示用") | |
34 | + private String videoName ; | |
35 | + | |
36 | + public String getVideoName() { | |
37 | + return videoName; | |
38 | + } | |
39 | + | |
40 | + public void setVideoName(String videoName) { | |
41 | + this.videoName = videoName; | |
42 | + } | |
33 | 43 | |
34 | 44 | public String getDuration() { |
35 | 45 | return duration; | ... | ... |
src/main/java/com/sincere/student/service/impl/MajorServiceImpl.java
... | ... | @@ -26,7 +26,7 @@ public class MajorServiceImpl implements MajorService { |
26 | 26 | major.setMajor("%"+majorSearchDto.getSearch()+"%"); |
27 | 27 | } |
28 | 28 | if(majorSearchDto.getPid() != 0){ |
29 | - major.setpId(majorSearchDto.getPid()); | |
29 | + major.setPid(majorSearchDto.getPid()); | |
30 | 30 | } |
31 | 31 | PageHelper.startPage(majorSearchDto.getPage(),majorSearchDto.getPageSize()); |
32 | 32 | List<Major> list = majorMapper.getList(major); |
... | ... | @@ -37,8 +37,8 @@ public class MajorServiceImpl implements MajorService { |
37 | 37 | |
38 | 38 | @Override |
39 | 39 | public int create(Major major) { |
40 | - if(major.getpId() == 0){ //说明是一级专业 | |
41 | - major.setpId(-1); | |
40 | + if(major.getPid() == 0){ //说明是一级专业 | |
41 | + major.setPid(-1); | |
42 | 42 | } |
43 | 43 | return majorMapper.create(major); |
44 | 44 | } | ... | ... |
src/main/java/com/sincere/student/service/impl/MessageServiceImpl.java
... | ... | @@ -7,11 +7,15 @@ import com.sincere.student.mapper.UniversityReplyMapper; |
7 | 7 | import com.sincere.student.model.Message; |
8 | 8 | import com.sincere.student.model.Reply; |
9 | 9 | import com.sincere.student.service.MessageService; |
10 | +import com.sincere.student.utils.DateUtils; | |
10 | 11 | import com.sincere.student.utils.Page; |
11 | 12 | import org.apache.commons.lang3.StringUtils; |
12 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
13 | 14 | import org.springframework.stereotype.Service; |
14 | 15 | |
16 | +import java.util.Date; | |
17 | +import java.util.List; | |
18 | + | |
15 | 19 | @Service |
16 | 20 | public class MessageServiceImpl implements MessageService { |
17 | 21 | |
... | ... | @@ -28,7 +32,11 @@ public class MessageServiceImpl implements MessageService { |
28 | 32 | messageSearchDto.setSearch("%"+messageSearchDto.getSearch()+"%"); |
29 | 33 | } |
30 | 34 | PageHelper.startPage(messageSearchDto.getPage(),messageSearchDto.getPageSize()); |
31 | - page.setList(messageMapper.getList(messageSearchDto)); | |
35 | + List<Message> list = messageMapper.getList(messageSearchDto) ; | |
36 | + for(Message message : list){ | |
37 | + message.setDistanceTimes(DateUtils.getDistanceTimes(new Date(),message.getCreateTime())); | |
38 | + } | |
39 | + page.setList(list); | |
32 | 40 | page.setCount(messageMapper.getListCount(messageSearchDto)); |
33 | 41 | return page; |
34 | 42 | } | ... | ... |
src/main/java/com/sincere/student/service/impl/SubmitServiceImpl.java
... | ... | @@ -101,6 +101,6 @@ public class SubmitServiceImpl implements SubmitService { |
101 | 101 | pointMapper.insertBatch(list); |
102 | 102 | } |
103 | 103 | } |
104 | - return submitFileMapper.updateByPrimaryKey(submitFile); | |
104 | + return submitFileMapper.updateByPrimaryKeySelective(submitFile); | |
105 | 105 | } |
106 | 106 | } | ... | ... |
src/main/java/com/sincere/student/service/impl/VideoServiceImpl.java
... | ... | @@ -10,6 +10,8 @@ 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.List; | |
14 | + | |
13 | 15 | @Service |
14 | 16 | public class VideoServiceImpl implements VideoService { |
15 | 17 | |
... | ... | @@ -35,8 +37,14 @@ public class VideoServiceImpl implements VideoService { |
35 | 37 | if(StringUtils.isNotBlank(dto.getUniversityName())){ |
36 | 38 | dto.setUniversityName("%"+dto.getUniversityName()+"%"); |
37 | 39 | } |
40 | + | |
38 | 41 | PageHelper.startPage(dto.getPage(),dto.getPageSize()); |
39 | - page.setList(videoMapper.getList(dto)); | |
42 | + List<Video> list = videoMapper.getList(dto); | |
43 | + for(Video video : list){ | |
44 | + String fileName = video.getVideoUrl().substring(video.getVideoUrl().lastIndexOf("/")+1); | |
45 | + video.setVideoName(fileName); | |
46 | + } | |
47 | + page.setList(list); | |
40 | 48 | page.setCount(videoMapper.getListCount(dto)); |
41 | 49 | return page; |
42 | 50 | } | ... | ... |
... | ... | @@ -0,0 +1,32 @@ |
1 | +package com.sincere.student.utils; | |
2 | + | |
3 | +import java.text.DateFormat; | |
4 | +import java.text.SimpleDateFormat; | |
5 | +import java.util.Date; | |
6 | + | |
7 | +public class DateUtils { | |
8 | + | |
9 | + public static Long[] getDistanceTimes(Date one, Date two) { | |
10 | + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
11 | + long day = 0; | |
12 | + long hour = 0; | |
13 | + long min = 0; | |
14 | + long sec = 0; | |
15 | + long time1 = one.getTime(); | |
16 | + long time2 = two.getTime(); | |
17 | + long diff; | |
18 | + if (time1 < time2) { | |
19 | + diff = time2 - time1; | |
20 | + } else { | |
21 | + diff = time1 - time2; | |
22 | + } | |
23 | + day = diff / (24 * 60 * 60 * 1000); | |
24 | + hour = (diff / (60 * 60 * 1000) - day * 24); | |
25 | + min = ((diff / (60 * 1000)) - day * 24 * 60 - hour * 60); | |
26 | + sec = (diff / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60); | |
27 | + | |
28 | + Long[] times = { day, hour, min, sec }; | |
29 | + return times; | |
30 | + } | |
31 | + | |
32 | +} | ... | ... |
src/main/java/com/sincere/student/utils/ExcelUtils.java
1 | 1 | package com.sincere.student.utils; |
2 | 2 | |
3 | +import com.aliyun.oss.OSSClient; | |
4 | +import com.aliyun.oss.model.OSSObject; | |
3 | 5 | import com.sincere.student.model.Point; |
4 | 6 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
5 | 7 | import org.apache.poi.ss.usermodel.*; |
6 | 8 | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
7 | 9 | |
8 | 10 | import java.io.File; |
9 | -import java.io.FileInputStream; | |
10 | 11 | import java.io.InputStream; |
11 | -import java.net.HttpURLConnection; | |
12 | -import java.net.URL; | |
13 | 12 | import java.util.ArrayList; |
14 | 13 | import java.util.List; |
15 | 14 | |
16 | 15 | public class ExcelUtils { |
17 | 16 | |
17 | + public static OSSClient ossClient = null ; | |
18 | 18 | |
19 | - public static InputStream GetFileInputStream(String fileUrl){ | |
20 | - try{ | |
21 | - URL url = new URL(fileUrl); | |
22 | - HttpURLConnection conn = (HttpURLConnection)url.openConnection(); | |
23 | - //设置超时间为3秒 | |
24 | - conn.setConnectTimeout(8*1000); | |
25 | - //得到输入流 | |
26 | - InputStream inputStream = conn.getInputStream(); | |
27 | - | |
28 | - return inputStream ; | |
29 | - }catch (Exception e){ | |
19 | + private static final String key = "QiuM3PwHTnVotcGy" ; | |
20 | + private static final String secret = "Yqs7RlaC1MioZu2YYJ6u0TdeO13VFC" ; | |
21 | + private static final String endPoint = "http://oss-cn-hangzhou.aliyuncs.com" ; | |
22 | + private static final String bucketName = "szyundisk" ; | |
23 | + private static final String domain = "https://szyundisk.oss-cn-hangzhou.aliyuncs.com/" ; | |
30 | 24 | |
25 | + public static synchronized OSSClient getInstance() { | |
26 | + if (ossClient == null) { | |
27 | + synchronized (ExcelUtils.class) { | |
28 | + if (ossClient == null) { | |
29 | + ossClient = new OSSClient(endPoint, key, secret); | |
30 | + } | |
31 | + } | |
31 | 32 | } |
32 | - return null ; | |
33 | + return ossClient; | |
33 | 34 | } |
34 | 35 | |
35 | 36 | public static List<Point> analysisExcel(String url) throws ResultException{ |
37 | + InputStream inputStream = null ; | |
38 | + OSSClient ossClient = getInstance(); | |
39 | + OSSObject object = ossClient.getObject(bucketName,url.replace(domain,"")); | |
36 | 40 | try{ |
37 | 41 | File excelFile = new File(url); |
38 | 42 | // 获得工作簿 |
39 | 43 | String file = excelFile.getName(); |
40 | 44 | Workbook workbook = null; |
41 | - InputStream inputStream = GetFileInputStream(url); | |
42 | - //InputStream inputStream = new FileInputStream(url); | |
45 | + inputStream = object.getObjectContent(); | |
43 | 46 | if(inputStream == null){ |
44 | 47 | throw new ResultException(901,"路径错误"); |
45 | 48 | } |
... | ... | @@ -87,8 +90,15 @@ public class ExcelUtils { |
87 | 90 | } |
88 | 91 | return list ; |
89 | 92 | }catch (Exception e){ |
90 | - e.printStackTrace(); | |
91 | 93 | throw new ResultException(999,"系统错误"); |
94 | + }finally { | |
95 | + try{ | |
96 | + inputStream.close(); | |
97 | + object.close(); | |
98 | + }catch (Exception e){ | |
99 | + | |
100 | + } | |
101 | + | |
92 | 102 | } |
93 | 103 | } |
94 | 104 | } | ... | ... |
src/main/resources/mapper/MajorMapper.xml
... | ... | @@ -6,15 +6,15 @@ |
6 | 6 | <id column="id" property="id"/> |
7 | 7 | <result column="major" property="major"/> |
8 | 8 | <result column="major_code" property="majorCode"/> |
9 | - <result column="p_id" property="pId"/> | |
9 | + <result column="p_id" property="pid"/> | |
10 | 10 | <result column="create_time" property="createTime"/> |
11 | 11 | </resultMap> |
12 | 12 | |
13 | 13 | <select id="getList" parameterType="com.sincere.student.model.Major" resultMap="MajorMap"> |
14 | 14 | select * from university_major |
15 | 15 | <where> |
16 | - <if test="pId != 0"> | |
17 | - and p_id = #{pId} | |
16 | + <if test="pid != 0"> | |
17 | + and p_id = #{pid} | |
18 | 18 | </if> |
19 | 19 | <if test="major != null and major != ''"> |
20 | 20 | and major like #{major} |
... | ... | @@ -25,21 +25,18 @@ |
25 | 25 | <select id="getListCount" parameterType="com.sincere.student.model.Major" resultType="java.lang.Integer"> |
26 | 26 | select count(0) from university_major |
27 | 27 | <where> |
28 | - <if test="pId >= 0"> | |
29 | - and p_id = #{pId} | |
28 | + <if test="pid != 0"> | |
29 | + and p_id = #{pid} | |
30 | 30 | </if> |
31 | 31 | <if test="major != null and major != ''"> |
32 | 32 | and major like #{major} |
33 | 33 | </if> |
34 | - <if test="majorCode != null"> | |
35 | - and major_code like #{majorCode} | |
36 | - </if> | |
37 | 34 | </where> |
38 | 35 | </select> |
39 | 36 | |
40 | 37 | <insert id="create" parameterType="com.sincere.student.model.Major" > |
41 | 38 | insert into university_major (major,major_code,p_id,create_time) |
42 | - values (#{major},#{majorCode},#{pId},GETDATE()) | |
39 | + values (#{major},#{majorCode},#{pid},GETDATE()) | |
43 | 40 | </insert> |
44 | 41 | |
45 | 42 | <delete id="delete" parameterType="java.lang.Integer"> | ... | ... |
src/main/resources/mapper/UniversityMajorMapper.xml
... | ... | @@ -7,6 +7,15 @@ |
7 | 7 | <result column="major_id" property="majorId"/> |
8 | 8 | </resultMap> |
9 | 9 | |
10 | + <resultMap id="MajorMap" type="com.sincere.student.model.Major"> | |
11 | + <result column="f_id" property="id"/> | |
12 | + <result column="f_major" property="major"/> | |
13 | + <collection property="children" ofType="com.sincere.student.model.Major"> | |
14 | + <result column="s_id" property="id"/> | |
15 | + <result column="s_major" property="major"/> | |
16 | + </collection> | |
17 | + </resultMap> | |
18 | + | |
10 | 19 | <insert id="insertBatch" parameterType="java.util.List"> |
11 | 20 | insert into university_relate_major ( university_id , major_id) |
12 | 21 | values |
... | ... | @@ -19,9 +28,11 @@ |
19 | 28 | delete university_relate_major where university_id = #{universityId} |
20 | 29 | </delete> |
21 | 30 | |
22 | - <select id="selectUniversityMajor" parameterType="java.lang.Integer" resultType="java.lang.String" > | |
23 | - select m.major from university_relate_major r | |
24 | - join university_major m on m.id = r.major_id | |
31 | + <select id="selectUniversityMajor" parameterType="java.lang.Integer" resultMap="MajorMap" > | |
32 | + select f.id as f_id , f.major as f_major , s.id as s_id , s.major as s_major from | |
33 | + university_major s | |
34 | + join university_major f on f.id = s.p_id | |
35 | + join university_relate_major r on s.id = r.major_id | |
25 | 36 | where r.university_id = #{id} |
26 | 37 | </select> |
27 | 38 | ... | ... |
src/main/resources/mapper/UniversitySubmitFileMapper.xml
... | ... | @@ -165,17 +165,17 @@ |
165 | 165 | <update id="updateByPrimaryKeySelective" parameterType="com.sincere.student.model.SubmitFile"> |
166 | 166 | update university_submit_file |
167 | 167 | <set> |
168 | - <if test="title != null"> | |
168 | + <if test="title != null and title != ''"> | |
169 | 169 | title = #{title,jdbcType=VARCHAR}, |
170 | 170 | </if> |
171 | - <if test="year != null"> | |
171 | + <if test="year != null and year != ''"> | |
172 | 172 | year = #{year,jdbcType=VARCHAR}, |
173 | 173 | </if> |
174 | - <if test="sort != null"> | |
174 | + <if test="sort != 0"> | |
175 | 175 | sort = #{sort,jdbcType=INTEGER}, |
176 | 176 | </if> |
177 | - <if test="createTime != null"> | |
178 | - create_time = #{createTime,jdbcType=TIMESTAMP}, | |
177 | + <if test="fileUrl != null and fileUrl != ''"> | |
178 | + file_url = #{fileUrl,jdbcType=VARCHAR}, | |
179 | 179 | </if> |
180 | 180 | </set> |
181 | 181 | where id = #{id,jdbcType=INTEGER} | ... | ... |