Files
tuanwei-java/src/main/java/com/gxwebsoft/gxmu/controller/CollegeController.java
2026-07-20 11:48:06 +08:00

91 lines
3.1 KiB
Java

package com.gxwebsoft.gxmu.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.gxmu.entity.College;
import com.gxwebsoft.gxmu.param.CollegeParam;
import com.gxwebsoft.gxmu.service.CollegeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 学院管理控制器
*/
@Api(tags = "学院管理")
@RestController
@RequestMapping("/api/gxmu/college")
public class CollegeController extends BaseController {
@Resource
private CollegeService collegeService;
@ApiOperation("分页查询学院")
@GetMapping("/page")
public ApiResult<PageResult<College>> page(CollegeParam param) {
param.setTenantId(getTenantId());
return success(collegeService.pageRel(param));
}
@ApiOperation("查询学院列表")
@GetMapping()
public ApiResult<List<College>> list(CollegeParam param) {
param.setTenantId(getTenantId());
return success(collegeService.listRel(param));
}
@ApiOperation("根据id查询学院")
@GetMapping("/{id}")
public ApiResult<College> get(@PathVariable("id") Integer id) {
return success(collegeService.getByIdRel(id, getTenantId()));
}
@OperationLog
@ApiOperation("添加学院")
@PostMapping()
public ApiResult<?> save(@RequestBody College college) {
college.setTenantId(getTenantId());
return collegeService.save(college) ? success("添加成功") : fail("添加失败");
}
@OperationLog
@ApiOperation("修改学院")
@PutMapping()
public ApiResult<?> update(@RequestBody College college) {
college.setTenantId(getTenantId());
return collegeService.updateById(college) ? success("修改成功") : fail("修改失败");
}
@OperationLog
@ApiOperation("删除学院")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
return collegeService.remove(new LambdaQueryWrapper<College>()
.eq(College::getId, id)
.eq(College::getTenantId, getTenantId())) ? success("删除成功") : fail("删除失败");
}
@OperationLog
@ApiOperation("批量修改学院")
@PutMapping("/batch")
public ApiResult<?> updateBatch(@RequestBody BatchParam<College> batchParam) {
return batchParam.update(collegeService, "id") ? success("修改成功") : fail("修改失败");
}
@OperationLog
@ApiOperation("批量删除学院")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
return collegeService.remove(new LambdaQueryWrapper<College>()
.in(College::getId, ids)
.eq(College::getTenantId, getTenantId())) ? success("删除成功") : fail("删除失败");
}
}