StudentInfoServiceImpl.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package com.ruoyi.system.service.impl;
  2. import java.util.List;
  3. import com.ruoyi.common.core.domain.AjaxResult;
  4. import com.ruoyi.common.utils.ClassUtils;
  5. import com.ruoyi.common.utils.DateUtils;
  6. import com.ruoyi.system.domain.StudentInfoOld;
  7. import com.ruoyi.system.mapper.StudentInfoOldMapper;
  8. import lombok.SneakyThrows;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.stereotype.Service;
  11. import com.ruoyi.system.mapper.StudentInfoMapper;
  12. import com.ruoyi.system.domain.StudentInfo;
  13. import com.ruoyi.system.service.IStudentInfoService;
  14. /**
  15. * 学生档案信息Service业务层处理
  16. *
  17. * @author ruoyi
  18. * @date 2023-07-21
  19. */
  20. @Service
  21. public class StudentInfoServiceImpl implements IStudentInfoService
  22. {
  23. @Autowired
  24. private StudentInfoMapper studentInfoMapper;
  25. @Autowired
  26. private StudentInfoOldMapper studentInfoOldMapper;
  27. /**
  28. * 查询学生档案信息
  29. *
  30. * @param id 学生档案信息主键
  31. * @return 学生档案信息
  32. */
  33. @Override
  34. public StudentInfo selectStudentInfoById(Long id)
  35. {
  36. return studentInfoMapper.selectStudentInfoById(id);
  37. }
  38. /**
  39. * 查询学生档案信息列表
  40. *
  41. * @param studentInfo 学生档案信息
  42. * @return 学生档案信息
  43. */
  44. @Override
  45. public List<StudentInfo> selectStudentInfoList(StudentInfo studentInfo)
  46. {
  47. return studentInfoMapper.selectStudentInfoList(studentInfo);
  48. }
  49. /**
  50. * 新增学生档案信息
  51. *
  52. * @param studentInfo 学生档案信息
  53. * @return 结果
  54. */
  55. @Override
  56. public AjaxResult insertStudentInfo(StudentInfo studentInfo)
  57. {
  58. //查询数据库是否存在信息
  59. StudentInfo student = new StudentInfo();
  60. student.setStudentId(studentInfo.getStudentId());
  61. List<StudentInfo> studentInfos = studentInfoMapper.selectStudentInfoList(student);
  62. if(studentInfos!=null && studentInfos.size()>0){
  63. return AjaxResult.error("参数错误");
  64. }
  65. studentInfo.setCreateTime(DateUtils.getNowDate());
  66. int rows = studentInfoMapper.insertStudentInfo(studentInfo);
  67. return rows > 0 ? AjaxResult.success() : AjaxResult.error();
  68. }
  69. /**
  70. * 修改学生档案信息
  71. *
  72. * @param studentInfo 学生档案信息
  73. * @return 结果
  74. */
  75. @SneakyThrows
  76. @Override
  77. public int updateStudentInfo(StudentInfo studentInfo)
  78. {
  79. //查询修改前数据
  80. StudentInfo student = studentInfoMapper.selectStudentInfoByStudentId(studentInfo.getStudentId());
  81. StudentInfoOld studentInfoOld = new StudentInfoOld();
  82. ClassUtils.copyProperties(student, studentInfoOld);
  83. studentInfoOld.setCreateTime(DateUtils.getNowDate());
  84. studentInfoOld.setUpdateTime(studentInfo.getCreateTime());
  85. studentInfoOldMapper.insertStudentInfoOld(studentInfoOld);
  86. studentInfo.setUpdateTime(DateUtils.getNowDate());
  87. return studentInfoMapper.updateStudentInfo(studentInfo);
  88. }
  89. /**
  90. * 批量删除学生档案信息
  91. *
  92. * @param ids 需要删除的学生档案信息主键
  93. * @return 结果
  94. */
  95. @Override
  96. public int deleteStudentInfoByIds(Long[] ids)
  97. {
  98. return studentInfoMapper.deleteStudentInfoByIds(ids);
  99. }
  100. /**
  101. * 删除学生档案信息信息
  102. *
  103. * @param id 学生档案信息主键
  104. * @return 结果
  105. */
  106. @Override
  107. public int deleteStudentInfoById(Long id)
  108. {
  109. return studentInfoMapper.deleteStudentInfoById(id);
  110. }
  111. }