package com.gkhy.exam.pay.controller; import com.gkhy.exam.pay.entity.CoalPayStudent; import com.gkhy.exam.pay.service.CoalPayStudentService; import com.ruoyi.common.annotation.Anonymous; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.util.List; @RestController @Api(tags = "煤矿缴费批次对应学员管理") @RequestMapping("/pay/coalPayStudent") public class CoalPayStudentController extends BaseController { @Autowired private CoalPayStudentService coalPayStudentService; /** * 缴费批次对应学生 */ @GetMapping("/studentList/{coalPayId}") @ApiOperation(value = "缴费信息对应学员信息") public TableDataInfo list(@PathVariable Long coalPayId) { startPage(); List list = coalPayStudentService.selectCoalPayStudentList(coalPayId); return getDataTable(list); } /** * 修改相关学生信息 */ @PostMapping("/update") @ApiOperation(value = "修改相关学员信息") public AjaxResult updateStudent(@RequestBody CoalPayStudent coalPayStudent){ return coalPayStudentService.updateByCoalPayStudent(coalPayStudent); } /** * 新增相关学生 */ @PostMapping("/insert") @ApiOperation(value = "新增相关学员") public AjaxResult insertStudent(@Validated @RequestBody CoalPayStudent coalPayStudent){ return toAjax(coalPayStudentService.insertStudent(coalPayStudent)); } /** * 删除相关学生 */ @PostMapping("/delete") @ApiOperation(value = "删除对应学员") public AjaxResult deleteStudent(@RequestBody Long[] ids){ return toAjax(coalPayStudentService.deleteStudent(ids)); } /** * 批量导入学生 */ @PostMapping("/import") @Anonymous @ApiModelProperty(value = "导入学员") public AjaxResult uploadStudent(@RequestParam("file") MultipartFile file, @RequestParam("coalPayId") Long coalPayId) { try { return coalPayStudentService.uploadStudent(file, coalPayId); } catch (IOException e) { // 处理异常,返回友好的错误消息 return AjaxResult.error("学员信息导入失败: " + e.getMessage()); } } }