|
@@ -1,19 +1,3 @@
|
|
|
-/*
|
|
|
- * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
- *
|
|
|
- * Redistribution and use in source and binary forms, with or without
|
|
|
- * modification, are permitted provided that the following conditions are met:
|
|
|
- *
|
|
|
- * Redistributions of source code must retain the above copyright notice,
|
|
|
- * this list of conditions and the following disclaimer.
|
|
|
- * Redistributions in binary form must reproduce the above copyright
|
|
|
- * notice, this list of conditions and the following disclaimer in the
|
|
|
- * documentation and/or other materials provided with the distribution.
|
|
|
- * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
- * contributors may be used to endorse or promote products derived from
|
|
|
- * this software without specific prior written permission.
|
|
|
- * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
- */
|
|
|
package org.springblade.business.controller;
|
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -22,9 +6,10 @@ import io.swagger.annotations.ApiParam;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import javax.validation.Valid;
|
|
|
-
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.secure.BladeUser;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -36,16 +21,18 @@ import org.springblade.business.wrapper.ConstructionLedgerWrapper;
|
|
|
import org.springblade.business.service.IConstructionLedgerService;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
/**
|
|
|
- * 控制器
|
|
|
+ * 施工台账控制器
|
|
|
*
|
|
|
* @author BladeX
|
|
|
* @since 2022-05-23
|
|
|
*/
|
|
|
@RestController
|
|
|
@AllArgsConstructor
|
|
|
-@RequestMapping("/constructionledger")
|
|
|
-@Api(value = "", tags = "接口")
|
|
|
+@RequestMapping("/constructionLedger")
|
|
|
+@Api(tags = "施工台账接口")
|
|
|
public class ConstructionLedgerController extends BladeController {
|
|
|
|
|
|
private final IConstructionLedgerService constructionLedgerService;
|
|
@@ -55,9 +42,9 @@ public class ConstructionLedgerController extends BladeController {
|
|
|
*/
|
|
|
@GetMapping("/detail")
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
- @ApiOperation(value = "详情", notes = "传入constructionLedger")
|
|
|
- public R<ConstructionLedgerVO> detail(ConstructionLedger constructionLedger) {
|
|
|
- ConstructionLedger detail = constructionLedgerService.getOne(Condition.getQueryWrapper(constructionLedger));
|
|
|
+ @ApiOperation(value = "详情", notes = "传入id")
|
|
|
+ public R<ConstructionLedgerVO> detail(@RequestParam String id) {
|
|
|
+ ConstructionLedger detail = this.constructionLedgerService.getById(id);
|
|
|
return R.data(ConstructionLedgerWrapper.build().entityVO(detail));
|
|
|
}
|
|
|
|
|
@@ -66,21 +53,20 @@ public class ConstructionLedgerController extends BladeController {
|
|
|
*/
|
|
|
@GetMapping("/list")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
- @ApiOperation(value = "分页", notes = "传入constructionLedger")
|
|
|
+ @ApiOperation(value = "分页(不建议)", notes = "传入constructionLedger")
|
|
|
public R<IPage<ConstructionLedgerVO>> list(ConstructionLedger constructionLedger, Query query) {
|
|
|
- IPage<ConstructionLedger> pages = constructionLedgerService.page(Condition.getPage(query), Condition.getQueryWrapper(constructionLedger));
|
|
|
+ IPage<ConstructionLedger> pages = this.constructionLedgerService.page(Condition.getPage(query), Condition.getQueryWrapper(constructionLedger));
|
|
|
return R.data(ConstructionLedgerWrapper.build().pageVO(pages));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 自定义分页
|
|
|
*/
|
|
|
@GetMapping("/page")
|
|
|
@ApiOperationSupport(order = 3)
|
|
|
- @ApiOperation(value = "分页", notes = "传入constructionLedger")
|
|
|
+ @ApiOperation(value = "分页(建议)", notes = "传入constructionLedger")
|
|
|
public R<IPage<ConstructionLedgerVO>> page(ConstructionLedgerVO constructionLedger, Query query) {
|
|
|
- IPage<ConstructionLedgerVO> pages = constructionLedgerService.selectConstructionLedgerPage(Condition.getPage(query), constructionLedger);
|
|
|
+ IPage<ConstructionLedgerVO> pages = this.constructionLedgerService.selectConstructionLedgerPage(Condition.getPage(query), constructionLedger);
|
|
|
return R.data(pages);
|
|
|
}
|
|
|
|
|
@@ -89,9 +75,10 @@ public class ConstructionLedgerController extends BladeController {
|
|
|
*/
|
|
|
@PostMapping("/save")
|
|
|
@ApiOperationSupport(order = 4)
|
|
|
- @ApiOperation(value = "新增", notes = "传入constructionLedger")
|
|
|
- public R save(@Valid @RequestBody ConstructionLedger constructionLedger) {
|
|
|
- return R.status(constructionLedgerService.save(constructionLedger));
|
|
|
+ @ApiOperation(value = "新增(不需要)", notes = "传入constructionLedger")
|
|
|
+ public R<Boolean> save(@Valid @RequestBody ConstructionLedger constructionLedger) {
|
|
|
+ setUserData(constructionLedger, true);
|
|
|
+ return R.status(this.constructionLedgerService.save(constructionLedger));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -100,30 +87,33 @@ public class ConstructionLedgerController extends BladeController {
|
|
|
@PostMapping("/update")
|
|
|
@ApiOperationSupport(order = 5)
|
|
|
@ApiOperation(value = "修改", notes = "传入constructionLedger")
|
|
|
- public R update(@Valid @RequestBody ConstructionLedger constructionLedger) {
|
|
|
- return R.status(constructionLedgerService.updateById(constructionLedger));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增或修改
|
|
|
- */
|
|
|
- @PostMapping("/submit")
|
|
|
- @ApiOperationSupport(order = 6)
|
|
|
- @ApiOperation(value = "新增或修改", notes = "传入constructionLedger")
|
|
|
- public R submit(@Valid @RequestBody ConstructionLedger constructionLedger) {
|
|
|
- return R.status(constructionLedgerService.saveOrUpdate(constructionLedger));
|
|
|
+ public R<Boolean> update(@Valid @RequestBody ConstructionLedger constructionLedger) {
|
|
|
+ setUserData(constructionLedger, false);
|
|
|
+ return R.status(this.constructionLedgerService.updateById(constructionLedger));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 删除
|
|
|
*/
|
|
|
@PostMapping("/remove")
|
|
|
- @ApiOperationSupport(order = 7)
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
@ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
|
- public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
- return R.status(constructionLedgerService.deleteLogic(Func.toLongList(ids)));
|
|
|
+ public R<Boolean> remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
+ return R.status(this.constructionLedgerService.deleteLogic(Func.toLongList(ids)));
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置登录用户信息
|
|
|
+ private void setUserData(ConstructionLedger constructionLedger, boolean isCreate){
|
|
|
+ //获取当前登录人
|
|
|
+ BladeUser user = AuthUtil.getUser();
|
|
|
+ //记录操作人信息
|
|
|
+ if(isCreate){
|
|
|
+ constructionLedger.setCreateUser(user.getUserId());
|
|
|
+ constructionLedger.setCreateDept(Long.parseLong(user.getDeptId()));
|
|
|
+ } else {
|
|
|
+ constructionLedger.setUpdateUser(user.getUserId());
|
|
|
+ constructionLedger.setUpdateTime(new Date());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|