LearningPlanServiceImpl.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package com.ghsc.partybuild.service.impl;
  2. import com.github.pagehelper.PageHelper;
  3. import com.github.pagehelper.PageInfo;
  4. import com.ghsc.partybuild.mapper.LearningPlanCQuery;
  5. import com.ghsc.partybuild.mapper.ZzLearningplanMapper;
  6. import com.ghsc.partybuild.model.ZzLearningplan;
  7. import com.ghsc.partybuild.model.ZzLearningplanWithBLOBs;
  8. import com.ghsc.partybuild.service.LearningPlanService;
  9. import com.ghsc.partybuild.util.StringUtils;
  10. import com.ghsc.partybuild.vo.LearningPlanVo;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Service;
  13. import java.util.Date;
  14. import java.util.List;
  15. import java.util.UUID;
  16. @Service("LearningPlanService")
  17. public class LearningPlanServiceImpl implements LearningPlanService {
  18. @Autowired
  19. public LearningPlanCQuery learningPlanCQuery;
  20. @Autowired
  21. public StringUtils stringUtils;
  22. @Autowired
  23. public ZzLearningplanMapper zzLearningplanMapper;
  24. @Override
  25. public PageInfo<LearningPlanVo> getList(int page, int rows, String planName, Date startDate, Date endDate, Integer recordStatus, Integer learningPlanType) {
  26. PageHelper.startPage(page, rows);
  27. List<LearningPlanVo> dataList = learningPlanCQuery.selectPlanList(null, planName, startDate, endDate, recordStatus, learningPlanType);
  28. return new PageInfo<>(dataList);
  29. }
  30. @Override
  31. public LearningPlanVo get(String planID) {
  32. if (stringUtils.IsNullOrEmpty(planID))
  33. return null;
  34. return learningPlanCQuery.selectPlanList(planID, null, null, null, null, null).stream().findFirst().orElse(null);
  35. }
  36. @Override
  37. public Integer save(LearningPlanVo data, String userID, String userName) {
  38. Integer result = 0;
  39. LearningPlanVo dbData = !stringUtils.IsNullOrEmpty(data.getLearningPlanID()) ? get(data.getLearningPlanID()) : null;
  40. if (dbData == null) {
  41. if (stringUtils.IsNullOrEmpty(data.getLearningPlanID()))
  42. data.setLearningPlanID(UUID.randomUUID().toString());
  43. data.setCreateTime(new Date());
  44. data.setCreateUserId(userID);
  45. data.setCreateUserName(userName);
  46. result = zzLearningplanMapper.insert(data);
  47. } else {
  48. data.setUpdateTime(new Date());
  49. data.setUpdateUserId(userID);
  50. data.setUpdateUserName(userName);
  51. result = zzLearningplanMapper.updateByPrimaryKeyWithBLOBs(data);
  52. }
  53. return result;
  54. }
  55. @Override
  56. public Integer delete(String planID) {
  57. return zzLearningplanMapper.deleteByPrimaryKey(planID);
  58. }
  59. @Override
  60. public Integer publicPlan(String planID) {
  61. ZzLearningplanWithBLOBs data = zzLearningplanMapper.selectByPrimaryKey(planID);
  62. data.setRecordStatus(2);
  63. return zzLearningplanMapper.updateByPrimaryKeyWithBLOBs(data);
  64. }
  65. }