Explorar o código

家校互动代码跟新

guq %!s(int64=6) %!d(string=hai) anos
pai
achega
074b1cc612
Modificáronse 21 ficheiros con 371 adicións e 40 borrados
  1. 18 8
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/controller/StudentController.java
  2. 18 8
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/controller/TeacherController.java
  3. 5 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/StudentService.java
  4. 5 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/TeacherService.java
  5. 22 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/StudentServiceImpl.java
  6. 25 1
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/TeacherServiceImpl.java
  7. 31 5
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/controller/HomeWorkController.java
  8. 31 7
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/controller/NoticeController.java
  9. 15 1
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/HomeWorkService.java
  10. 14 1
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/NoticeService.java
  11. 66 4
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/HomeWorkServiceImpl.java
  12. 65 4
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/NoticeServiceImpl.java
  13. 1 1
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/exception/BizExceptionCode.java
  14. 6 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/HomeWorkMapper.java
  15. 5 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/NoticeMapper.java
  16. 2 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysStudentMapper.java
  17. 2 0
      applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysTeacherMapper.java
  18. 16 0
      applications/school/school-server/src/main/resources/mapper/HomeWorkMapper.xml
  19. 16 0
      applications/school/school-server/src/main/resources/mapper/NotifyMapper.xml
  20. 4 0
      applications/school/school-server/src/main/resources/mapper/SysStudentMapper.xml
  21. 4 0
      applications/school/school-server/src/main/resources/mapper/SysTeacherMapper.xml

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

@@ -6,16 +6,14 @@ import com.usoftchina.smartschool.base.Result;
 import com.usoftchina.smartschool.page.PageDefault;
 import com.usoftchina.smartschool.page.PageRequest;
 import com.usoftchina.smartschool.school.basic.service.StudentService;
