package com.ghsc.partybuild.service.impl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.ghsc.partybuild.mapper.LearningPlanCQuery; import com.ghsc.partybuild.mapper.ZzLearningplanMapper; import com.ghsc.partybuild.model.ZzLearningplan; import com.ghsc.partybuild.model.ZzLearningplanWithBLOBs; import com.ghsc.partybuild.service.LearningPlanService; import com.ghsc.partybuild.util.StringUtils; import com.ghsc.partybuild.vo.LearningPlanVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; import java.util.UUID; @Service("LearningPlanService") public class LearningPlanServiceImpl implements LearningPlanService { @Autowired public LearningPlanCQuery learningPlanCQuery; @Autowired public StringUtils stringUtils; @Autowired public ZzLearningplanMapper zzLearningplanMapper; @Override public PageInfo getList(int page, int rows, String planName, Date startDate, Date endDate, Integer recordStatus, Integer learningPlanType) { PageHelper.startPage(page, rows); List dataList = learningPlanCQuery.selectPlanList(null, planName, startDate, endDate, recordStatus, learningPlanType); return new PageInfo<>(dataList); } @Override public LearningPlanVo get(String planID) { if (stringUtils.IsNullOrEmpty(planID)) return null; return learningPlanCQuery.selectPlanList(planID, null, null, null, null, null).stream().findFirst().orElse(null); } @Override public Integer save(LearningPlanVo data, String userID, String userName) { Integer result = 0; LearningPlanVo dbData = !stringUtils.IsNullOrEmpty(data.getLearningPlanID()) ? get(data.getLearningPlanID()) : null; if (dbData == null) { if (stringUtils.IsNullOrEmpty(data.getLearningPlanID())) data.setLearningPlanID(UUID.randomUUID().toString()); data.setCreateTime(new Date()); data.setCreateUserId(userID); data.setCreateUserName(userName); result = zzLearningplanMapper.insert(data); } else { data.setUpdateTime(new Date()); data.setUpdateUserId(userID); data.setUpdateUserName(userName); result = zzLearningplanMapper.updateByPrimaryKeyWithBLOBs(data); } return result; } @Override public Integer delete(String planID) { return zzLearningplanMapper.deleteByPrimaryKey(planID); } @Override public Integer publicPlan(String planID) { ZzLearningplanWithBLOBs data = zzLearningplanMapper.selectByPrimaryKey(planID); data.setRecordStatus(2); return zzLearningplanMapper.updateByPrimaryKeyWithBLOBs(data); } }