新增项目管理
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
package com.gxwebsoft.tower.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.tower.service.TowerProjectService;
|
||||
import com.gxwebsoft.tower.entity.TowerProject;
|
||||
import com.gxwebsoft.tower.param.TowerProjectParam;
|
||||
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 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.common.system.entity.User;
|
||||
import com.gxwebsoft.tower.entity.TowerProject;
|
||||
import com.gxwebsoft.tower.entity.TowerProjectOrder;
|
||||
import com.gxwebsoft.tower.param.TowerProjectParam;
|
||||
import com.gxwebsoft.tower.service.TowerProjectOrderService;
|
||||
import com.gxwebsoft.tower.service.TowerProjectService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 项目管理控制器
|
||||
@@ -30,9 +32,10 @@ import java.util.List;
|
||||
public class TowerProjectController extends BaseController {
|
||||
@Resource
|
||||
private TowerProjectService towerProjectService;
|
||||
@Resource
|
||||
private TowerProjectOrderService towerProjectOrderService;
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerProject:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询项目管理")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<TowerProject>> page(TowerProjectParam param) {
|
||||
@@ -41,7 +44,6 @@ public class TowerProjectController extends BaseController {
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerProject:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部项目管理")
|
||||
@GetMapping()
|
||||
public ApiResult<List<TowerProject>> list(TowerProjectParam param) {
|
||||
@@ -50,7 +52,6 @@ public class TowerProjectController extends BaseController {
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerProject:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询项目管理")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<TowerProject> get(@PathVariable("id") Integer id) {
|
||||
@@ -59,7 +60,6 @@ public class TowerProjectController extends BaseController {
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerProject:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加项目管理")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody TowerProject towerProject) {
|
||||
@@ -69,24 +69,34 @@ public class TowerProjectController extends BaseController {
|
||||
towerProject.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (towerProjectService.save(towerProject)) {
|
||||
if (!towerProject.getOrders().isEmpty()) {
|
||||
final Set<TowerProjectOrder> orders = towerProject.getOrders();
|
||||
orders.forEach(d->{
|
||||
d.setProjectId(towerProject.getProjectId());
|
||||
});
|
||||
towerProjectOrderService.saveBatch(orders);
|
||||
}
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerProject:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改项目管理")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody TowerProject towerProject) {
|
||||
if (towerProjectService.updateById(towerProject)) {
|
||||
if (!towerProject.getOrders().isEmpty()) {
|
||||
final Set<TowerProjectOrder> orders = towerProject.getOrders();
|
||||
System.out.println("orders = " + orders);
|
||||
towerProjectOrderService.saveOrUpdateBatch(towerProject.getOrders());
|
||||
}
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerProject:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除项目管理")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
@@ -97,7 +107,6 @@ public class TowerProjectController extends BaseController {
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerProject:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加项目管理")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<TowerProject> list) {
|
||||
@@ -108,7 +117,6 @@ public class TowerProjectController extends BaseController {
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerProject:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改项目管理")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<TowerProject> batchParam) {
|
||||
|
||||
Reference in New Issue
Block a user