+import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
 import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.po.StudentForm;
 import com.usoftchina.smartschool.school.po.SysSchool;
 import com.usoftchina.smartschool.school.po.SysStudent;
 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.*;
 
 /**
  * @author: guq
@@ -28,28 +26,40 @@ public class StudentController {
     @Autowired
     private StudentService studentService;
 
-    @RequestMapping("/list")
+    @GetMapping("/list")
     public Result getList(@PageDefault PageRequest page, ListReqDTO listReqDTO) {
         PageInfo<SysStudent> student = studentService.getListData(page, listReqDTO);
         return Result.success(student);
     }
 
-    @RequestMapping("/read/{id}")
+    @PostMapping("/read/{id}")
     public Result getFormData(@PathVariable("id") Long id) {
          StudentForm formData = studentService.getFormData(id);
         return Result.success(formData);
     }
 
-    @RequestMapping("/save")
+    @PostMapping("/save")
     public Result getFormData(@RequestBody StudentForm form) {
         DocBaseDTO formData = studentService.saveFormData(form);
         return Result.success(formData);
     }
 
     //导入保存至列表
-    @RequestMapping("/saveToFormal")
+    @PostMapping("/saveToFormal")
     public Result saveToFormal(Integer id, boolean update) {
         studentService.saveToFormal(id, update);
         return Result.success();
     }
+
+    @PostMapping("/delete/{id}")
+    public Result delete(@PathVariable("id") Long id) {
+        studentService.delete(id);
+        return Result.success();
+    }
+
+    @PostMapping("/batchDelete")
+    public Result batchDelete(@RequestBody BatchDealBaseDTO baseDTOs) {
+        studentService.batchDelete(baseDTOs);
+        return Result.success();
+    }
 }

+ 18 - 8
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/controller/TeacherController.java

@@ -5,6 +5,7 @@ import com.usoftchina.smartschool.base.Result;
 import com.usoftchina.smartschool.page.PageDefault;
 import com.usoftchina.smartschool.page.PageRequest;
 import com.usoftchina.smartschool.school.basic.service.TeacherService;
+import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
 import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.po.StudentForm;
@@ -12,10 +13,7 @@ import com.usoftchina.smartschool.school.po.SysStudent;
 import com.usoftchina.smartschool.school.po.SysTeacher;
 import com.usoftchina.smartschool.school.po.TeacherForm;
 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.*;
 
 /**
  * @author: guq
@@ -28,28 +26,40 @@ public class TeacherController {
     @Autowired
     private TeacherService teacherService;
 
-    @RequestMapping("/list")
+    @GetMapping("/list")
     public Result getList(@PageDefault PageRequest page, ListReqDTO listReqDTO) {
         PageInfo<SysTeacher> teacher = teacherService.getListData(page, listReqDTO);
         return Result.success(teacher);
     }
 
-    @RequestMapping("/read/{id}")
+    @GetMapping("/read/{id}")
     public Result getFormData(@PathVariable("id") Long id) {
         TeacherForm formData = teacherService.getFormData(id);
         return Result.success(formData);
     }
 
-    @RequestMapping("/save")
+    @PostMapping("/save")
     public Result getFormData(@RequestBody SysTeacher teacher) {
         DocBaseDTO formData = teacherService.saveFormData(teacher);
         return Result.success(formData);
     }
 
     //导入保存至列表
-    @RequestMapping("/saveToFormal")
+    @PostMapping("/saveToFormal")
     public Result saveToFormal(Integer id, boolean update) {
         teacherService.saveToFormal(id, update);
         return Result.success();
     }
+
+    @PostMapping("/delete/{id}")
+    public Result delete(@PathVariable("id") Long id) {
+        teacherService.delete(id);
+        return Result.success();
+    }
+
+    @PostMapping("/batchDelete")
+    public Result batchDelete(@RequestBody BatchDealBaseDTO baseDTOs) {
+        teacherService.batchDelete(baseDTOs);
+        return Result.success();
+    }
 }

+ 5 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/StudentService.java

@@ -2,6 +2,7 @@ package com.usoftchina.smartschool.school.basic.service;
 
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.smartschool.page.PageRequest;
+import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
 import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.po.StudentForm;
@@ -15,4 +16,8 @@ public interface StudentService {
     DocBaseDTO saveFormData(StudentForm form);
 
     void saveToFormal(Integer id, boolean update);
+
+    void delete(Long id);
+
+    void batchDelete(BatchDealBaseDTO baseDTOs);
 }

+ 5 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/TeacherService.java

@@ -2,6 +2,7 @@ package com.usoftchina.smartschool.school.basic.service;
 
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.smartschool.page.PageRequest;
+import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
 import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.po.SysTeacher;
@@ -15,4 +16,8 @@ public interface TeacherService {
     DocBaseDTO saveFormData(SysTeacher teacher);
 
     void saveToFormal(Integer id, boolean update);
+
+    void delete(Long id);
+
+    void batchDelete(BatchDealBaseDTO baseDTOs);
 }

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

@@ -7,6 +7,7 @@ import com.usoftchina.smartschool.context.BaseContextHolder;
 import com.usoftchina.smartschool.exception.BizException;
 import com.usoftchina.smartschool.page.PageRequest;
 import com.usoftchina.smartschool.school.basic.service.StudentService;
+import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
 import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.exception.BizExceptionCode;
@@ -207,4 +208,25 @@ public class StudentServiceImpl implements StudentService{
             dataImportMapper.updateDataImport(id);
         }
     }
+
+    @Override
+    public void delete(Long id) {
+        if (null == id || "0".equals(id)) {
+            return;
+        }
+        sysStudentMapper.deleteByPrimaryKey(id);
+        sysStudentMapper.deleteRelation(id);
+    }
+
+    @Override
+    public void batchDelete(BatchDealBaseDTO baseDTOs) {
+        if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
+                baseDTOs.getBaseDTOs().size() == 0) {
+            return;
+        }
+
+        for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
+            delete(base.getId());
+        }
+    }
 }

+ 25 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/TeacherServiceImpl.java

@@ -7,6 +7,7 @@ import com.usoftchina.smartschool.context.BaseContextHolder;
 import com.usoftchina.smartschool.exception.BizException;
 import com.usoftchina.smartschool.page.PageRequest;
 import com.usoftchina.smartschool.school.basic.service.TeacherService;
+import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
 import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.exception.BizExceptionCode;
@@ -70,10 +71,11 @@ public class TeacherServiceImpl implements TeacherService{
             throw new BizException(BizExceptionCode.EMPTY_DATA);
         }
         Long school_id = BaseContextHolder.getSchoolId();
+        school_id = 1l;
         formdata.setSchool_id(school_id);
         formdata.setTeacher_status(1);
         //新增教师
-        if (StringUtils.isEmpty(formdata.getSchool_id()) || "0".equals(formdata.getSchool_id().toString())) {
+        if (StringUtils.isEmpty(formdata.getTeacher_id()) || "0".equals(formdata.getTeacher_id().toString())) {
             sysTeacherMapper.insertSelective(formdata);
 
         } else {
@@ -90,6 +92,7 @@ public class TeacherServiceImpl implements TeacherService{
             return;
         }
         Long schoolId = BaseContextHolder.getSchoolId();
+        schoolId = 1l;
         List<DataImportDetail> details = dataImportMapper.selectDataById(id);
         List<SysTeacher> teachers = new ArrayList<>();
         SysTeacher teacher =null;
@@ -126,4 +129,25 @@ public class TeacherServiceImpl implements TeacherService{
         }
     }
 
+    @Override
+    @Transactional
+    public void delete(Long id) {
+        if (null == id || "0".equals(id)) {
+            return;
+        }
+        sysTeacherMapper.deleteByPrimaryKey(id);
+        sysTeacherMapper.deleteRelation(id);
+    }
+
+    @Override
+    public void batchDelete(BatchDealBaseDTO baseDTOs) {
+        if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
+                baseDTOs.getBaseDTOs().size() == 0) {
+            return;
+        }
+
+        for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
+            delete(base.getId());
+        }
+    }
 }

+ 31 - 5
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/controller/HomeWorkController.java

@@ -1,13 +1,16 @@
 package com.usoftchina.smartschool.school.business.controller;
 
+import com.github.pagehelper.PageInfo;
 import com.usoftchina.smartschool.base.Result;
+import com.usoftchina.smartschool.page.PageDefault;
+import com.usoftchina.smartschool.page.PageRequest;
 import com.usoftchina.smartschool.school.business.service.HomeWorkService;
+import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
+import com.usoftchina.smartschool.school.dto.DocBaseDTO;
+import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.po.HomeWork;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-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.*;
 
 /**
  * @author: guq
@@ -22,8 +25,31 @@ public class HomeWorkController {
 
     @PostMapping("/save")
     public Result save(@RequestBody HomeWork data) {
-        homeWorkService.save(data);
+        DocBaseDTO docBaseDTO = homeWorkService.save(data);
+        return Result.success(docBaseDTO);
+    }
+
+    @GetMapping("/list")
+    public Result getList(@PageDefault PageRequest page, ListReqDTO listReqDTO) {
+        PageInfo<HomeWork> record = homeWorkService.getListData(page, listReqDTO);
+        return Result.success(record);
+    }
+
+    @GetMapping("/read/{id}")
+    public Result getFormdata(@PathVariable("id") Long id) {
+        HomeWork formdata = homeWorkService.getFormdata(id);
+        return Result.success(formdata);
+    }
+
+    @PostMapping("/delete/{id}")
+    public Result delete(@PathVariable("id") Long id) {
+        homeWorkService.delete(id);
         return Result.success();
     }
 
+    @PostMapping("/batchDelete")
+    public Result batchDelete(@RequestBody BatchDealBaseDTO baseDTOs) {
+        homeWorkService.batchDelete(baseDTOs);
+        return Result.success();
+    }
 }

+ 31 - 7
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/controller/NoticeController.java

@@ -1,15 +1,17 @@
 package com.usoftchina.smartschool.school.business.controller;
 
+import com.github.pagehelper.PageInfo;
 import com.usoftchina.smartschool.base.Result;
+import com.usoftchina.smartschool.page.PageDefault;
+import com.usoftchina.smartschool.page.PageRequest;
 import com.usoftchina.smartschool.school.business.service.NoticeService;
+import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
 import com.usoftchina.smartschool.school.dto.DocBaseDTO;
+import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.po.Notify;
-import com.usoftchina.smartschool.school.po.NotifyDO;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-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.*;
+
 
 /**
  * @author: guq
@@ -24,9 +26,31 @@ public class NoticeController {
 
     @PostMapping("/save")
     public Result save(@RequestBody Notify data) {
-        noticeService.save(data);
-        return Result.success();
+        DocBaseDTO baseDTO = noticeService.save(data);
+        return Result.success(baseDTO);
+    }
+
+    @GetMapping("/list")
+    public Result getList(@PageDefault PageRequest page, ListReqDTO listReqDTO) {
+        PageInfo<Notify> record = noticeService.getListData(page, listReqDTO);
+        return Result.success(record);
+    }
+
+    @GetMapping("/read/{id}")
+    public Result getFormdata(@PathVariable("id") Long id) {
+        Notify formdata = noticeService.getFormdata(id);
+        return Result.success(formdata);
     }
 
+    @PostMapping("/delete/{id}")
+    public Result delete(@PathVariable("id") Long id) {
+        noticeService.delete(id);
+        return Result.success();
+    }
 
+    @PostMapping("/batchDelete")
+    public Result batchDelete(@RequestBody BatchDealBaseDTO baseDTOs) {
+        noticeService.batchDelete(baseDTOs);
+        return Result.success();
+    }
 }

+ 15 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/HomeWorkService.java

@@ -1,7 +1,21 @@
 package com.usoftchina.smartschool.school.business.service;
 
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.smartschool.page.PageRequest;
+import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
+import com.usoftchina.smartschool.school.dto.DocBaseDTO;
+import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.po.HomeWork;
+import com.usoftchina.smartschool.school.po.Notify;
 
 public interface HomeWorkService {
-    void save(HomeWork data);
+    DocBaseDTO save(HomeWork data);
+
+    PageInfo<HomeWork> getListData(PageRequest page, ListReqDTO listReqDTO);
+
+    void delete(Long id);
+
+    void batchDelete(BatchDealBaseDTO baseDTOs);
+
+    HomeWork getFormdata(Long id);
 }

+ 14 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/NoticeService.java

@@ -1,8 +1,21 @@
 package com.usoftchina.smartschool.school.business.service;
 
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.smartschool.page.PageRequest;
+import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
+import com.usoftchina.smartschool.school.dto.DocBaseDTO;
+import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.po.Notify;
 
 public interface NoticeService {
 
-    void save(Notify data);
+    DocBaseDTO save(Notify data);
+
+    PageInfo<Notify> getListData(PageRequest page, ListReqDTO listReqDTO);
+
+    Notify getFormdata(Long id);
+
+    void delete(Long id);
+
+    void batchDelete(BatchDealBaseDTO baseDTOs);
 }

+ 66 - 4
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/HomeWorkServiceImpl.java

@@ -1,13 +1,23 @@
 package com.usoftchina.smartschool.school.business.service.impl;
 
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.smartschool.context.BaseContextHolder;
 import com.usoftchina.smartschool.exception.BizException;
+import com.usoftchina.smartschool.page.PageRequest;
 import com.usoftchina.smartschool.school.business.service.HomeWorkService;
+import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
+import com.usoftchina.smartschool.school.dto.DocBaseDTO;
+import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.exception.BizExceptionCode;
 import com.usoftchina.smartschool.school.mapper.HomeWorkMapper;
 import com.usoftchina.smartschool.school.po.HomeWork;
-import com.usoftchina.smartschool.school.wxschool.utils.StringUtils;
+import com.usoftchina.smartschool.school.po.Notify;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.util.List;
 
 /**
  * @author: guq
@@ -20,10 +30,62 @@ public class HomeWorkServiceImpl implements HomeWorkService{
     private HomeWorkMapper homeWorkMapper;
 
     @Override
-    public void save(HomeWork formdata) {
-        if (StringUtils.isArray(formdata)){
+    public DocBaseDTO save(HomeWork formdata) {
+        if (StringUtils.isEmpty(formdata)){
             throw new BizException(BizExceptionCode.EMPTY_DATA);
         }
-        homeWorkMapper.insertSelective(formdata);
+        //新增
+        if (StringUtils.isEmpty(formdata.getTask_id()) || "0".equals(formdata.getTask_id().toString())) {
+            homeWorkMapper.insertSelective(formdata);
+
+        } else {
+            //更新
+            homeWorkMapper.updateByPrimaryKeySelective(formdata);
+        }
+        return new DocBaseDTO(formdata.getTask_id());
+    }
+
+    @Override
+    public PageInfo<HomeWork> getListData(PageRequest page, ListReqDTO listReqDTO) {
+        PageHelper.startPage(page.getNumber(), page.getSize());
+        Long schoolId = BaseContextHolder.getSchoolId();
+        schoolId = 1l;
+        //condition语句
+        String condition = listReqDTO.getFinalCondition();
+        if(condition == null){
+            condition = "1=1";
+        }
+        List<HomeWork> data = homeWorkMapper.selectByConditon(condition, schoolId);
+        PageInfo<HomeWork> list = new PageInfo<>(data);
+        return list;
+    }
+
+    @Override
+    public void delete(Long id) {
+        if (StringUtils.isEmpty(id) || "0".equals(id)) {
+            return;
+        }
+        homeWorkMapper.deleteByPrimaryKey(id);
+    }
+
+    @Override
+    public void batchDelete(BatchDealBaseDTO baseDTOs) {
+        if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
+                baseDTOs.getBaseDTOs().size() == 0) {
+            return;
+        }
+
+        for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
+            delete(base.getId());
+        }
+    }
+
+    @Override
+    public HomeWork getFormdata(Long id) {
+        if (StringUtils.isEmpty(id) || "0".equals(id)) {
+            throw new BizException(BizExceptionCode.USELESS_DATA);
+        }
+        HomeWork data = homeWorkMapper.selectByPrimaryKey(id);
+        return data;
     }
 }

+ 65 - 4
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/NoticeServiceImpl.java

@@ -1,14 +1,23 @@
 package com.usoftchina.smartschool.school.business.service.impl;
 
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.smartschool.context.BaseContextHolder;
 import com.usoftchina.smartschool.exception.BizException;
+import com.usoftchina.smartschool.page.PageRequest;
 import com.usoftchina.smartschool.school.business.service.NoticeService;
+import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
+import com.usoftchina.smartschool.school.dto.DocBaseDTO;
+import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.exception.BizExceptionCode;
 import com.usoftchina.smartschool.school.mapper.NoticeMapper;
 import com.usoftchina.smartschool.school.po.Notify;
-import com.usoftchina.smartschool.school.wxschool.utils.StringUtils;
+import com.usoftchina.smartschool.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @author: guq
  * @create: 2019-02-15 09:54
@@ -20,10 +29,62 @@ public class NoticeServiceImpl implements NoticeService{
     private NoticeMapper noticeMapper;
 
     @Override
-    public void save(Notify formdata) {
-        if (StringUtils.isArray(formdata)){
+    public DocBaseDTO save(Notify formdata) {
+        if (StringUtils.isEmpty(formdata)){
             throw new BizException(BizExceptionCode.EMPTY_DATA);
         }
-        noticeMapper.insertSelective(formdata);
+        //新增
+        if (StringUtils.isEmpty(formdata.getNotify_id()) || "0".equals(formdata.getNotify_id().toString())) {
+            noticeMapper.insertSelective(formdata);
+
+        } else {
+            //更新
+            noticeMapper.updateByPrimaryKeySelective(formdata);
+        }
+        return new DocBaseDTO(formdata.getNotify_id());
+    }
+
+    @Override
+    public PageInfo<Notify> getListData(PageRequest page, ListReqDTO listReqDTO) {
+        PageHelper.startPage(page.getNumber(), page.getSize());
+        Long schoolId = BaseContextHolder.getSchoolId();
+        schoolId = 1l;
+        //condition语句
+        String condition = listReqDTO.getFinalCondition();
+        if(condition == null){
+            condition = "1=1";
+        }
+        List<Notify> data = noticeMapper.selectByConditon(condition, schoolId);
+        PageInfo<Notify> list = new PageInfo<>(data);
+        return list;
+    }
+
+    @Override
+    public Notify getFormdata(Long id) {
+        if (StringUtils.isEmpty(id) || "0".equals(id)) {
+            throw new BizException(BizExceptionCode.USELESS_DATA);
+        }
+        Notify data = noticeMapper.selectByPrimaryKey(id);
+        return data;
+    }
+
+    @Override
+    public void delete(Long id) {
+        if (StringUtils.isEmpty(id) || "0".equals(id)) {
+            return;
+        }
+        noticeMapper.deleteByPrimaryKey(id);
+    }
+
+    @Override
+    public void batchDelete(BatchDealBaseDTO baseDTOs) {
+        if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
+                baseDTOs.getBaseDTOs().size() == 0) {
+            return;
+        }
+
+        for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
+            delete(base.getId());
+        }
     }
 }

+ 1 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/exception/BizExceptionCode.java

@@ -8,7 +8,7 @@ import com.usoftchina.smartschool.exception.BaseExceptionCode;
  **/
 public enum BizExceptionCode implements BaseExceptionCode {
 
-    BIZ_IMPORT_ERROREXCEL(500002, "导入内容错误"),
+    BIZ_IMPORT_ERROREXCEL(500002, "请选用正确的导入模板"),
     EMPTY_DATA(76100,"数据为空,请填写后再保存"),
     USELESS_DATA(50001, "无效数据");
 

+ 6 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/HomeWorkMapper.java

@@ -2,6 +2,10 @@ package com.usoftchina.smartschool.school.mapper;
 
 import com.usoftchina.smartschool.school.po.HomeWork;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.web.bind.annotation.GetMapping;
+
+import java.util.List;
 
 @Mapper
 public interface HomeWorkMapper {
@@ -19,4 +23,6 @@ public interface HomeWorkMapper {
     int updateByPrimaryKeyWithBLOBs(HomeWork record);
 
     int updateByPrimaryKey(HomeWork record);
+
+    List<HomeWork> selectByConditon(@Param("con") String condition, @Param("school_id") Long schoolId);
 }

+ 5 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/NoticeMapper.java

@@ -2,6 +2,9 @@ package com.usoftchina.smartschool.school.mapper;
 
 import com.usoftchina.smartschool.school.po.Notify;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 @Mapper
 public interface NoticeMapper {
@@ -19,4 +22,6 @@ public interface NoticeMapper {
     int updateByPrimaryKeyWithBLOBs(Notify record);
 
     int updateByPrimaryKey(Notify record);
+
+    List<Notify> selectByConditon(@Param("con") String con, @Param("school_id") Long schoolId);
 }

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysStudentMapper.java

@@ -38,4 +38,6 @@ public interface SysStudentMapper {
     SysParents selectParentByPhone(@Param("phone") String phone, @Param("schoolId") Long schoolId );
 
     void insertrelationDetail(@Param("id") Long id, @Param("pr_id") Long pr_id, @Param("relation") String relation);
+
+    void deleteRelation(Long id);
 }

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysTeacherMapper.java

@@ -28,4 +28,6 @@ public interface SysTeacherMapper {
     List<TeacherDetail> selectDetail(Long id);
 
     SysTeacher selectByPhone(@Param("phone") String phone, @Param("school_id") Long school_id);
+
+    void deleteRelation(Long id);
 }

+ 16 - 0
applications/school/school-server/src/main/resources/mapper/HomeWorkMapper.xml

@@ -39,6 +39,9 @@
       )
   </insert>
   <insert id="insertSelective" parameterType="com.usoftchina.smartschool.school.po.HomeWork" >
+    <selectKey  resultType="java.lang.Long" keyProperty="task_id">
+      SELECT LAST_INSERT_ID() AS ID
+    </selectKey>
     insert into task_notify
     <trim prefix="(" suffix=")" suffixOverrides="," >
       <if test="subject_id != null" >
@@ -177,4 +180,17 @@
       school_id = #{school_id,jdbcType=BIGINT}
     where task_id = #{task_id,jdbcType=BIGINT}
   </update>
+
+  <select id="selectByConditon" resultMap="BaseResultMap">
+    select * from task_notify
+    <where>
+      <if test="con != null">
+        ${con}
+      </if>
+      <if test="school_id != null">
+        and school_id=#{school_id}
+      </if>
+    </where>
+    ORDER BY task_id DESC
+  </select>
 </mapper>

+ 16 - 0
applications/school/school-server/src/main/resources/mapper/NotifyMapper.xml

@@ -37,6 +37,9 @@
       )
   </insert>
   <insert id="insertSelective" parameterType="com.usoftchina.smartschool.school.po.Notify" >
+    <selectKey  resultType="java.lang.Long" keyProperty="notify_id">
+      SELECT LAST_INSERT_ID() AS ID
+    </selectKey>
     insert into notify
     <trim prefix="(" suffix=")" suffixOverrides="," >
       <if test="notify_title != null" >
@@ -174,4 +177,17 @@
       school_id = #{school_id,jdbcType=BIGINT}
     where notify_id = #{notify_id,jdbcType=BIGINT}
   </update>
+
+  <select id="selectByConditon" resultMap="BaseResultMap">
+    select * from notify
+    <where>
+      <if test="con != null">
+        ${con}
+      </if>
+      <if test="school_id != null">
+        and school_id=#{school_id}
+      </if>
+    </where>
+    ORDER BY notify_id DESC
+  </select>
 </mapper>

+ 4 - 0
applications/school/school-server/src/main/resources/mapper/SysStudentMapper.xml

@@ -349,4 +349,8 @@
   <insert id="insertrelationDetail">
      insert into sys_parents_stu (stu_id,parent_id,ps_relation) VALUES (#{id},#{pr_id},#{relation})
   </insert>
+
+  <delete id="deleteRelation" parameterType="long">
+    delete  from sys_parents_stu where stu_id = #{id}
+  </delete>
 </mapper>

+ 4 - 0
applications/school/school-server/src/main/resources/mapper/SysTeacherMapper.xml

@@ -316,4 +316,8 @@ where sys_teacher_clazz.teacher_id=#{id}
   <select id="selectByPhone" resultMap="BaseResultMap">
     select * from sys_teacher where teacher_phone=#{phone} and school_id=#{school_id}
   </select>
+
+  <delete id="deleteRelation">
+    delete from sys_teacher_clazz where teacher_id=#{teacher_id}
+  </delete>
 </mapper>