Browse Source

学校关联附属学校相关内容

tags/正式版本
王宁 2 years ago
parent
commit
3c3c67152b

+ 39
- 1
sapi/src/main/java/com/xhkjedu/sapi/controller/system/SchoolController.java View File

@@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
4 4
 import com.github.pagehelper.PageInfo;
5 5
 import com.xhkjedu.sapi.model.system.TSchool;
6 6
 import com.xhkjedu.sapi.service.system.SchoolService;
7
+import com.xhkjedu.sapi.vo.analyze.SchoolParams;
7 8
 import com.xhkjedu.utils.N_Utils;
8 9
 import com.xhkjedu.utils.PageUtil;
9 10
 import com.xhkjedu.vo.PageResult;
@@ -63,7 +64,7 @@ public class SchoolController {
63 64
         Integer pageSize = tSchool.getPageSize();
64 65
         N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1});
65 66
         PageHelper.startPage(page, pageSize);
66
-        List<TSchool> list = schoolService.findAll();
67
+        List<Map> list = schoolService.findAll();
67 68
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
68 69
         return new ResultVo(0,"获取列表成功",pageResult);
69 70
     }
@@ -121,4 +122,41 @@ public class SchoolController {
121 122
         Integer limitenolen = schoolService.getLimiteNoLen(schoolid);
122 123
         return new ResultVo(0, "获取成功", limitenolen);
123 124
     }
125
+
126
+    /**
127
+     * @Description 保存学校关联学校
128
+     * @Param [params]
129
+     * @Return com.xhkjedu.vo.ResultVo
130
+     * @Author wn
131
+     * @Date 2022/9/22 16:24
132
+     **/
133
+    @PostMapping("/sfschool")
134
+    public ResultVo saveSchoolFriend(@RequestBody SchoolParams params) {
135
+        Integer schoolid = params.getSchoolid();
136
+        List<Integer> schoolids = params.getSchoolids();
137
+        N_Utils.validation(new Object[]{schoolid, "学校id", 1});
138
+        if(N_Utils.isListEmpty(schoolids)){
139
+            return new ResultVo(1,"未选择学校");
140
+        }
141
+        schoolService.saveSchoolFriend(params);
142
+        return new ResultVo(0, "保存成功");
143
+    }
144
+
145
+    /**
146
+     * @Description 获取学校关联附属学校id
147
+     * @Param [params]
148
+     * @Return com.xhkjedu.vo.ResultVo
149
+     * @Author wn
150
+     * @Date 2022/9/22 16:40
151
+     **/
152
+    @PostMapping("/getfids")
153
+    public ResultVo getFschoolids(@RequestBody SchoolParams params) {
154
+        Integer schoolid = params.getSchoolid();
155
+        N_Utils.validation(new Object[]{schoolid, "学校id", 1});
156
+        List<Integer> list = schoolService.listFSchoolidsBySchoolid(schoolid);
157
+        return new ResultVo(0, "获取成功",list);
158
+    }
159
+
160
+
161
+
124 162
 }

+ 24
- 0
sapi/src/main/java/com/xhkjedu/sapi/mapper/system/SchoolFriendMapper.java View File

@@ -0,0 +1,24 @@
1
+package com.xhkjedu.sapi.mapper.system;
2
+
3
+import com.xhkjedu.sapi.base.TkMapper;
4
+import com.xhkjedu.sapi.model.system.TSchoolFriend;
5
+import org.apache.ibatis.annotations.Param;
6
+import org.springframework.stereotype.Repository;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * @Description
12
+ * @Author WN
13
+ * Date 2022/9/22 16:08
14
+ **/
15
+@Repository
16
+public interface SchoolFriendMapper extends TkMapper<TSchoolFriend> {
17
+
18
+    //获取关联学校id
19
+    List<Integer> listFSchoolidsBySchoolid(@Param("schoolid")Integer schoolid);
20
+
21
+    //删除学校附属学校
22
+    void deleteBySchoolid(@Param("schoolid")Integer schoolid);
23
+
24
+}

+ 1
- 1
sapi/src/main/java/com/xhkjedu/sapi/mapper/system/SchoolMapper.java View File

