新增客户管理;
新增合同管理
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
package com.gxwebsoft.tower.controller;
|
||||
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.Company;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.tower.entity.*;
|
||||
import com.gxwebsoft.tower.mapper.TowerContractMapper;
|
||||
import com.gxwebsoft.tower.service.TowerContractService;
|
||||
import com.gxwebsoft.tower.param.TowerContractParam;
|
||||
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-06-08 22:36:47
|
||||
*/
|
||||
@Api(tags = "合同存档管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/tower/tower-contract")
|
||||
public class TowerContractController extends BaseController {
|
||||
@Resource
|
||||
private TowerContractService towerContractService;
|
||||
private TowerContractMapper towerContractMapper;
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerContract:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询合同存档")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<TowerContract>> page(TowerContractParam param) {
|
||||
MPJLambdaWrapper<TowerContract> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(TowerContract.class)
|
||||
.select(TowerProject::getProjectName)
|
||||
.selectAs(TowerCustomer::getName, TowerContract::getCustomerName)
|
||||
.selectAs(Company::getCompanyName, TowerContract::getCompanyName)
|
||||
.leftJoin(TowerProject.class, TowerProject::getProjectId, TowerContract::getProjectId)
|
||||
.leftJoin(TowerCustomer.class, TowerCustomer::getCustomerId, TowerContract::getCustomerId)
|
||||
.leftJoin(Company.class, Company::getCompanyId, TowerContract::getCompanyId);
|
||||
|
||||
PageParam<TowerContract, TowerContractParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(towerContractService.page(page, wrapper));
|
||||
// 使用关联查询
|
||||
//return success(towerContractService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerContract:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部合同存档")
|
||||
@GetMapping()
|
||||
public ApiResult<List<TowerContract>> list(TowerContractParam param) {
|
||||
PageParam<TowerContract, TowerContractParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(towerContractService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(towerContractService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerContract:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询合同存档")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<TowerContract> get(@PathVariable("id") Integer id) {
|
||||
return success(towerContractService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(towerContractService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerContract:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加合同存档")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody TowerContract towerContract) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
towerContract.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (towerContractService.save(towerContract)) {
|
||||
return success(towerContract.getContractId());
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerContract:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改合同存档")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody TowerContract towerContract) {
|
||||
if (towerContractService.updateById(towerContract)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerContract:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除合同存档")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (towerContractService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerContract:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加合同存档")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<TowerContract> list) {
|
||||
if (towerContractService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerContract:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改合同存档")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<TowerContract> batchParam) {
|
||||
if (batchParam.update(towerContractService, "contract_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('tower:towerContract:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除合同存档")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (towerContractService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user