Browse Source

家校互动代码跟新

guq 6 years ago
parent
commit
b12d3dc8c4

+ 3 - 6
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/controller/SchoolController.java

@@ -4,10 +4,7 @@ import com.usoftchina.smartschool.base.Result;
 import com.usoftchina.smartschool.school.basic.service.SchoolService;
 import com.usoftchina.smartschool.school.po.SysSchool;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * 学校信息
@@ -21,13 +18,13 @@ public class SchoolController {
     @Autowired
     private SchoolService schoolService;
 
-    @RequestMapping("/read/{id}")
+    @GetMapping("/read/{id}")
     public Result getFormData(@PathVariable("id") Long id) {
         SysSchool school = schoolService.getFormData(id);
         return Result.success(school);
     }
 
-    @RequestMapping("/save")
+    @PostMapping("/save")
     public Result saveFormData(@RequestBody SysSchool school) {
         schoolService.saveFormData(school);
         return Result.success();

+ 1 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/controller/StudentController.java

@@ -32,7 +32,7 @@ public class StudentController {
         return Result.success(student);
     }
 
-    @PostMapping("/read/{id}")
+    @GetMapping("/read/{id}")
     public Result getFormData(@PathVariable("id") Long id) {
          StudentForm formData = studentService.getFormData(id);
         return Result.success(formData);

+ 48 - 5
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/ClassServiceImpl.java

@@ -7,13 +7,12 @@ import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.exception.BizExceptionCode;
 import com.usoftchina.smartschool.school.mapper.SysClazzMapper;
 import com.usoftchina.smartschool.school.mapper.SysStudentMapper;
-import com.usoftchina.smartschool.school.po.ClassForm;
-import com.usoftchina.smartschool.school.po.SysClazz;
-import com.usoftchina.smartschool.school.po.SysStudent;
-import com.usoftchina.smartschool.school.po.TeacherDetail;
+import com.usoftchina.smartschool.school.po.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -52,8 +51,52 @@ public class ClassServiceImpl implements ClassService{
         }
         SysClazz clazz = formdata.getMain();
         List<SysStudent> students = formdata.getItems1();
+        Long id = clazz.getClazz_id();
+        Long school_id = BaseContextHolder.getSchoolId();
+        school_id = 1l;
 
-        return null;
+        //插入从表数据
+        List<SysStudent> insertDetails = new ArrayList<>();
+        //更新从表数据
+        List<SysStudent> updateDetails = new ArrayList<>();
+        //新增
+        if (StringUtils.isEmpty(id) || "0".equals(id.toString())) {
+            clazz.setClazz_status(1);
+            sysClazzMapper.insertSelective(clazz);
+            for (SysStudent student : students) {
+                student.setClazz_id(clazz.getClazz_id());
+                student.setStu_status(1);
+                student.setSchool_id(school_id);
+                sysStudentMapper.insertSelective(student);
+            }
+            return new DocBaseDTO(clazz.getClazz_id());
+        }
+        //更新
+        sysClazzMapper.updateByPrimaryKeySelective(clazz);
+        //更新明细
+        for (SysStudent detail : students) {
+            detail.setClazz_id(clazz.getClazz_id());
+            if (StringUtils.isEmpty(detail.getStu_id()) || "0".equals(detail.getStu_id().toString())) {
+                insertDetails.add(detail);
+            } else {
+                updateDetails.add(detail);
+            }
+        }
+        //插入从表
+        if (insertDetails.size() > 0) {
+            Long pr_id = null;
+            for (SysStudent item : insertDetails) {
+                item.setSchool_id(school_id);
+                sysStudentMapper.insertSelective(item);
+            }
+        }
+        //更新从表
+        if (updateDetails.size() > 0) {
+            for (SysStudent item : updateDetails) {
+                sysStudentMapper.updateByPrimaryKeySelective(item);
+            }
+        }
+        return new DocBaseDTO(clazz.getClazz_id());
     }
 
     @Override

+ 3 - 4
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/StudentServiceImpl.java

@@ -110,7 +110,7 @@ public class StudentServiceImpl implements StudentService{
         //插入从表
         if (insertDetails.size() > 0) {
             Long pr_id = null;
-            for (SysParents item : items) {
+            for (SysParents item : insertDetails) {
                 item.setSchool_id(schoolid);
                 sysStudentMapper.insertparent(item);
                 pr_id = item.getParent_id();
@@ -120,12 +120,11 @@ public class StudentServiceImpl implements StudentService{
         //更新从表
         if (updateDetails.size() > 0) {
             sysStudentMapper.updateParents(updateDetails);
-            for (SysParents item : items) {
+            for (SysParents item : updateDetails) {
                 sysStudentMapper.updateRelation(item.getParent_id(), id, item.getPr_relation());
             }
         }
-
-        return null;
+        return new DocBaseDTO(id, null, "student");
     }
 
     @Override

+ 40 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/OutInRecord.java

@@ -22,6 +22,46 @@ public class OutInRecord implements Serializable{
 
     private Long school_id;
 
+    private String stu_name;
+
+    private Integer stu_sex;
+
+    private String stu_number;
+
+    private String clazz_name;
+
+    public String getStu_name() {
+        return stu_name;
+    }
+
+    public void setStu_name(String stu_name) {
+        this.stu_name = stu_name;
+    }
+
+    public Integer getStu_sex() {
+        return stu_sex;
+    }
+
+    public void setStu_sex(Integer stu_sex) {
+        this.stu_sex = stu_sex;
+    }
+
+    public String getStu_number() {
+        return stu_number;
+    }
+
+    public void setStu_number(String stu_number) {
+        this.stu_number = stu_number;
+    }
+
+    public String getClazz_name() {
+        return clazz_name;
+    }
+
+    public void setClazz_name(String clazz_name) {
+        this.clazz_name = clazz_name;
+    }
+
     public Long getRecord_id() {
         return record_id;
     }

+ 7 - 2
applications/school/school-server/src/main/resources/mapper/OutInRecordMapper.xml

@@ -10,6 +10,10 @@
     <result column="record_remarks" property="record_remarks" jdbcType="VARCHAR" />
     <result column="stu_id" property="stu_id" jdbcType="BIGINT" />
     <result column="school_id" property="school_id" jdbcType="BIGINT" />
+    <result column="clazz_name" property="clazz_name" jdbcType="VARCHAR"/>
+    <result column="stu_name" property="stu_name" jdbcType="VARCHAR"/>
+    <result column="stu_sex" property="stu_sex" jdbcType="INTEGER"/>
+    <result column="stu_number" property="stu_number" jdbcType="VARCHAR"/>
   </resultMap>
   <sql id="Base_Column_List" >
     record_id, record_name, out_date, in_date, record_details, record_remarks,
@@ -128,13 +132,14 @@
   </update>
 
   <select id="selectByConditon" resultMap="BaseResultMap">
-    select * from out_in_record
+    select * from out_in_record left join sys_student on out_in_record.stu_id = sys_student.stu_id
+    left join sys_clazz on sys_student.clazz_id = sys_clazz.clazz_id
     <where>
       <if test="con != null">
         ${con}
       </if>
       <if test="school_id != null">
-        and school_id=#{school_id}
+        and out_in_record.school_id=#{school_id}
       </if>
     </where>
     ORDER BY record_id DESC