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.
106 lines
4.6 KiB
106 lines
4.6 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.SpecialtyDO;
|
|
import cn.iocoder.yudao.module.zhuguang.dal.dataobject.basic_info.FixedClassTableDO;
|
|
import cn.iocoder.yudao.module.zhuguang.service.basic_info.SpecialtyService;
|
|
|
|
@Tag(name = "管理后台 - 专业")
|
|
@RestController
|
|
@RequestMapping("/zhuguang/specialty")
|
|
@Validated
|
|
public class SpecialtyController {
|
|
|
|
@Resource
|
|
private SpecialtyService specialtyService;
|
|
|
|
@PostMapping("/create")
|
|
@Operation(summary = "创建专业")
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:specialty:create')")
|
|
public CommonResult<Long> createSpecialty(@Valid @RequestBody SpecialtySaveReqVO createReqVO) {
|
|
return success(specialtyService.createSpecialty(createReqVO));
|
|
}
|
|
|
|
@PutMapping("/update")
|
|
@Operation(summary = "更新专业")
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:specialty:update')")
|
|
public CommonResult<Boolean> updateSpecialty(@Valid @RequestBody SpecialtySaveReqVO updateReqVO) {
|
|
specialtyService.updateSpecialty(updateReqVO);
|
|
return success(true);
|
|
}
|
|
|
|
@DeleteMapping("/delete")
|
|
@Operation(summary = "删除专业")
|
|
@Parameter(name = "id", description = "编号", required = true)
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:specialty:delete')")
|
|
public CommonResult<Boolean> deleteSpecialty(@RequestParam("id") Long id) {
|
|
specialtyService.deleteSpecialty(id);
|
|
return success(true);
|
|
}
|
|
|
|
@GetMapping("/get")
|
|
@Operation(summary = "获得专业")
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:specialty:query')")
|
|
public CommonResult<SpecialtyRespVO> getSpecialty(@RequestParam("id") Long id) {
|
|
SpecialtyDO specialty = specialtyService.getSpecialty(id);
|
|
return success(BeanUtils.toBean(specialty, SpecialtyRespVO.class));
|
|
}
|
|
|
|
@GetMapping("/page")
|
|
@Operation(summary = "获得专业分页")
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:specialty:query')")
|
|
public CommonResult<PageResult<SpecialtyRespVO>> getSpecialtyPage(@Valid SpecialtyPageReqVO pageReqVO) {
|
|
PageResult<SpecialtyDO> pageResult = specialtyService.getSpecialtyPage(pageReqVO);
|
|
return success(BeanUtils.toBean(pageResult, SpecialtyRespVO.class));
|
|
}
|
|
|
|
@GetMapping("/export-excel")
|
|
@Operation(summary = "导出专业 Excel")
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:specialty:export')")
|
|
@ApiAccessLog(operateType = EXPORT)
|
|
public void exportSpecialtyExcel(@Valid SpecialtyPageReqVO pageReqVO,
|
|
HttpServletResponse response) throws IOException {
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
List<SpecialtyDO> list = specialtyService.getSpecialtyPage(pageReqVO).getList();
|
|
// 导出 Excel
|
|
ExcelUtils.write(response, "专业.xls", "数据", SpecialtyRespVO.class,
|
|
BeanUtils.toBean(list, SpecialtyRespVO.class));
|
|
}
|
|
|
|
// ==================== 子表(固定班级) ====================
|
|
|
|
@GetMapping("/fixed-class-table/list-by-specialty-id")
|
|
@Operation(summary = "获得固定班级列表")
|
|
@Parameter(name = "specialtyId", description = "专业的id")
|
|
@PreAuthorize("@ss.hasPermission('zhuguang:specialty:query')")
|
|
public CommonResult<List<FixedClassTableDO>> getFixedClassTableListBySpecialtyId(@RequestParam("specialtyId") Long specialtyId) {
|
|
return success(specialtyService.getFixedClassTableListBySpecialtyId(specialtyId));
|
|
}
|
|
|
|
} |