package com.smart.reader.controller; import com.smart.reader.common.Page; import com.smart.reader.common.R; import com.smart.reader.enums.SuccessResultCode; import com.smart.reader.exception.CustomException; import com.smart.reader.model.bo.StudentInfoAddBo; import com.smart.reader.model.bo.StudentInfoUpdateBo; import com.smart.reader.model.vo.StudentInfoVo; import com.smart.reader.model.vo.SysUserInfoVo; import com.smart.reader.service.StudentInfoService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; @RestController @RequestMapping("/api/v1/educational/studentInfo") @Validated @Api(tags = "学生信息管理") public class StudentInfoController { @Resource private StudentInfoService studentInfoService; @GetMapping("queryInfo") @ApiOperation("获取学生列表") @ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", value = "当前⻚", required = true, dataType = "int", defaultValue = "1"), @ApiImplicitParam(name = "pageSize", value = "⻚⼤⼩", required = true, dataType = "int", defaultValue = "10"), }) public R> queryInfo(int pageNum, int pageSize) throws CustomException { Page result = studentInfoService.queryInfo(pageNum, pageSize); return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg(), result); } @PostMapping("/add") @ApiOperation("新增学生信息") public R add(@RequestBody StudentInfoAddBo studentInfo) throws CustomException { studentInfoService.add(studentInfo); return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg()); } @DeleteMapping("/delete/{id}") @ApiOperation("删除学生信息") public R delete(@PathVariable Long id) throws CustomException { studentInfoService.delete(id); return R.fail(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg()); } @PutMapping("/edit") @ApiOperation("修改学生信息") public R edit(@RequestBody StudentInfoUpdateBo studentInfo) throws CustomException { studentInfoService.edit(studentInfo); return R.fail(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg()); } @GetMapping("/{id}") @ApiOperation("查询学生详情") public R detail(@PathVariable Long id) throws CustomException { StudentInfoVo studentInfoVo = studentInfoService.detail(id); return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg(), studentInfoVo); } @DeleteMapping("/batchDelete") @ApiOperation("批量删除学生信息") public R batchDelete(@RequestBody List ids) throws CustomException { studentInfoService.batchDelete(ids); return R.success(SuccessResultCode.SUCCESS.getCode(), "批量删除成功"); } }