新增配件管理模块
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
package com.gxwebsoft.tower.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.tower.service.TowerPartService;
|
||||
import com.gxwebsoft.tower.entity.TowerPart;
|
||||
import com.gxwebsoft.tower.param.TowerPartParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 安全检查控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-02-27 18:40:31
|
||||
*/
|
||||
@Api(tags = "安全检查管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/tower/tower-part")
|
||||
public class TowerPartController extends BaseController {
|
||||
@Resource
|
||||
private TowerPartService towerPartService;
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerPart:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询安全检查")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<TowerPart>> page(TowerPartParam param) {
|
||||
// 使用关联查询
|
||||
return success(towerPartService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerPart:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部安全检查")
|
||||
@GetMapping()
|
||||
public ApiResult<List<TowerPart>> list(TowerPartParam param) {
|
||||
PageParam<TowerPart, TowerPartParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(towerPartService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(towerPartService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerPart:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询安全检查")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<TowerPart> get(@PathVariable("id") Integer id) {
|
||||
return success(towerPartService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(towerPartService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerPart:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加安全检查")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody TowerPart towerPart) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
towerPart.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (towerPartService.save(towerPart)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerPart:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改安全检查")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody TowerPart towerPart) {
|
||||
if (towerPartService.updateById(towerPart)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerPart:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除安全检查")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (towerPartService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerPart:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加安全检查")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<TowerPart> list) {
|
||||
if (towerPartService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerPart:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改安全检查")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<TowerPart> batchParam) {
|
||||
if (batchParam.update(towerPartService, "part_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerPart:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除安全检查")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (towerPartService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user