You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
4.7 KiB
109 lines
4.7 KiB
package cn.iocoder.yudao.module.zhuguang.controller.admin.basic_info;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import jakarta.annotation.Resource;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
import jakarta.validation.constraints.*;
|
|
import jakarta.validation.*;
|
|
import jakarta.servlet.http.*;
|
|
import java.util.*;
|
|
import java.io.IOException;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
|
import cn.iocoder.yudao.module.zhuguang.controller.admin.basic_info.vo.*;
|
|
import cn.iocoder.yudao.module.zhuguang.dal.dataobject.basic_info.CounselorDO;
|
|
import cn.iocoder.yudao.module.zhuguang.dal.dataobject.basic_info.FixedClassTableDO;
|
|
import cn.iocoder.yudao.module.zhuguang.service.basic_info.CounselorService;
|
|
|
|
/**
|
|
* 辅导员表
|
|
*/
|
|
@Tag(name = "管理后台 - 辅导员")
|
|
@RestController
|
|
@RequestMapping("/zhuguang/counselor")
|
|
@Validated
|
|
public class CounselorController {
|
|
|
|
@Resource
|
|
private CounselorService counselorService;
|
|
|
|
@PostMapping("/create")
|
|
@Operation(summary = "创建辅导员")
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:counselor:create')")
|
|
public CommonResult<Long> createCounselor(@Valid @RequestBody CounselorSaveReqVO createReqVO) {
|
|
return success(counselorService.createCounselor(createReqVO));
|
|
}
|
|
|
|
@PutMapping("/update")
|
|
@Operation(summary = "更新辅导员")
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:counselor:update')")
|
|
public CommonResult<Boolean> updateCounselor(@Valid @RequestBody CounselorSaveReqVO updateReqVO) {
|
|
counselorService.updateCounselor(updateReqVO);
|
|
return success(true);
|
|
}
|
|
|
|
@DeleteMapping("/delete")
|
|
@Operation(summary = "删除辅导员")
|
|
@Parameter(name = "id", description = "编号", required = true)
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:counselor:delete')")
|
|
public CommonResult<Boolean> deleteCounselor(@RequestParam("id") Long id) {
|
|
counselorService.deleteCounselor(id);
|
|
return success(true);
|
|
}
|
|
|
|
@GetMapping("/get")
|
|
@Operation(summary = "获得辅导员")
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:counselor:query')")
|
|
public CommonResult<CounselorRespVO> getCounselor(@RequestParam("id") Long id) {
|
|
CounselorDO counselor = counselorService.getCounselor(id);
|
|
return success(BeanUtils.toBean(counselor, CounselorRespVO.class));
|
|
}
|
|
|
|
@GetMapping("/page")
|
|
@Operation(summary = "获得辅导员分页")
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:counselor:query')")
|
|
public CommonResult<PageResult<CounselorRespVO>> getCounselorPage(@Valid CounselorPageReqVO pageReqVO) {
|
|
PageResult<CounselorDO> pageResult = counselorService.getCounselorPage(pageReqVO);
|
|
return success(BeanUtils.toBean(pageResult, CounselorRespVO.class));
|
|
}
|
|
|
|
@GetMapping("/export-excel")
|
|
@Operation(summary = "导出辅导员 Excel")
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:counselor:export')")
|
|
@ApiAccessLog(operateType = EXPORT)
|
|
public void exportCounselorExcel(@Valid CounselorPageReqVO pageReqVO,
|
|
HttpServletResponse response) throws IOException {
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
List<CounselorDO> list = counselorService.getCounselorPage(pageReqVO).getList();
|
|
// 导出 Excel
|
|
ExcelUtils.write(response, "辅导员.xls", "数据", CounselorRespVO.class,
|
|
BeanUtils.toBean(list, CounselorRespVO.class));
|
|
}
|
|
|
|
// ==================== 子表(固定班级) ====================
|
|
|
|
@GetMapping("/fixed-class-table/list-by-counselor-id")
|
|
@Operation(summary = "获得固定班级列表")
|
|
@Parameter(name = "counselorId", description = "辅导员的id")
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:counselor:query')")
|
|
public CommonResult<List<FixedClassTableDO>> getFixedClassTableListByCounselorId(@RequestParam("counselorId") Long counselorId) {
|
|
return success(counselorService.getFixedClassTableListByCounselorId(counselorId));
|
|
}
|
|
|
|
} |