parent
07639b6008
commit
05e9786c62
12 changed files with 278 additions and 9 deletions
@ -1,7 +1,26 @@ |
|||||||
package com.msdw.tms.api; |
package com.msdw.tms.api; |
||||||
|
|
||||||
|
import com.msdw.tms.common.utils.R; |
||||||
|
import com.msdw.tms.entity.vo.StudentVo; |
||||||
import io.swagger.annotations.Api; |
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
@Api(value = "学生管理", tags = "学生管理") |
@Api(value = "学生管理", tags = "学生管理") |
||||||
public interface StudentControllerApi { |
public interface StudentControllerApi { |
||||||
|
|
||||||
|
@ApiOperation(value = "新增学生",notes = "新增学生") |
||||||
|
public R addStudent(@RequestBody StudentVo studentVo); |
||||||
|
|
||||||
|
@ApiOperation(value = "学生列表信息",notes = "学生列表信息") |
||||||
|
public R queryStudent(Integer schoolId, String seachContent, Integer page, Integer size); |
||||||
|
|
||||||
|
@ApiOperation(value = "删除学生",notes = "删除学生") |
||||||
|
public R daleteStudent(List<Integer> studentId); |
||||||
|
|
||||||
|
@ApiOperation(value = "编辑学生信息",notes = "编辑学生信息") |
||||||
|
public R updateStudent(StudentVo studentVo); |
||||||
} |
} |
||||||
|
@ -1,9 +1,20 @@ |
|||||||
package com.msdw.tms.dao; |
package com.msdw.tms.dao; |
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||||
import com.msdw.tms.entity.StudentEntity; |
import com.msdw.tms.entity.StudentEntity; |
||||||
|
import com.msdw.tms.entity.vo.StudentVo; |
||||||
import org.apache.ibatis.annotations.Mapper; |
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.poi.ss.formula.functions.T; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
@Mapper |
@Mapper |
||||||
public interface StudentDao extends BaseMapper<StudentEntity> { |
public interface StudentDao extends BaseMapper<StudentEntity> { |
||||||
|
boolean saveStudent(StudentVo studentVo); |
||||||
|
|
||||||
|
IPage<StudentVo> queryStudent(Page<T> tpage,String searchContent,Integer schoolId); |
||||||
|
|
||||||
|
boolean deleteStudent(List<Integer> studentId); |
||||||
} |
} |
||||||
|
@ -1,8 +1,18 @@ |
|||||||
package com.msdw.tms.service; |
package com.msdw.tms.service; |
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService; |
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.msdw.tms.common.utils.PageUtils; |
||||||
import com.msdw.tms.entity.StudentEntity; |
import com.msdw.tms.entity.StudentEntity; |
||||||
|
import com.msdw.tms.entity.UserInfoEntity; |
||||||
|
import com.msdw.tms.entity.vo.StudentVo; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
public interface StudentService extends IService<StudentEntity>{ |
public interface StudentService extends IService<StudentEntity>{ |
||||||
|
|
||||||
|
boolean saveStudent(StudentVo studentvo); |
||||||
|
|
||||||
|
PageUtils queryStudent(Integer schoolId,String searchContent, Integer page, Integer size); |
||||||
|
|
||||||
|
boolean deleteStudent(List<Integer> studentId); |
||||||
} |
} |
||||||
|
@ -1,12 +1,49 @@ |
|||||||
package com.msdw.tms.service.impl; |
package com.msdw.tms.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.msdw.tms.common.utils.Constant; |
||||||
|
import com.msdw.tms.common.utils.PageUtils; |
||||||
import com.msdw.tms.dao.StudentDao; |
import com.msdw.tms.dao.StudentDao; |
||||||
import com.msdw.tms.entity.StudentEntity; |
import com.msdw.tms.entity.StudentEntity; |
||||||
|
import com.msdw.tms.entity.vo.StudentVo; |
||||||
import com.msdw.tms.service.StudentService; |
import com.msdw.tms.service.StudentService; |
||||||
|
import org.apache.poi.ss.formula.functions.T; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
@Service("studentService") |
@Service("studentService") |
||||||
public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> implements StudentService { |
public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> implements StudentService { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private StudentDao studentDao; |
||||||
|
|
||||||
|
@Transactional |
||||||
|
@Override |
||||||
|
public boolean saveStudent(StudentVo studentvo) { |
||||||
|
studentvo.setIsdel(Constant.IsDel.NOT_DEL.getType()); |
||||||
|
boolean save = studentDao.saveStudent(studentvo); |
||||||
|
return save; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public PageUtils queryStudent(Integer schoolId,String searchContent, Integer page, Integer size) { |
||||||
|
Page<T> tPage = new Page<>(page,size); |
||||||
|
IPage<StudentVo> saveStudent = studentDao.queryStudent(tPage,searchContent,schoolId); |
||||||
|
PageUtils pageUtils = new PageUtils(saveStudent); |
||||||
|
return pageUtils; |
||||||
|
} |
||||||
|
|
||||||
|
@Transactional |
||||||
|
@Override |
||||||
|
public boolean deleteStudent(List<Integer> studentId) { |
||||||
|
|
||||||
|
boolean delete = studentDao.deleteStudent(studentId); |
||||||
|
return delete; |
||||||
|
} |
||||||
|
|
||||||
} |
} |
||||||
|
@ -0,0 +1,66 @@ |
|||||||
|
package com.msdw.tms.service; |
||||||
|
|
||||||
|
import cn.hutool.system.UserInfo; |
||||||
|
import com.msdw.tms.common.utils.PageUtils; |
||||||
|
import com.msdw.tms.common.utils.R; |
||||||
|
import com.msdw.tms.controller.StudentController; |
||||||
|
import com.msdw.tms.entity.UserInfoEntity; |
||||||
|
import com.msdw.tms.entity.vo.StudentVo; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@SpringBootTest |
||||||
|
public class StudentTest { |
||||||
|
@Autowired |
||||||
|
private StudentService studentService; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private UserInfoService userInfoService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加学生 |
||||||
|
*/ |
||||||
|
@Test |
||||||
|
public void addStudent(){ |
||||||
|
StudentVo studentVo = new StudentVo(); |
||||||
|
Integer a = 1; |
||||||
|
UserInfoEntity userInfoEntity = new UserInfoEntity(); |
||||||
|
userInfoEntity.setAccount("123456").setUserName("michonne").setSchoolId(a); |
||||||
|
studentVo.setSchoolId(a).setUserId(257).setStudentIdNumber("888888").setRoleId(4).setProfessionalId(1).setGradeId(1).setClassId(1); |
||||||
|
studentVo.setUserInfo(userInfoEntity); |
||||||
|
boolean aa= studentService.saveStudent(studentVo); |
||||||
|
// boolean bb = userInfoService.saveUserInfo(userInfoEntity);
|
||||||
|
System.out.println(aa ? "添加成功" : "添加失败"); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 学生列表 |
||||||
|
*/ |
||||||
|
@Test |
||||||
|
public void queryStudent(){ |
||||||
|
Integer schoolId = 1; |
||||||
|
String searchContent = "michonne"; |
||||||
|
Integer page = 1; |
||||||
|
Integer size = 20; |
||||||
|
PageUtils pageUtils = studentService.queryStudent(schoolId,searchContent,page,size); |
||||||
|
System.out.println(pageUtils); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除学生 |
||||||
|
*/ |
||||||
|
// @Test
|
||||||
|
// public void deleteStudent(){
|
||||||
|
// List<Integer> studentId = {1,2};
|
||||||
|
//// List<Integer> studentId = new ArrayList<>();
|
||||||
|
//// studentId.add(1);
|
||||||
|
//// studentId.add(2);
|
||||||
|
//
|
||||||
|
// boolean b = studentService.deleteStudent(studentId);
|
||||||
|
// System.out.println(b ? "删除成功" : "删除失败");
|
||||||
|
// }
|
||||||
|
} |
Loading…
Reference in new issue