|
|
@@ -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;
|
|
|
}
|
|
|
}
|