140 lines
4.6 KiB
Java
140 lines
4.6 KiB
Java
package com.gxwebsoft.common.system.controller;
|
|
|
|
import com.gxwebsoft.common.core.web.BaseController;
|
|
import com.gxwebsoft.common.system.entity.User;
|
|
import com.gxwebsoft.common.system.service.AppService;
|
|
import com.gxwebsoft.common.system.entity.App;
|
|
import com.gxwebsoft.common.system.param.AppParam;
|
|
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 2023-10-30 22:20:23
|
|
*/
|
|
@Api(tags = "应用管理记录表管理")
|
|
@RestController
|
|
@RequestMapping("/api/system/app")
|
|
public class AppController extends BaseController {
|
|
@Resource
|
|
private AppService appService;
|
|
|
|
@PreAuthorize("hasAuthority('sys:app:list')")
|
|
@OperationLog
|
|
@ApiOperation("分页查询应用管理记录表")
|
|
@GetMapping("/page")
|
|
public ApiResult<PageResult<App>> page(AppParam param) {
|
|
PageParam<App, AppParam> page = new PageParam<>(param);
|
|
page.setDefaultOrder("create_time desc");
|
|
return success(appService.page(page, page.getWrapper()));
|
|
// 使用关联查询
|
|
//return success(appService.pageRel(param));
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:app:list')")
|
|
@OperationLog
|
|
@ApiOperation("查询全部应用管理记录表")
|
|
@GetMapping()
|
|
public ApiResult<List<App>> list(AppParam param) {
|
|
PageParam<App, AppParam> page = new PageParam<>(param);
|
|
page.setDefaultOrder("create_time desc");
|
|
return success(appService.list(page.getOrderWrapper()));
|
|
// 使用关联查询
|
|
//return success(appService.listRel(param));
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:app:list')")
|
|
@OperationLog
|
|
@ApiOperation("根据id查询应用管理记录表")
|
|
@GetMapping("/{id}")
|
|
public ApiResult<App> get(@PathVariable("id") Integer id) {
|
|
return success(appService.getById(id));
|
|
// 使用关联查询
|
|
//return success(appService.getByIdRel(id));
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:app:save')")
|
|
@OperationLog
|
|
@ApiOperation("添加应用管理记录表")
|
|
@PostMapping()
|
|
public ApiResult<?> save(@RequestBody App app) {
|
|
// 记录当前登录用户id
|
|
User loginUser = getLoginUser();
|
|
if (loginUser != null) {
|
|
app.setUserId(loginUser.getUserId());
|
|
}
|
|
if (appService.save(app)) {
|
|
return success("添加成功");
|
|
}
|
|
return fail("添加失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:app:update')")
|
|
@OperationLog
|
|
@ApiOperation("修改应用管理记录表")
|
|
@PutMapping()
|
|
public ApiResult<?> update(@RequestBody App app) {
|
|
if (appService.updateById(app)) {
|
|
return success("修改成功");
|
|
}
|
|
return fail("修改失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:app:remove')")
|
|
@OperationLog
|
|
@ApiOperation("删除应用管理记录表")
|
|
@DeleteMapping("/{id}")
|
|
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
|
if (appService.removeById(id)) {
|
|
return success("删除成功");
|
|
}
|
|
return fail("删除失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:app:save')")
|
|
@OperationLog
|
|
@ApiOperation("批量添加应用管理记录表")
|
|
@PostMapping("/batch")
|
|
public ApiResult<?> saveBatch(@RequestBody List<App> list) {
|
|
if (appService.saveBatch(list)) {
|
|
return success("添加成功");
|
|
}
|
|
return fail("添加失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:app:update')")
|
|
@OperationLog
|
|
@ApiOperation("批量修改应用管理记录表")
|
|
@PutMapping("/batch")
|
|
public ApiResult<?> removeBatch(@RequestBody BatchParam<App> batchParam) {
|
|
if (batchParam.update(appService, "app_id")) {
|
|
return success("修改成功");
|
|
}
|
|
return fail("修改失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:app:remove')")
|
|
@OperationLog
|
|
@ApiOperation("批量删除应用管理记录表")
|
|
@DeleteMapping("/batch")
|
|
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
|
if (appService.removeByIds(ids)) {
|
|
return success("删除成功");
|
|
}
|
|
return fail("删除失败");
|
|
}
|
|
|
|
}
|