From 7a1ab2693de593026b420fd89b977881eee484ff Mon Sep 17 00:00:00 2001
From: Fancy <Fancy.fx@outlook.com>
Date: 星期三, 16 十月 2024 17:10:48 +0800
Subject: [PATCH] command crud
---
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoTst/TstCommandMapper.java | 41 ++++++
pms-parent/pms-test/src/main/java/com/dy/pmsTest/command/CommandCtrl.java | 130 +++++++++++++++++++++
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoTst/TstCommand.java | 90 +++++++++++++++
pms-parent/pms-test/src/main/java/com/dy/pmsTest/command/CommandSv.java | 79 +++++++++++++
pms-parent/pms-test/src/main/java/com/dy/pmsTest/command/QueryVo.java | 18 +++
5 files changed, 358 insertions(+), 0 deletions(-)
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoTst/TstCommandMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoTst/TstCommandMapper.java
new file mode 100644
index 0000000..73663b9
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoTst/TstCommandMapper.java
@@ -0,0 +1,41 @@
+package com.dy.pmsGlobal.daoTst;
+
+import com.dy.pmsGlobal.pojoTst.TstCommand;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+* @author User
+* @description 閽堝琛ㄣ�恡st_command銆戠殑鏁版嵁搴撴搷浣淢apper
+* @createDate 2024-10-16 15:50:25
+* @Entity com.dy.pmsGlobal.pojoTst.TstCommand
+*/
+@Mapper
+public interface TstCommandMapper {
+
+ int deleteByPrimaryKey(Long id);
+
+ int insert(TstCommand record);
+
+ int insertSelective(TstCommand record);
+
+ int deleteLogicById(Long id);
+
+ TstCommand selectByPrimaryKey(Long id);
+
+ Long selectByNameId(@Param("id") Long id,@Param("proId") Long proId, @Param("name") String name);
+
+ List<TstCommand> selectAll();
+
+ Long selectSomeCount(Map<String,Object> params);
+
+ List<TstCommand> selectSome(Map<String,Object> params);
+
+ int updateByPrimaryKeySelective(TstCommand record);
+
+ int updateByPrimaryKey(TstCommand record);
+
+}
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoTst/TstCommand.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoTst/TstCommand.java
new file mode 100644
index 0000000..8a8121a
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoTst/TstCommand.java
@@ -0,0 +1,90 @@
+package com.dy.pmsGlobal.pojoTst;
+
+import com.alibaba.fastjson2.annotation.JSONField;
+import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+
+import com.dy.common.po.BaseEntity;
+import lombok.*;
+
+/**
+ *
+ * @TableName tst_command
+ */
+@TableName(value ="tst_command", autoResultMap = true)
+@Data
+@Builder
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class TstCommand implements BaseEntity {
+ /**
+ *
+ */
+ @JSONField(serializeUsing= ObjectWriterImplToString.class)
+ @TableId(type = IdType.AUTO)
+ public Long id;
+
+ /**
+ * 浜у搧瀹炰綋缂栧彿
+ */
+ @JSONField(serializeUsing= ObjectWriterImplToString.class)
+ public Long proId;
+
+ /**
+ * 鎸囦护绫诲瀷:娴嬭瘯鎸囦护(1)銆佽缃寚浠�(2)
+ */
+ public Integer type;
+
+ /**
+ * 鎸囦护鍚嶇О
+ */
+ public String name;
+
+ /**
+ * 鎸囦护鍊�
+ */
+ public String value;
+
+ /**
+ * 鏄惁鍒犻櫎锛�1鏄紝0鍚�
+ */
+ public Boolean deleted;
+
+ /**
+ * 澶囨敞
+ */
+ public String remark;
+
+ /**
+ * 鏄惁绂佺敤锛�1鏄紝0鍚�
+ */
+ public Boolean disabled;
+
+ /**
+ * 鍒涘缓浜�
+ */
+ @JSONField(serializeUsing= ObjectWriterImplToString.class)
+ public Long createBy;
+
+ /**
+ * 鍒涘缓鏃堕棿
+ */
+ public Date createDate;
+
+ /**
+ * 鏇存柊浜�
+ */
+ @JSONField(serializeUsing= ObjectWriterImplToString.class)
+ public Long updatedBy;
+
+ /**
+ * 鏇存柊鏃堕棿
+ */
+ public Date updatedDate;
+}
\ No newline at end of file
diff --git a/pms-parent/pms-test/src/main/java/com/dy/pmsTest/command/CommandCtrl.java b/pms-parent/pms-test/src/main/java/com/dy/pmsTest/command/CommandCtrl.java
new file mode 100644
index 0000000..f08f0a1
--- /dev/null
+++ b/pms-parent/pms-test/src/main/java/com/dy/pmsTest/command/CommandCtrl.java
@@ -0,0 +1,130 @@
+package com.dy.pmsTest.command;
+
+import com.alibaba.fastjson2.JSON;
+import com.dy.common.aop.SsoPowerAop;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsGlobal.aop.Log;
+import com.dy.pmsGlobal.pojoTst.TstCommand;
+import jakarta.validation.Valid;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 鎸囦护
+ */
+
+@Slf4j
+@RestController
+@RequestMapping(path="command")
+public class CommandCtrl {
+ private CommandSv sv;
+ @Autowired
+ public void setSv(CommandSv sv){
+ this.sv = sv;
+ }
+
+ /**
+ * 淇濆瓨
+ * @param command
+ * @return
+ */
+ @PostMapping(path="save")
+ @SsoPowerAop(power = "10300005")
+ @Log("淇濆瓨鎸囦护")
+ public BaseResponse<Boolean> save(@RequestBody @Valid TstCommand command){
+ command.disabled = false;
+ command.deleted = false;
+ int count = sv.save(command);
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
+ }
+
+ /**
+ * 鏇存柊
+ * @param command
+ * @return
+ */
+ @PostMapping(path="update")
+ @SsoPowerAop(power = "10300005")
+ @Log("鏇存柊鎸囦护")
+ public BaseResponse<Boolean> update(@RequestBody @Valid TstCommand command){
+ int count = sv.update(command);
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
+ }
+
+ /**
+ * 鍒犻櫎
+ * @param id
+ * @return
+ */
+ @GetMapping(path="delete")
+ @SsoPowerAop(power = "10300005")
+ @Log("鍒犻櫎鎸囦护")
+ public BaseResponse<Boolean> delete(String id){
+ int count = sv.delete(Long.parseLong(id));
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
+ }
+
+ /**
+ * 鏍规嵁ID鏌ヨ
+ * @return
+ */
+ @GetMapping(path="one")
+ @SsoPowerAop(power = "10300004") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @Log("鏍规嵁ID鏌ヨ鎸囦护")
+ public BaseResponse<TstCommand> one(String id){
+ TstCommand param=sv.selectById(id);
+ return BaseResponseUtils.buildSuccess(JSON.toJSON(param));
+ }
+
+ /**
+ * 鍒嗛〉鏌ヨ
+ * @param vo
+ * @return
+ */
+ @PostMapping(path="some")
+ @SsoPowerAop(power = "10300004")
+ @Log("鍒嗛〉鏌ヨ鎸囦护")
+ public BaseResponse<QueryResultVo<List<TstCommand>>> some(@RequestBody QueryVo vo){
+ QueryResultVo<List<TstCommand>> list = sv.selectSome(vo) ;
+ return BaseResponseUtils.buildSuccess(list);
+ }
+
+ /**
+ * 鏌ヨ鎵�鏈�
+ * @return
+ */
+ @GetMapping(path="all")
+ @SsoPowerAop(power = "10300004")
+ @Log("鏌ヨ鎵�鏈夋寚浠�")
+ public BaseResponse<List<TstCommand>> all(){
+ List<TstCommand> list = sv.selectAll();
+
+ return BaseResponseUtils.buildSuccess(list);
+ }
+}
+
+
+
+
+
+
+
+
+
diff --git a/pms-parent/pms-test/src/main/java/com/dy/pmsTest/command/CommandSv.java b/pms-parent/pms-test/src/main/java/com/dy/pmsTest/command/CommandSv.java
new file mode 100644
index 0000000..41d145f
--- /dev/null
+++ b/pms-parent/pms-test/src/main/java/com/dy/pmsTest/command/CommandSv.java
@@ -0,0 +1,79 @@
+package com.dy.pmsTest.command;
+
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsGlobal.daoTst.TstCommandMapper;
+import com.dy.pmsGlobal.pojoTst.TstCommand;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.common.utils.PojoUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class CommandSv {
+ private TstCommandMapper dao;
+
+ @Autowired
+ public void setDao(TstCommandMapper dao) {
+ this.dao = dao;
+ }
+
+ @Transactional
+ public int save(TstCommand command) throws RuntimeException {
+ if(dao.selectByNameId(command.id,command.proId,command.name)>0){
+ throw new RuntimeException("鎸囦护鍚嶇О宸插瓨鍦�");
+ }
+ int count = dao.insertSelective(command);
+ return count;
+ }
+
+ /**
+ * 閫昏緫鍒犻櫎瀹炰綋
+ * @param id 瀹炰綋ID
+ * @return 褰卞搷璁板綍鏁伴噺
+ */
+ @Transactional
+ public int delete(Long id) {
+ return this.dao.deleteLogicById(id);
+ }
+
+
+ @Transactional
+ public int update(TstCommand command) throws RuntimeException {
+ if(dao.selectByNameId(command.id,command.proId,command.name)>0){
+ throw new RuntimeException("鎸囦护鍚嶇О宸插瓨鍦�");
+ }
+ int count = dao.updateByPrimaryKeySelective(command);
+ return count;
+ }
+
+ public TstCommand selectById(String lineId) {
+ return dao.selectByPrimaryKey(Long.valueOf(lineId));
+ }
+
+ /**
+ * 鑾峰彇鍒楄〃
+ */
+ public QueryResultVo<List<TstCommand>> selectSome(QueryVo queryVo) {
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+
+ //鏌ヨ绗﹀悎鏉′欢鐨勮褰曟�绘暟
+ Long itemTotal = this.dao.selectSomeCount(params);
+
+ QueryResultVo<List<TstCommand>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ;
+ //璁$畻鍒嗛〉绛変俊鎭�
+ rsVo.calculateAndSet(itemTotal, params);
+
+ //鏌ヨ绗﹀悎鏉′欢鐨勮褰�
+ rsVo.obj = this.dao.selectSome(params) ;
+ return rsVo ;
+ }
+
+ public List<TstCommand> selectAll() {
+ return dao.selectAll();
+ }
+}
diff --git a/pms-parent/pms-test/src/main/java/com/dy/pmsTest/command/QueryVo.java b/pms-parent/pms-test/src/main/java/com/dy/pmsTest/command/QueryVo.java
new file mode 100644
index 0000000..7131091
--- /dev/null
+++ b/pms-parent/pms-test/src/main/java/com/dy/pmsTest/command/QueryVo.java
@@ -0,0 +1,18 @@
+package com.dy.pmsTest.command;
+
+import com.dy.common.webUtil.QueryConditionVo;
+import lombok.*;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class QueryVo extends QueryConditionVo {
+ public String name;
+
+ public String proId;
+ public String type;
+ public String value;
+}
--
Gitblit v1.8.0