Browse Source

课程表接口

chenw 6 years ago
parent
commit
cf755e976a

+ 133 - 0
applications/school/school-dto/src/main/java/com/usoftchina/smartschool/school/dto/CurriculumDTO.java

@@ -0,0 +1,133 @@
+package com.usoftchina.smartschool.school.dto;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Description 课程表主表DTO
+ * @Author chenwei
+ * @Date 2019/02/15
+ */
+public class CurriculumDTO implements Serializable {
+
+    /**
+     * id
+     */
+    private Long id;
+    /**
+     * 编号
+     */
+    private String code;
+    /**
+     * 学期名称
+     */
+    private String termName;
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * 学期开始日期
+     */
+    private Date termStart;
+    /**
+     * 学期结束日期
+     */
+    private Date termEnd;
+    /**
+     * 周 数
+     */
+    private Long weekNum;
+    /**
+     * 创建人名称
+     */
+    private Long creatorName;
+    /**
+     * 创建日期
+     */
+    private Date createTime;
+    /**
+     * 班级Id
+     */
+    private String clazzId;
+
+    public String getClazzId() {
+        return clazzId;
+    }
+
+    public void setClazzId(String clazzId) {
+        this.clazzId = clazzId;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getTermName() {
+        return termName;
+    }
+
+    public void setTermName(String termName) {
+        this.termName = termName;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Date getTermStart() {
+        return termStart;
+    }
+
+    public void setTermStart(Date termStart) {
+        this.termStart = termStart;
+    }
+
+    public Date getTermEnd() {
+        return termEnd;
+    }
+
+    public void setTermEnd(Date termEnd) {
+        this.termEnd = termEnd;
+    }
+
+    public Long getWeekNum() {
+        return weekNum;
+    }
+
+    public void setWeekNum(Long weekNum) {
+        this.weekNum = weekNum;
+    }
+
+    public Long getCreatorName() {
+        return creatorName;
+    }
+
+    public void setCreatorName(Long creatorName) {
+        this.creatorName = creatorName;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+}

+ 148 - 0
applications/school/school-dto/src/main/java/com/usoftchina/smartschool/school/dto/CurriculumDetailDTO.java

@@ -0,0 +1,148 @@
+package com.usoftchina.smartschool.school.dto;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Description 课程表明细DTO
+ * @Author chenwei
+ * @Date 2019/02/15
+ */
+public class CurriculumDetailDTO implements Serializable {
+
+    private Long id;
+    private int lessons;
+    private String mon;
+    private String tues;
+    private String wed;
+    private String thur;
+    private String fri;
+    private String sat;
+    private String startTime;
+    private String endTime;
+    private int status;
+    private String remarks;
+    private int clazzId;
+    private int schoolId;
+    private Long mId;
+
+    public Long getmId() {
+        return mId;
+    }
+
+    public void setmId(Long mId) {
+        this.mId = mId;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public int getLessons() {
+        return lessons;
+    }
+
+    public void setLessons(int lessons) {
+        this.lessons = lessons;
+    }
+
+    public String getMon() {
+        return mon;
+    }
+
+    public void setMon(String mon) {
+        this.mon = mon;
+    }
+
+    public String getTues() {
+        return tues;
+    }
+
+    public void setTues(String tues) {
+        this.tues = tues;
+    }
+
+    public String getWed() {
+        return wed;
+    }
+
+    public void setWed(String wed) {
+        this.wed = wed;
+    }
+
+    public String getThur() {
+        return thur;
+    }
+
+    public void setThur(String thur) {
+        this.thur = thur;
+    }
+
+    public String getFri() {
+        return fri;
+    }
+
+    public void setFri(String fri) {
+        this.fri = fri;
+    }
+
+    public String getSat() {
+        return sat;
+    }
+
+    public void setSat(String sat) {
+        this.sat = sat;
+    }
+
+    public String getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(String startTime) {
+        this.startTime = startTime;
+    }
+
+    public String getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(String endTime) {
+        this.endTime = endTime;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
+
+    public String getRemarks() {
+        return remarks;
+    }
+
+    public void setRemarks(String remarks) {
+        this.remarks = remarks;
+    }
+
+    public int getClazzId() {
+        return clazzId;
+    }
+
+    public void setClazzId(int clazzId) {
+        this.clazzId = clazzId;
+    }
+
+    public int getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(int schoolId) {
+        this.schoolId = schoolId;
+    }
+}

+ 31 - 0
applications/school/school-dto/src/main/java/com/usoftchina/smartschool/school/dto/CurriculumFormDTO.java

@@ -0,0 +1,31 @@
+package com.usoftchina.smartschool.school.dto;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @Description 课程表主从表数据
+ * @Author chenwei
+ * @Date 2019/02/15
+ */
+public class CurriculumFormDTO implements Serializable {
+
+    private CurriculumDTO main;
+    private List<CurriculumDetailDTO> items;
+
+    public CurriculumDTO getMain() {
+        return main;
+    }
+
+    public void setMain(CurriculumDTO main) {
+        this.main = main;
+    }
+
+    public List<CurriculumDetailDTO> getItems() {
+        return items;
+    }
+
+    public void setItems(List<CurriculumDetailDTO> items) {
+        this.items = items;
+    }
+}

+ 96 - 0
applications/school/school-dto/src/main/java/com/usoftchina/smartschool/school/dto/CurriculumListDTO.java

@@ -0,0 +1,96 @@
+package com.usoftchina.smartschool.school.dto;
+
+import java.io.Serializable;
+
+/**
+ * @Description 课程表列表DTO
+ * @Author chenwei
+ * @Date 2019/02/15
+ */
+public class CurriculumListDTO implements Serializable {
+
+    /**
+     * 学校名称
+     */
+    private String schoolName;
+    /**
+     * 学校ID
+     */
+    private String schoolId;
+    /**
+     * 年级
+     */
+    private String gradeName;
+    /**
+     * 年级ID
+     */
+    private String gradeId;
+    /**
+     * 班级
+     */
+    private String clazzName;
+    /**
+     * 班级ID
+     */
+    private String clazzId;
+    /**
+     * 使用状态, 1:使用   2:草稿
+     */
+    private String status;
+
+    public String getSchoolName() {
+        return schoolName;
+    }
+
+    public void setSchoolName(String schoolName) {
+        this.schoolName = schoolName;
+    }
+
+    public String getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(String schoolId) {
+        this.schoolId = schoolId;
+    }
+
+    public String getGradeName() {
+        return gradeName;
+    }
+
+    public void setGradeName(String gradeName) {
+        this.gradeName = gradeName;
+    }
+
+    public String getGradeId() {
+        return gradeId;
+    }
+
+    public void setGradeId(String gradeId) {
+        this.gradeId = gradeId;
+    }
+
+    public String getClazzName() {
+        return clazzName;
+    }
+
+    public void setClazzName(String clazzName) {
+        this.clazzName = clazzName;
+    }
+
+    public String getClazzId() {
+        return clazzId;
+    }
+
+    public void setClazzId(String clazzId) {
+        this.clazzId = clazzId;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+}

+ 54 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/controller/CurriculumController.java

@@ -0,0 +1,54 @@
+package com.usoftchina.smartschool.school.basic.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.basic.service.CurriculumService;
+import com.usoftchina.smartschool.school.dto.CurriculumFormDTO;
+import com.usoftchina.smartschool.school.dto.CurriculumListDTO;
+import com.usoftchina.smartschool.school.dto.ListReqDTO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @Description 课程表
+ * @Author chenwei
+ * @Date 2019/02/15
+ */
+@RestController
+@RequestMapping("/curriculum")
+public class CurriculumController {
+
+    @Autowired
+    private CurriculumService curriculumService;
+
+    @GetMapping("/list")
+    public Result list(@PageDefault PageRequest page, ListReqDTO listReqDTO){
+        PageInfo<CurriculumListDTO> pageInfo = curriculumService.selectAll(page, listReqDTO);
+        return Result.success(pageInfo);
+    }
+
+    @GetMapping("/read")
+    public Result read(Long school_id, Long clazz_id, Long grade_id){
+        return Result.success(curriculumService.read(school_id, clazz_id, grade_id));
+    }
+
+    @PostMapping("/save")
+    public Result save(CurriculumFormDTO curriculumFormDTO){
+        return Result.success(curriculumService.save(curriculumFormDTO));
+    }
+
+    @PostMapping("/delete")
+    public Result delete(Long school_id, Long clazz_id, Long grade_id){
+        curriculumService.delete(school_id, clazz_id, grade_id);
+        return Result.success();
+    }
+
+    @PostMapping("/deleteDetail/{id}")
+    public Result deleteDetail(@PathVariable("id") Long id){
+        curriculumService.deleteDetail(id);
+        return Result.success();
+    }
+
+}

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

@@ -0,0 +1,52 @@
+package com.usoftchina.smartschool.school.basic.service;
+
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.smartschool.page.PageRequest;
+import com.usoftchina.smartschool.school.dto.CurriculumFormDTO;
+import com.usoftchina.smartschool.school.dto.CurriculumListDTO;
+import com.usoftchina.smartschool.school.dto.DocBaseDTO;
+import com.usoftchina.smartschool.school.dto.ListReqDTO;
+
+/**
+ * @Author chenwei
+ * @Date 2019/02/15
+ */
+public interface CurriculumService {
+    /**
+     * 查询课表信息(列表)
+     * @param page
+     * @param listReqDTO
+     * @return
+     */
+    PageInfo<CurriculumListDTO> selectAll(PageRequest page, ListReqDTO listReqDTO);
+
+    /**
+     * 学校->年级->班 课程表
+     * @param school_id
+     * @param clazz_id
+     * @param grade_id
+     * @return
+     */
+    CurriculumFormDTO read(Long school_id, Long clazz_id, Long grade_id);
+
+    /**
+     * 新增/更新 课表
+     * @param curriculumFormDTO
+     * @return
+     */
+    DocBaseDTO save(CurriculumFormDTO curriculumFormDTO);
+
+    /**
+     * 删除学校->年级->班 课表
+     * @param school_id
+     * @param clazz_id
+     * @param grade_id
+     */
+    void delete(Long school_id, Long clazz_id, Long grade_id);
+
+    /**
+     * 删除课表明细
+     * @param id
+     */
+    void deleteDetail(Long id);
+}

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

@@ -0,0 +1,176 @@
+package com.usoftchina.smartschool.school.basic.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.basic.service.CurriculumService;
+import com.usoftchina.smartschool.school.dto.*;
+import com.usoftchina.smartschool.school.exception.BizExceptionCode;
+import com.usoftchina.smartschool.school.mapper.CurriculumMapper;
+import com.usoftchina.smartschool.school.mapper.SysClazzMapper;
+import com.usoftchina.smartschool.school.po.SubjectDO;
+import com.usoftchina.smartschool.school.wxschool.utils.ObjectUtils;
+import com.usoftchina.smartschool.school.wxschool.utils.StringUtils;
+import com.usoftchina.smartschool.utils.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description 课程表
+ * @Author chenwei
+ * @Date 2019/02/15
+ */
+@Service
+public class CurriculumServiceImpl implements CurriculumService {
+
+    @Autowired
+    private CurriculumMapper curriculumMapper;
+
+
+    @Override
+    public PageInfo<CurriculumListDTO> selectAll(PageRequest page, ListReqDTO listReqDTO) {
+        PageHelper.startPage(page.getNumber(), page.getSize());
+        //condition语句
+        String condition = listReqDTO.getFinalCondition();
+        if(condition == null){
+            condition = "1=1";
+        }
+        Long schoolId = BaseContextHolder.getSchoolId();
+        List<CurriculumListDTO> curriculumListDTO = curriculumMapper.selectByCondition(condition, schoolId);
+        PageInfo<CurriculumListDTO> pageInfo = new PageInfo<CurriculumListDTO>(curriculumListDTO);
+        return pageInfo;
+    }
+
+    @Override
+    public CurriculumFormDTO read(Long school_id, Long clazz_id, Long grade_id) {
+        CurriculumFormDTO curriculumFormDTO = new CurriculumFormDTO();
+        curriculumFormDTO.setMain(curriculumMapper.selectMain(school_id, clazz_id, grade_id));
+        List<CurriculumDetailDTO> curriculumDetailDTOList = curriculumMapper.selectItems(school_id, clazz_id, grade_id);
+        List<SubjectDO> subjectDOList = curriculumMapper.selectSubject(school_id);
+        for (SubjectDO subjectDO : subjectDOList){
+            for (CurriculumDetailDTO curriculumDetailDTO : curriculumDetailDTOList){
+                convertToChinese(curriculumDetailDTO, subjectDO);
+            }
+        }
+        curriculumFormDTO.setItems(curriculumDetailDTOList);
+        return curriculumFormDTO;
+    }
+
+    /**
+     * 课程表ID转中文
+     * @param curriculumDetailDTO
+     * @param subjectDO
+     */
+    private void convertToChinese(CurriculumDetailDTO curriculumDetailDTO, SubjectDO subjectDO) {
+        if (curriculumDetailDTO.getMon().equals(subjectDO.getSubjectId().toString())){
+            curriculumDetailDTO.setMon(subjectDO.getSubjectName());
+        }
+        if (curriculumDetailDTO.getTues().equals(subjectDO.getSubjectId().toString())){
+            curriculumDetailDTO.setTues(subjectDO.getSubjectName());
+        }
+        if (curriculumDetailDTO.getThur().equals(subjectDO.getSubjectId().toString())){
+            curriculumDetailDTO.setThur(subjectDO.getSubjectName());
+        }
+        if (curriculumDetailDTO.getWed().equals(subjectDO.getSubjectId().toString())){
+            curriculumDetailDTO.setWed(subjectDO.getSubjectName());
+        }
+        if (curriculumDetailDTO.getFri().equals(subjectDO.getSubjectId().toString())){
+            curriculumDetailDTO.setFri(subjectDO.getSubjectName());
+        }
+        if (curriculumDetailDTO.getSat().equals(subjectDO.getSubjectId().toString())){
+            curriculumDetailDTO.setSat(subjectDO.getSubjectName());
+        }
+    }
+
+    /**
+     * 课程表中文转ID
+     * @param curriculumDetailDTO
+     * @param subjectDO
+     */
+    private void convertToId(CurriculumDetailDTO curriculumDetailDTO, SubjectDO subjectDO) {
+        if (curriculumDetailDTO.getMon().equals(subjectDO.getSubjectName())){
+            curriculumDetailDTO.setMon(subjectDO.getSubjectId().toString());
+        }
+        if (curriculumDetailDTO.getTues().equals(subjectDO.getSubjectName())){
+            curriculumDetailDTO.setTues(subjectDO.getSubjectId().toString());
+        }
+        if (curriculumDetailDTO.getThur().equals(subjectDO.getSubjectName())){
+            curriculumDetailDTO.setThur(subjectDO.getSubjectId().toString());
+        }
+        if (curriculumDetailDTO.getWed().equals(subjectDO.getSubjectName())){
+            curriculumDetailDTO.setWed(subjectDO.getSubjectId().toString());
+        }
+        if (curriculumDetailDTO.getFri().equals(subjectDO.getSubjectName())){
+            curriculumDetailDTO.setFri(subjectDO.getSubjectId().toString());
+        }
+        if (curriculumDetailDTO.getSat().equals(subjectDO.getSubjectName())){
+            curriculumDetailDTO.setSat(subjectDO.getSubjectId().toString());
+        }
+    }
+
+    @Override
+    public DocBaseDTO save(CurriculumFormDTO curriculumFormDTO) {
+        if (ObjectUtils.isEmpty(curriculumFormDTO)) {
+            throw new BizException(BizExceptionCode.EMPTY_DATA);
+        }
+        CurriculumDTO main = curriculumFormDTO.getMain();
+        List<CurriculumDetailDTO> items = curriculumFormDTO.getItems();
+        //查询课表科目信息
+        List<SubjectDO> subjectDOList = curriculumMapper.selectSubject(BaseContextHolder.getSchoolId());
+        if (null != main.getId() && 0 != main.getId()){
+            //保存主表
+            curriculumMapper.insertSelective(main);
+            Long mId = main.getId();
+            //保存明细表
+            if (!CollectionUtils.isEmpty(items)) {
+                //修改明细数据为科目对应的ID
+                for (SubjectDO subjectDO : subjectDOList) {
+                    for (CurriculumDetailDTO curriculumDetailDTO : items) {
+                        curriculumDetailDTO.setmId(mId);
+                        convertToId(curriculumDetailDTO, subjectDO);
+                    }
+                }
+                curriculumMapper.insertDetailSelective(items);
+            }
+        }else {
+            //更新主表
+            curriculumMapper.updateByPrimaryKeySelective(main);
+            if (!CollectionUtils.isEmpty(items)) {
+                List<CurriculumDetailDTO> insertList = new ArrayList<CurriculumDetailDTO>();
+                List<CurriculumDetailDTO> updateList = new ArrayList<CurriculumDetailDTO>();
+                for (CurriculumDetailDTO curriculumDetailDTO : items){
+                    for (SubjectDO subjectDO : subjectDOList) {
+                        convertToId(curriculumDetailDTO, subjectDO);
+                        if (curriculumDetailDTO.getId() != null && 0 != curriculumDetailDTO.getId()) {
+                            updateList.add(curriculumDetailDTO);
+                        } else {
+                            insertList.add(curriculumDetailDTO);
+                        }
+                    }
+                }
+                if (insertList.size() > 0) {
+                    curriculumMapper.insertDetailSelective(insertList);
+                }
+                if (updateList.size() > 0) {
+                    curriculumMapper.updateDetailSelective(updateList);
+                }
+            }
+        }
+        return new DocBaseDTO(main.getId(), null, null);
+    }
+
+    @Override
+    public void delete(Long school_id, Long clazz_id, Long grade_id) {
+        curriculumMapper.delete(school_id, clazz_id);
+    }
+
+    @Override
+    public void deleteDetail(Long id) {
+        curriculumMapper.deleteDetail(id);
+    }
+}

+ 84 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/CurriculumMapper.java

@@ -0,0 +1,84 @@
+package com.usoftchina.smartschool.school.mapper;
+
+import com.usoftchina.smartschool.school.dto.CurriculumDTO;
+import com.usoftchina.smartschool.school.dto.CurriculumDetailDTO;
+import com.usoftchina.smartschool.school.dto.CurriculumListDTO;
+import com.usoftchina.smartschool.school.po.SubjectDO;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface CurriculumMapper {
+
+    /**
+     * 按条件查找列表数据
+     * @param condition
+     * @param schoolId
+     * @return
+     */
+    List<CurriculumListDTO> selectByCondition(@Param("condition") String condition, @Param("schoolId") Long schoolId);
+
+    /**
+     * 查询课程表主表数据
+     * @param school_id
+     * @param clazz_id
+     * @param grade_id
+     * @return
+     */
+    CurriculumDTO selectMain(@Param("school_id") Long school_id, @Param("clazz_id") Long clazz_id, @Param("grade_id") Long grade_id);
+
+    /**
+     * 查询课程表明细表数据
+     * @param school_id
+     * @param clazz_id
+     * @param grade_id
+     * @return
+     */
+    List<CurriculumDetailDTO> selectItems(@Param("school_id") Long school_id, @Param("clazz_id") Long clazz_id, @Param("grade_id") Long grade_id);
+
+    /**
+     * 查询学校科目名称
+     * @param school_id
+     * @return
+     */
+    List<SubjectDO> selectSubject(@Param("school_id") Long school_id);
+
+    /**
+     * 删除班级课程表
+     * @param school_id
+     * @param clazz_id
+     */
+    void delete(@Param("school_id") Long school_id, @Param("clazz_id") Long clazz_id);
+
+    /**
+     * 删除课程表明细行
+     * @param id
+     */
+    void deleteDetail(@Param("id") Long id);
+
+    /**
+     * 课程表主表信息保存
+     * @param curriculumDTO
+     */
+    void insertSelective(CurriculumDTO curriculumDTO);
+
+    /**
+     * 课程明细表保存
+     * @param curriculumDetailDTOList
+     */
+    void insertDetailSelective(List<CurriculumDetailDTO> curriculumDetailDTOList);
+
+    /**
+     * 更新课程表主表信息
+     * @param curriculumDTO
+     */
+    void updateByPrimaryKeySelective(CurriculumDTO curriculumDTO);
+
+    /**
+     * 课程明细表更新
+     * @param curriculumDetailDTOList
+     */
+    void updateDetailSelective(List<CurriculumDetailDTO> curriculumDetailDTOList);
+}

+ 232 - 0
applications/school/school-server/src/main/resources/mapper/CurriculumMapper.xml

@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.usoftchina.smartschool.school.mapper.CurriculumMapper" >
+  <resultMap id="CurriculumDetailDTOMap" type="com.usoftchina.smartschool.school.dto.CurriculumDetailDTO">
+    <id column="cur_id" property="id" jdbcType="INTEGER" />
+    <result column="cur_lessons" property="lessons" jdbcType="INTEGER" />
+    <result column="cur_mon" property="mon" jdbcType="VARCHAR" />
+    <result column="cur_tues" property="tues" jdbcType="VARCHAR" />
+    <result column="cur_wed" property="wed" jdbcType="VARCHAR" />
+    <result column="cur_thur" property="thur" jdbcType="VARCHAR" />
+    <result column="cur_fri" property="fri" jdbcType="VARCHAR" />
+    <result column="cur_sat" property="sat" jdbcType="VARCHAR" />
+    <result column="cur_status" property="status" jdbcType="INTEGER" />
+    <result column="cur_remarks" property="remarks" jdbcType="VARCHAR" />
+    <result column="cur_start_time" property="startTime" jdbcType="TIME" />
+    <result column="cur_end_time" property="endTime" jdbcType="TIME" />
+    <result column="clazz_id" property="clazzId" jdbcType="INTEGER" />
+    <result column="school_id" property="schoolId" jdbcType="INTEGER" />
+    <result column="cur_mid" property="mId" jdbcType="INTEGER" />
+  </resultMap>
+
+  <resultMap id="CurriculumDTOMap" type="com.usoftchina.smartschool.school.dto.CurriculumDTO">
+    <id column="id" property="id" jdbcType="INTEGER" />
+    <result column="mcur_code" property="code" jdbcType="VARCHAR" />
+    <result column="mcur_term_name" property="termName" jdbcType="VARCHAR" />
+    <result column="mcur_name" property="name" jdbcType="VARCHAR" />
+    <result column="mcur_term_start" property="termStart" jdbcType="TIMESTAMP" />
+    <result column="mcur_term_end" property="termEnd" jdbcType="TIMESTAMP" />
+    <result column="mcur_weeknum" property="weekNum" jdbcType="INTEGER" />
+    <result column="creatorName" property="creatorName" jdbcType="VARCHAR" />
+    <result column="createTime" property="createTime" jdbcType="TIMESTAMP" />
+    <!--<result column="school_id" property="" jdbcType="VARCHAR" />
+    <result column="clazz_id" property="" jdbcType="VARCHAR" />-->
+  </resultMap>
+
+  <select id="selectByCondition" resultType="com.usoftchina.smartschool.school.dto.CurriculumListDTO">
+    select school.school_name schoolName, grade.grade_name gradeName, clazz.clazz_name clazzName, cur_status status, cur.school_id schoolId, cur.clazz_id clazzId, clazz.grade_id gradeId
+    from clazz_curriculum cur
+    left join sys_clazz clazz on cur.clazz_id = clazz.clazz_id
+    left join sys_grade grade on clazz.grade_id = grade.grade_id
+    left join sys_school school on school.school_id = cur.school_id
+    <where>
+      <if test="condition != null">
+        ${condition}
+      </if>
+      <if test="schoolId != null">
+        and cur.school_id = #{schoolId}
+      </if>
+    </where>
+  </select>
+
+  <select id="selectMain" resultMap="CurriculumDTOMap">
+    select * from clazz_main_curriculum where clazz_id = #{clazz_id} and school_id = #{school_id}
+  </select>
+
+  <select id="selectItems" resultMap="CurriculumDetailDTOMap">
+    select * from clazz_curriculum where clazz_id = #{clazz_id} and school_id = #{school_id}
+  </select>
+
+  <select id="selectSubject" resultType="com.usoftchina.smartschool.school.po.SubjectDO">
+    select * from subject where school_id = #{school_id}
+  </select>
+
+  <delete id="delete">
+    delete from clazz_curriculum where class_id = #{clazz_id} and school_id = #{school_id}
+  </delete>
+
+  <delete id="deleteDetail">
+    DELETE FROM clazz_curriculum where cur_id = #{id}
+  </delete>
+
+  <insert id="insertSelective" parameterType="com.usoftchina.smartschool.school.dto.CurriculumDTO">
+    <selectKey  resultType="java.lang.Long" keyProperty="id">
+      SELECT LAST_INSERT_ID() AS ID
+    </selectKey>
+    INSERT INTO clazz_main_curriculum
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="code != null">
+        mcur_code,
+      </if>
+      <if test="termName != null">
+        mcur_term_name,
+      </if>
+      <if test="name != null">
+        mcur_name,
+      </if>
+      <if test="termStart != null">
+        mcur_term_start,
+      </if>
+      <if test="termEnd != null">
+        mcur_term_end,
+      </if>
+      <if test="weekNum != null">
+        mcur_weeknum,
+      </if>
+      <if test="creatorName != null">
+        creatorName,
+      </if>
+      <if test="createTime != null">
+        createTime,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="code != null">
+        #{code, jdbcType=VARCHAR},
+      </if>
+      <if test="termName != null">
+        #{termName, jdbcType=VARCHAR},
+      </if>
+      <if test="name != null">
+        #{name, jdbcType=VARCHAR},
+      </if>
+      <if test="termStart != null">
+        #{termStart, jdbcType=TIMESTAMP},
+      </if>
+      <if test="termEnd != null">
+        #{termEnd, jdbcType=TIMESTAMP},
+      </if>
+      <if test="weekNum != null">
+        #{weekNum, jdbcType=INTEGER},
+      </if>
+      <if test="creatorName != null">
+        #{creatorName, jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        #{createTime, jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+
+  <insert id="insertDetailSelective" parameterType="java.util.List">
+    insert into clazz_curriculum
+    (cur_lessons,cur_mon,cur_tues,cur_wed,
+    cur_thur,cur_fri,cur_sat,cur_start_time,cur_end_time,
+    cur_status,cur_remarks,clazz_id,school_id,cur_mid
+    ) values
+    <foreach collection="list" item="item" index="index" open="" close="" separator=",">
+      (
+        #{lessons, jdbcType=INTEGER},#{mon,jdbcType=INTEGER},#{tues,jdbcType=INTEGER},#{wed,jdbcType=INTEGER},
+        #{thur,jdbcType=INTEGER},#{fri,jdbcType=INTEGER},#{sat,jdbcType=INTEGER},#{startTime,jdbcType=TIME},
+        #{endTime,jdbcType=TIME},#{status,jdbcType=INTEGER},#{remarks,jdbcType=VARCHAR},#{clazzId,jdbcType=INTEGER},
+        #{schoolId,jdbcType=INTEGER},#{mId,jdbcType=INTEGER},
+      )
+    </foreach>
+  </insert>
+
+  <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.smartschool.school.dto.CurriculumDTO" >
+    update clazz_main_curriculum
+    <set >
+      <if test="mcur_code != null" >
+        mcur_code = #{code,jdbcType=VARCHAR},
+      </if>
+      <if test="mcur_term_name != null" >
+        mcur_term_name = #{termName,jdbcType=VARCHAR},
+      </if>
+      <if test="mcur_name != null" >
+        mcur_name = #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="mcur_term_start != null" >
+        mcur_term_start = #{termStart,jdbcType=TIMESTAMP},
+      </if>
+      <if test="mcur_term_end != null" >
+        mcur_term_end = #{termEnd,jdbcType=TIMESTAMP},
+      </if>
+      <if test="mcur_weeknum != null" >
+        mcur_weeknum = #{weekNum,jdbcType=INTEGER},
+      </if>
+      <if test="creatorName != null" >
+        creatorName = #{creatorName,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null" >
+        createTime = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="clazzId != null" >
+        clazz_id = #{clazzId,jdbcType=INTEGER},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+
+  <update id="updateDetailSelective" parameterType="com.usoftchina.smartschool.school.dto.CurriculumDetailDTO">
+    <foreach collection="list" item="item" index="index" separator=";">
+      update clazz_curriculum
+      <set>
+        <if test="item.lessons != null and lessons != 0">
+          cur_lessons = #{item.lession, jdbcType=INTEGER},
+        </if>
+        <if test="item.mon != null">
+          cur_mon = #{item.mon, jdbcType=VARCHAR},
+        </if>
+        <if test="item.tues != null">
+          cur_tues = #{item.tues, jdbcType=VARCHAR},
+        </if>
+        <if test="item.wed != null">
+          cur_wed = #{item.wed, jdbcType=VARCHAR},
+        </if>
+        <if test="item.thur != null">
+          cur_thur = #{item.thur, jdbcType=VARCHAR},
+        </if>
+        <if test="item.fri != null">
+          cur_fri = #{item.fri, jdbcType=VARCHAR},
+        </if>
+        <if test="item.sat != null">
+          cur_sat = #{item.sat, jdbcType=VARCHAR},
+        </if>
+        <if test="item.startTime != null">
+          cur_start_time = #{item.startTime, jdbcType=VARCHAR},
+        </if>
+        <if test="item.endTime != null">
+          cur_end_time = #{item.endTime, jdbcType=TIME},
+        </if>
+        <if test="item.status != null">
+          cur_status = #{item.status, jdbcType=TIME},
+        </if>
+        <if test="item.remarks != null">
+          cur_remarks = #{item.remarks, jdbcType=VARCHAR},
+        </if>
+        <if test="item.clazzId != null">
+          clazz_id = #{item.clazzId, jdbcType=INTEGER},
+        </if>
+        <if test="item.schoolId != null">
+          school_id = #{item.schoolId, jdbcType=INTEGER},
+        </if>
+        <if test="item.mId != null">
+          cur_mid = #{item.mId, jdbcType=INTEGER},
+        </if>
+      </set>
+      WHERE cur_id= #{item.id,jdbcType=INTEGER}
+    </foreach>
+  </update>
+
+</mapper>

+ 71 - 0
applications/school/school-server/src/test/java/com/usoftchina/smartschool/school/service/CurriculumServiceTest.java

@@ -0,0 +1,71 @@
+package com.usoftchina.smartschool.school.service;
+
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.smartschool.context.BaseContextHolder;
+import com.usoftchina.smartschool.page.PageRequest;
+import com.usoftchina.smartschool.school.basic.service.CurriculumService;
+import com.usoftchina.smartschool.school.dto.CurriculumFormDTO;
+import com.usoftchina.smartschool.school.dto.CurriculumListDTO;
+import com.usoftchina.smartschool.school.dto.ListReqDTO;
+import com.usoftchina.smartschool.utils.JsonUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @Description
+ * @Author chenwei
+ * @Date 2019/02/19
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest
+@EnableAutoConfiguration
+public class CurriculumServiceTest {
+
+    @Autowired
+    private CurriculumService curriculumService;
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(CurriculumServiceTest.class);
+
+    @Test
+    public void testA_selectAll(){
+        LOGGER.info("===============test selectAll start==============");
+        PageRequest pageRequest = new PageRequest(1, 8);
+        BaseContextHolder.setSchoolId(1);
+        PageInfo<CurriculumListDTO> pageInfo = curriculumService.selectAll(pageRequest, new ListReqDTO());
+        LOGGER.info("pageInfo={}", JsonUtils.toJsonString(pageInfo));
+        LOGGER.info("===============test selectAll end================");
+
+    }
+
+    @Test
+    public void testB_read(){
+        LOGGER.info("===============test read start==============");
+        CurriculumFormDTO curriculumFormDTO = curriculumService.read(1L,1L,1L);
+        LOGGER.info("curriculumFormDTO={}", JsonUtils.toJsonString(curriculumFormDTO));
+        LOGGER.info("===============test read end================");
+    }
+
+    @Test
+    public void testC_save(){
+        LOGGER.info("===============test save start==============");
+        LOGGER.info("===============test save end================");
+    }
+
+    @Test
+    public void testE_delete(){
+        LOGGER.info("===============test delete start==============");
+        LOGGER.info("===============test delete end================");
+    }
+
+    @Test
+    public void testF_deleteDetail(){
+        LOGGER.info("===============test deleteDetail start==============");
+        LOGGER.info("===============test deleteDetail end================");
+    }
+}

+ 32 - 1
framework/test-starter/pom.xml

@@ -10,6 +10,37 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>test-starter</artifactId>
-
+    <dependencies>
+        <dependency>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-starter-test</artifactId>
+        </dependency>
+        <dependency>
+          <groupId>com.usoftchina.smartschool</groupId>
+          <artifactId>core</artifactId>
+        </dependency>
+        <dependency>
+          <groupId>org.springframework</groupId>
+          <artifactId>spring-web</artifactId>
+          <scope>compile</scope>
+          <optional>true</optional>
+        </dependency>
+        <dependency>
+          <groupId>javax.servlet</groupId>
+          <artifactId>javax.servlet-api</artifactId>
+          <scope>compile</scope>
+          <optional>true</optional>
+        </dependency>
+        <dependency>
+          <groupId>com.fasterxml.jackson.core</groupId>
+          <artifactId>jackson-core</artifactId>
+          <scope>provided</scope>
+        </dependency>
+        <dependency>
+          <groupId>com.fasterxml.jackson.core</groupId>
+          <artifactId>jackson-databind</artifactId>
+          <scope>provided</scope>
+        </dependency>
+    </dependencies>
 
 </project>