@@ -12,7 +12,7 @@ public interface SchoolMapper extends TkMapper<TSchool> {
12 12
     Integer deleteById(@Param("schoolid") Integer schoolid);
13 13
 
14 14
     //列表
15
-    List<TSchool> findAll();
15
+    List<Map> findAll();
16 16
 
17 17
     /**
18 18
      * 学年升级

+ 31
- 0
sapi/src/main/java/com/xhkjedu/sapi/model/system/TSchoolFriend.java View File

@@ -0,0 +1,31 @@
1
+package com.xhkjedu.sapi.model.system;
2
+
3
+import com.xhkjedu.sapi.model.BaseBean;
4
+import lombok.Data;
5
+
6
+import javax.persistence.Id;
7
+import javax.persistence.Table;
8
+
9
+/**
10
+ * @Description
11
+ * @Author WN
12
+ * Date 2022/9/22 16:04
13
+ **/
14
+@Table(name = "t_school_friend")
15
+@Data
16
+public class TSchoolFriend extends BaseBean {
17
+    @Id
18
+    //学校关联附属学校id
19
+    private Integer sfid;
20
+
21
+    //学校id
22
+    private Integer schoolid;
23
+    //附属学校id
24
+    private Integer fschoolid;
25
+
26
+    //创建人
27
+    private Integer createid;
28
+
29
+    //创建时间
30
+    private Integer createtime;
31
+}

+ 29
- 1
sapi/src/main/java/com/xhkjedu/sapi/service/system/SchoolService.java View File

@@ -5,6 +5,7 @@ import com.xhkjedu.sapi.mapper.system.*;
5 5
 import com.xhkjedu.sapi.model.gradeclass.*;
6 6
 import com.xhkjedu.sapi.model.system.*;
7 7
 import com.xhkjedu.sapi.utils.ApiUtil;
8
+import com.xhkjedu.sapi.vo.analyze.SchoolParams;
8 9
 import com.xhkjedu.utils.MD5;
9 10
 import com.xhkjedu.utils.N_Utils;
10 11
 import lombok.extern.slf4j.Slf4j;
@@ -52,6 +53,8 @@ public class SchoolService {
52 53
     private RoleModuleMapper roleModuleMapper;
53 54
     @Autowired
54 55
     private UserRoleMapper userRoleMapper;
56
+    @Resource
57
+    private SchoolFriendMapper schoolFriendMapper;
55 58
 
56 59
     //添加
57 60
     @Transactional(rollbackFor = Exception.class)
@@ -223,7 +226,7 @@ public class SchoolService {
223 226
     }
224 227
 
225 228
     //获取列表
226
-    public List <TSchool> findAll() {
229
+    public List <Map> findAll() {
227 230
         return schoolMapper.findAll();
228 231
     }
229 232
 
@@ -420,4 +423,29 @@ public class SchoolService {
420 423
     public Integer getLimiteNoLen(Integer schoolid) {
421 424
         return schoolMapper.getLimiteNoLen(schoolid);
422 425
     }
426
+
427
+    //保存学校关联附属学校
428
+    @Transactional(rollbackFor = Exception.class)
429
+    public void saveSchoolFriend(SchoolParams params){
430
+        //先移除学校关联学校
431
+        schoolFriendMapper.deleteBySchoolid(params.getSchoolid());
432
+
433
+        List<TSchoolFriend> schoolfriends = new ArrayList<>();
434
+        List<Integer> schoolids  = params.getSchoolids();
435
+        int timestemp = N_Utils.getSecondTimestamp();
436
+        for(Integer shid : schoolids){
437
+            TSchoolFriend sf = new TSchoolFriend();
438
+            sf.setSchoolid(params.getSchoolid());
439
+            sf.setFschoolid(shid);
440
+            sf.setCreateid(params.getCreateid());
441
+            sf.setCreatetime(timestemp);
442
+            schoolfriends.add(sf);
443
+        }
444
+        schoolFriendMapper.insertList(schoolfriends);
445
+    }
446
+
447
+    //获取学校附属学校
448
+    public List<Integer> listFSchoolidsBySchoolid(Integer schoolid){
449
+        return schoolFriendMapper.listFSchoolidsBySchoolid(schoolid);
450
+    }
423 451
 }

+ 5
- 0
sapi/src/main/java/com/xhkjedu/sapi/vo/analyze/SchoolParams.java View File

@@ -2,6 +2,9 @@ package com.xhkjedu.sapi.vo.analyze;
2 2
 
3 3
 import lombok.Data;
4 4
 
5
+import java.util.ArrayList;
6
+import java.util.List;
7
+
5 8
 /**
6 9
  * @ClassName SchoolParams
7 10
  * Description TODO
@@ -23,4 +26,6 @@ public class SchoolParams {
23 26
     private Integer page;//分页显示页码
24 27
     private Integer pageSize;//分页显示条数
25 28
     private Integer year;//分页显示条数
29
+
30
+    private List<Integer> schoolids = new ArrayList<>();
26 31
 }

+ 1
- 1
sapi/src/main/resources/application.properties View File

@@ -52,7 +52,7 @@ secretKey=nanhuakaizhangjianwangni
52 52
 rabbitmq.researchTransferQueue=xhkjedutest.xhschool.researchTransferQueue_dev
53 53
 rabbitmq.resourceDelQueue=xhkjedutest.xhschool.resourceDelQueue_dev
54 54
 rabbitmq.researchHandleQueue=xhkjedutest.xhschool.researchHandleQueue_dev
55
-spring.rabbitmq.host=116.63.199.166
55
+spring.rabbitmq.host=49.4.26.249
56 56
 spring.rabbitmq.port=5672
57 57
 spring.rabbitmq.username=xhkjedu
58 58
 spring.rabbitmq.password=xhkjedud07

+ 13
- 0
sapi/src/main/resources/mapper/system/SchoolFriendMapper.xml View File

@@ -0,0 +1,13 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.xhkjedu.sapi.mapper.system.SchoolFriendMapper">
4
+    <!--获取关联学校id-->
5
+    <select id="listFSchoolidsBySchoolid" resultType="java.lang.Integer">
6
+        select fschoolid from t_school_friend where schoolid=#{schoolid} order by schoolid
7
+    </select>
8
+
9
+    <!--删除学校附属学校-->
10
+    <delete id="deleteBySchoolid">
11
+        delete from t_school_friend where schoolid=#{schoolid}
12
+    </delete>
13
+</mapper>

+ 31
- 1
sapi/src/main/resources/mapper/system/SchoolMapper.xml View File

@@ -5,11 +5,41 @@
5 5
     <update id="deleteById">
6 6
         update t_school set schoolstate=10 where schoolid=#{schoolid}
7 7
     </update>
8
-    <select id="findAll" resultType="com.xhkjedu.sapi.model.system.TSchool">
8
+
9
+    <resultMap id="listSchools" type="java.util.Map">
10
+        <result property="schoolid" column="schoolid"></result>
11
+        <result property="schoolname" column="schoolname"></result>
12
+        <result property="shortname" column="shortname"></result>
13
+        <result property="schoollevel" column="schoollevel"></result>
14
+        <result property="bindmac" column="bindmac"></result>
15
+        <result property="schoolstate" column="schoolstate"></result>
16
+        <result property="year" column="year"></result>
17
+        <result property="errorrate" column="errorrate"></result>
18
+        <result property="schooldomain" column="schooldomain"></result>
19
+        <result property="tesupport" column="tesupport"></result>
20
+        <result property="recordno" column="recordno"></result>
21
+        <result property="limitenolen" column="limitenolen"></result>
22
+        <result property="livenum" column="livenum"></result>
23
+        <result property="livetime" column="livetime"></result>
24
+        <result property="coordinate" column="coordinate"></result>
25
+        <result property="docklc" column="docklc"></result>
26
+        <result property="usernum" column="usernum"></result>
27
+        <result property="createtime" column="createtime"></result>
28
+        <result property="createname" column="createname"></result>
29
+        <result property="loginname" column="loginname"></result>
30
+        <collection property="schools" ofType="java.util.Map" javaType="java.util.List">
31
+            <result property="schoolid" column="fschoolid"></result>
32
+            <result property="schoolname" column="fschoolname"></result>
33
+        </collection>
34
+    </resultMap>
35
+    <select id="findAll" resultMap="listSchools">
9 36
         select s.*,tu.username createname
10 37
         ,(select u.loginname from t_user u where u.schoolid=s.schoolid and u.usertype=0 and u.userstate=1
11 38
         ORDER BY u.userid ASC LIMIT 1)loginname
39
+         ,f.schoolid fschoolid,s2.schoolname fschoolname
12 40
         from t_school s left join t_user tu on s.createid = tu.userid
41
+        left join t_school_friend f on s.schoolid=f.schoolid
42
+        left join t_school s2 on f.fschoolid=s2.schoolid
13 43
         where s.schoolstate=1 order by s.createtime desc
14 44
     </select>
15 45
     <!--学年升级-->

Loading…
Cancel
Save