123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- package com.ruoyi.system.service.impl;
- import java.util.List;
- import com.ruoyi.common.core.domain.AjaxResult;
- import com.ruoyi.common.utils.ClassUtils;
- import com.ruoyi.common.utils.DateUtils;
- import com.ruoyi.system.domain.StudentInfoOld;
- import com.ruoyi.system.mapper.StudentInfoOldMapper;
- import lombok.SneakyThrows;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.ruoyi.system.mapper.StudentInfoMapper;
- import com.ruoyi.system.domain.StudentInfo;
- import com.ruoyi.system.service.IStudentInfoService;
- /**
- * 学生档案信息Service业务层处理
- *
- * @author ruoyi
- * @date 2023-07-21
- */
- @Service
- public class StudentInfoServiceImpl implements IStudentInfoService
- {
- @Autowired
- private StudentInfoMapper studentInfoMapper;
- @Autowired
- private StudentInfoOldMapper studentInfoOldMapper;
- /**
- * 查询学生档案信息
- *
- * @param id 学生档案信息主键
- * @return 学生档案信息
- */
- @Override
- public StudentInfo selectStudentInfoById(Long id)
- {
- return studentInfoMapper.selectStudentInfoById(id);
- }
- /**
- * 查询学生档案信息列表
- *
- * @param studentInfo 学生档案信息
- * @return 学生档案信息
- */
- @Override
- public List<StudentInfo> selectStudentInfoList(StudentInfo studentInfo)
- {
- return studentInfoMapper.selectStudentInfoList(studentInfo);
- }
- /**
- * 新增学生档案信息
- *
- * @param studentInfo 学生档案信息
- * @return 结果
- */
- @Override
- public AjaxResult insertStudentInfo(StudentInfo studentInfo)
- {
- //查询数据库是否存在信息
- StudentInfo student = new StudentInfo();
- student.setStudentId(studentInfo.getStudentId());
- List<StudentInfo> studentInfos = studentInfoMapper.selectStudentInfoList(student);
- if(studentInfos!=null && studentInfos.size()>0){
- return AjaxResult.error("参数错误");
- }
- studentInfo.setCreateTime(DateUtils.getNowDate());
- int rows = studentInfoMapper.insertStudentInfo(studentInfo);
- return rows > 0 ? AjaxResult.success() : AjaxResult.error();
- }
- /**
- * 修改学生档案信息
- *
- * @param studentInfo 学生档案信息
- * @return 结果
- */
- @SneakyThrows
- @Override
- public int updateStudentInfo(StudentInfo studentInfo)
- {
- //查询修改前数据
- StudentInfo student = studentInfoMapper.selectStudentInfoByStudentId(studentInfo.getStudentId());
- StudentInfoOld studentInfoOld = new StudentInfoOld();
- ClassUtils.copyProperties(student, studentInfoOld);
- studentInfoOld.setCreateTime(DateUtils.getNowDate());
- studentInfoOld.setUpdateTime(studentInfo.getCreateTime());
- studentInfoOldMapper.insertStudentInfoOld(studentInfoOld);
- studentInfo.setUpdateTime(DateUtils.getNowDate());
- return studentInfoMapper.updateStudentInfo(studentInfo);
- }
- /**
- * 批量删除学生档案信息
- *
- * @param ids 需要删除的学生档案信息主键
- * @return 结果
- */
- @Override
- public int deleteStudentInfoByIds(Long[] ids)
- {
- return studentInfoMapper.deleteStudentInfoByIds(ids);
- }
- /**
- * 删除学生档案信息信息
- *
- * @param id 学生档案信息主键
- * @return 结果
- */
- @Override
- public int deleteStudentInfoById(Long id)
- {
- return studentInfoMapper.deleteStudentInfoById(id);
- }
- }
|