|
|
@@ -0,0 +1,126 @@
|
|
|
+package org.springblade.business.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import org.springblade.business.entity.PrivateStandard;
|
|
|
+import org.springblade.business.service.PrivateStandardService;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.secure.BladeUser;
|
|
|
+import org.springblade.core.secure.utils.SecureUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 规范文件夹及规范文件表(UWbsPrivateStandard)表控制层
|
|
|
+ *
|
|
|
+ * @author makejava
|
|
|
+ * @since 2025-06-10 11:09:22
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("PrivateStandard")
|
|
|
+public class PrivateStandardController {
|
|
|
+ /**
|
|
|
+ * 服务对象
|
|
|
+ */
|
|
|
+ @Resource
|
|
|
+ private PrivateStandardService privateStandardService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询所有数据
|
|
|
+ *
|
|
|
+ * @param query 分页对象
|
|
|
+ * @param uWbsPrivateStandard 查询实体
|
|
|
+ * @return 所有数据
|
|
|
+ */
|
|
|
+ @GetMapping
|
|
|
+ public R<IPage<PrivateStandard>> selectAll(Query query, PrivateStandard uWbsPrivateStandard) {
|
|
|
+ try {
|
|
|
+ Page page = new Page(query.getCurrent(), query.getSize());
|
|
|
+ IPage<PrivateStandard> resultPage = this.privateStandardService.page(page, new QueryWrapper<>(uWbsPrivateStandard));
|
|
|
+ return R.data(resultPage);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 可根据实际需求记录日志或返回特定错误信息
|
|
|
+ return R.fail("查询失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过主键查询单条数据
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return 单条数据
|
|
|
+ */
|
|
|
+ @GetMapping("/getById")
|
|
|
+ public R<PrivateStandard> selectOne(Long id) {
|
|
|
+ PrivateStandard byId = this.privateStandardService.getById(id);
|
|
|
+ return R.data(byId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增数据
|
|
|
+ *
|
|
|
+ * @param uWbsPrivateStandard 实体对象
|
|
|
+ * @return 新增结果
|
|
|
+ */
|
|
|
+ @PostMapping
|
|
|
+ public R<Boolean> insert(@RequestBody @Validated PrivateStandard uWbsPrivateStandard) {
|
|
|
+ uWbsPrivateStandard.setId(SnowFlakeUtil.getId());
|
|
|
+ if (uWbsPrivateStandard.getType() != 1 && uWbsPrivateStandard.getType() != 2) {
|
|
|
+ return R.fail("类型错误");
|
|
|
+ }
|
|
|
+ if (uWbsPrivateStandard.getType() == 1) {
|
|
|
+ uWbsPrivateStandard.setParentId(0L);
|
|
|
+ if (uWbsPrivateStandard.getPrivateId() == null) {
|
|
|
+ return R.fail("节点不能为空");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (uWbsPrivateStandard.getParentId() == null) {
|
|
|
+ return R.fail("父级节点不能为空");
|
|
|
+ }
|
|
|
+ if (uWbsPrivateStandard.getIssueDate() == null) {
|
|
|
+ return R.fail("下达日期不能为空");
|
|
|
+ }
|
|
|
+ if (uWbsPrivateStandard.getActualizeDate() == null) {
|
|
|
+ return R.fail("实施日期不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BladeUser user = SecureUtil.getUser();
|
|
|
+ uWbsPrivateStandard.setCreateUser(user.getUserId());
|
|
|
+ boolean save = this.privateStandardService.save(uWbsPrivateStandard);
|
|
|
+ return R.data(save);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改数据
|
|
|
+ *
|
|
|
+ * @param uWbsPrivateStandard 实体对象
|
|
|
+ * @return 修改结果
|
|
|
+ */
|
|
|
+ @PutMapping
|
|
|
+ public R<Boolean> update(@RequestBody @Validated PrivateStandard uWbsPrivateStandard) {
|
|
|
+ BladeUser user = SecureUtil.getUser();
|
|
|
+ uWbsPrivateStandard.setUpdateUser(user.getUserId());
|
|
|
+ boolean b = this.privateStandardService.updateById(uWbsPrivateStandard);
|
|
|
+ return R.data(b);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除数据
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return 删除结果
|
|
|
+ */
|
|
|
+ @GetMapping("/delete")
|
|
|
+ public R<Boolean> delete(Long id) {
|
|
|
+ boolean b = this.privateStandardService.delete(id);
|
|
|
+ return R.data(b);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|