StudentMindOldServiceImpl.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package com.ruoyi.system.service.impl;
  2. import java.util.List;
  3. import com.ruoyi.common.core.domain.entity.SysUser;
  4. import com.ruoyi.common.exception.ServiceException;
  5. import com.ruoyi.common.utils.ClassUtils;
  6. import com.ruoyi.common.utils.DateUtils;
  7. import com.ruoyi.common.utils.SecurityUtils;
  8. import com.ruoyi.system.domain.StudentInfo;
  9. import com.ruoyi.system.mapper.StudentInfoMapper;
  10. import lombok.SneakyThrows;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Service;
  13. import com.ruoyi.system.mapper.StudentMindOldMapper;
  14. import com.ruoyi.system.domain.StudentMindOld;
  15. import com.ruoyi.system.service.IStudentMindOldService;
  16. /**
  17. * 学生心理健康历史信息Service业务层处理
  18. *
  19. * @author ruoyi
  20. * @date 2023-08-03
  21. */
  22. @Service
  23. public class StudentMindOldServiceImpl implements IStudentMindOldService
  24. {
  25. @Autowired
  26. private StudentMindOldMapper studentMindOldMapper;
  27. @Autowired
  28. private StudentInfoMapper studentInfoMapper;
  29. /**
  30. * 查询学生心理健康历史信息
  31. *
  32. * @param mindId 学生心理健康历史信息主键
  33. * @return 学生心理健康历史信息
  34. */
  35. @Override
  36. public StudentMindOld selectStudentMindOldByMindId(Long mindId)
  37. {
  38. return studentMindOldMapper.selectStudentMindOldByMindId(mindId);
  39. }
  40. /**
  41. * 查询学生心理健康历史信息列表
  42. *
  43. * @param studentMindOld 学生心理健康历史信息
  44. * @return 学生心理健康历史信息
  45. */
  46. @Override
  47. public List<StudentMindOld> selectStudentMindOldList(StudentMindOld studentMindOld)
  48. {
  49. return studentMindOldMapper.selectStudentMindOldList(studentMindOld);
  50. }
  51. /**
  52. * 新增学生心理健康历史信息
  53. *
  54. * @param studentMindOld 学生心理健康历史信息
  55. * @return 结果
  56. */
  57. @SneakyThrows
  58. @Override
  59. public int insertStudentMindOld(StudentMindOld studentMindOld)
  60. {
  61. SysUser user = SecurityUtils.getLoginUser().getUser();
  62. StudentInfo student = studentInfoMapper.selectStudentInfoByStudentId(studentMindOld.getStudentId());
  63. if(student==null){
  64. throw new ServiceException("请先填写学生档案信息");
  65. }
  66. student.setMind(studentMindOld.getMind());
  67. student.setPsychologicalDescription(studentMindOld.getPsychologicalDescription());
  68. student.setUpdateTime(DateUtils.getNowDate());
  69. studentInfoMapper.updateStudentInfo(student);
  70. ClassUtils.copyProperties(student, studentMindOld);
  71. studentMindOld.setCreateTime(DateUtils.getNowDate());
  72. studentMindOld.setUpdateTime(DateUtils.getNowDate());
  73. studentMindOld.setCreateBy(user.getUserName());
  74. return studentMindOldMapper.insertStudentMindOld(studentMindOld);
  75. }
  76. /**
  77. * 修改学生心理健康历史信息
  78. *
  79. * @param studentMindOld 学生心理健康历史信息
  80. * @return 结果
  81. */
  82. @Override
  83. public int updateStudentMindOld(StudentMindOld studentMindOld)
  84. {
  85. studentMindOld.setUpdateTime(DateUtils.getNowDate());
  86. return studentMindOldMapper.updateStudentMindOld(studentMindOld);
  87. }
  88. /**
  89. * 批量删除学生心理健康历史信息
  90. *
  91. * @param mindIds 需要删除的学生心理健康历史信息主键
  92. * @return 结果
  93. */
  94. @Override
  95. public int deleteStudentMindOldByMindIds(Long[] mindIds)
  96. {
  97. return studentMindOldMapper.deleteStudentMindOldByMindIds(mindIds);
  98. }
  99. /**
  100. * 删除学生心理健康历史信息信息
  101. *
  102. * @param mindId 学生心理健康历史信息主键
  103. * @return 结果
  104. */
  105. @Override
  106. public int deleteStudentMindOldByMindId(Long mindId)
  107. {
  108. return studentMindOldMapper.deleteStudentMindOldByMindId(mindId);
  109. }
  110. }