Pārlūkot izejas kodu

资金账号新建

songyang 2 gadi atpakaļ
vecāks
revīzija
f351a1fc1d

+ 46 - 5
src/main/java/com/dk/mdm/controller/mst/MoneyAccountController.java

@@ -3,16 +3,13 @@ package com.dk.mdm.controller.mst;
 import com.dk.common.model.pojo.PageList;
 import com.dk.common.response.ResponseResultVO;
 import com.dk.mdm.model.pojo.mst.MoneyAccount;
-import com.dk.common.controller.BaseController;
 import com.dk.common.service.BaseService;
 import com.dk.mdm.model.query.mst.MoneyAccountQuery;
 import com.dk.mdm.model.response.mst.MoneyAccountResponse;
+import com.dk.mdm.model.vo.mst.MoneyAccountVO;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RestController;
 import io.swagger.annotations.Api;
 import com.dk.mdm.service.mst.MoneyAccountService;
 
@@ -39,4 +36,48 @@ public class MoneyAccountController{
         return moneyAccountService.selectByCond(moneyAccountQuery);
     }
 
+    /**
+     * @desc : 新建资金账户
+     * @author : songy
+     * @date : 2023/2/29 10:48
+     */
+    @ApiOperation(value = "新建资金账户", notes = "新建资金账户")
+    @PostMapping({"insert"})
+    public ResponseResultVO<?> insert(@RequestBody MoneyAccountVO moneyAccountVO) {
+        return moneyAccountService.insert(moneyAccountVO);
+    }
+
+    /**
+     * @desc : 编辑员工
+     * @author : songy
+     * @date : 2023/2/29 10:49
+     */
+    @ApiOperation(value = "编辑资金账户", notes = "编辑资金账户")
+    @PostMapping({"update"})
+    public ResponseResultVO<Boolean> update(@RequestBody MoneyAccountVO moneyAccountVO) {
+        return moneyAccountService.update(moneyAccountVO);
+    }
+
+    /**
+     * @desc : 停用
+     * @author : songy
+     * @date : 2023/2/29 10:34
+     */
+    @ApiOperation(value = "停用", notes = "停用")
+    @PostMapping("disable/{id}")
+    public ResponseResultVO<Boolean> disable(@PathVariable String id) {
+        return this.getService().disable(id);
+    }
+
+    /**
+     * @desc : 启用
+     * @author : songy
+     * @date : 2023/2/29 10:34
+     */
+    @ApiOperation(value = "启用", notes = "启用")
+    @PostMapping("enable/{id}")
+    public ResponseResultVO<Boolean> enable(@PathVariable String id) {
+        return this.getService().enable(id);
+    }
+
 }

+ 2 - 1
src/main/java/com/dk/mdm/generator/Generator.java

@@ -53,7 +53,7 @@ public class Generator {
         GlobalConfig gc = new GlobalConfig();
         String projectPath = System.getProperty("user.dir");    //获取当前目录
         gc.setOutputDir(projectPath+"/src/main/java");          //输出到哪个目录
-        gc.setAuthor("姜永辉");                                    //作者
+        gc.setAuthor("宋杨");                                    //作者
         gc.setOpen(false);                                      //是否打开目录
         gc.setFileOverride(false);                              //是否覆盖
         gc.setServiceName("%sService");                         //去Service的I前缀
@@ -96,6 +96,7 @@ public class Generator {
         StrategyConfig strategy = new StrategyConfig();
         strategy.setTablePrefix("t_mst");                                             //表名前缀
         strategy.setInclude("t_mst_supplier");                                        //设置要映射的表名,只需改这里即可,可以是一个数组,一次性生成多张表。
+        strategy.setInclude("t_mst_money_account");                                        //设置要映射的表名,只需改这里即可,可以是一个数组,一次性生成多张表。
         strategy.setNaming(NamingStrategy.underline_to_camel);                      //转驼峰
         strategy.setColumnNaming(NamingStrategy.underline_to_camel);                //字段下划线转驼峰
         strategy.setEntityLombokModel(true);                                        //是否使用lombok开启注解

+ 22 - 0
src/main/java/com/dk/mdm/infrastructure/convert/mst/MoneyAccountConvert.java

@@ -0,0 +1,22 @@
+package com.dk.mdm.infrastructure.convert.mst;
+
+import com.dk.mdm.model.pojo.mst.MoneyAccount;
+import com.dk.mdm.model.vo.mst.MoneyAccountVO;
+import org.mapstruct.Mapper;
+
+/**
+ * @desc   : Staff转换类
+ * @author : admin
+ * @date   : 2023/1/9 10:37
+ */
+@Mapper(componentModel = "spring")
+public interface MoneyAccountConvert {
+
+    /**
+     * @desc   : 转换vo为pojo
+     * @author : admin
+     * @date   : 2023/1/9 10:37
+     */
+    MoneyAccount convertToPo(MoneyAccountVO moneyAccountVO);
+
+}

+ 43 - 4
src/main/java/com/dk/mdm/service/mst/MoneyAccountService.java

@@ -1,20 +1,26 @@
 package com.dk.mdm.service.mst;
 
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.dk.common.infrastructure.annotaiton.Pagination;
 import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
-import com.dk.mdm.infrastructure.convert.mst.StaffConvert;
-import com.dk.mdm.mapper.mst.StaffMapper;
+import com.dk.mdm.infrastructure.convert.mst.MoneyAccountConvert;
 import com.dk.mdm.model.pojo.mst.MoneyAccount;
 import com.dk.mdm.mapper.mst.MoneyAccountMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.mdm.model.pojo.mst.Staff;
 import com.dk.mdm.model.query.mst.MoneyAccountQuery;
 import com.dk.mdm.model.response.mst.MoneyAccountResponse;
+import com.dk.mdm.model.vo.mst.MoneyAccountVO;
+import com.dk.mdm.model.vo.mst.StaffVO;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.UUID;
+
 @Service
 @Transactional
 public class MoneyAccountService extends BaseService<MoneyAccount> {
@@ -27,6 +33,9 @@ public class MoneyAccountService extends BaseService<MoneyAccount> {
 	@Autowired
 	private MoneyAccountMapper moneyAccountMapper;
 
+	@Autowired
+	private MoneyAccountConvert moneyAccountConvert;
+
 	/**
 	 * @desc   : 重写主键
 	 * @author : songy
@@ -34,18 +43,48 @@ public class MoneyAccountService extends BaseService<MoneyAccount> {
 	 */
 	@Override
 	public String getPrimaryKey() {
-		return "staff_id";
+		return "moneyAccount_id";
 	}
 
 
 	/**
 	 * @desc   : 条件查询
 	 * @author : songy
-	 * @date   : 2023/1/9 10:40
+	 * @date   : 2023/2/29 10:40
 	 */
 	@Pagination
 	public ResponseResultVO<PageList<MoneyAccountResponse>> selectByCond(MoneyAccountQuery moneyAccountQuery) {
 		return super.mergeListWithCount(moneyAccountQuery, moneyAccountMapper.selectByCond(moneyAccountQuery),
 				moneyAccountMapper.countByCond(moneyAccountQuery));
 	}
+
+	/**
+	 * @desc : 保存方法
+	 * @author : songy
+	 * @date : 2023/2/29 10:49
+	 */
+	@Transactional(
+			rollbackFor = {Exception.class}
+	)
+	public ResponseResultVO<?> insert(MoneyAccountVO moneyAccountVO) {
+		// 转化实体
+		MoneyAccount moneyAccount = moneyAccountConvert.convertToPo(moneyAccountVO);
+
+		return super.insert(moneyAccount);
+	}
+
+	/**
+	 * @desc : 编辑方法
+	 * @author : songy
+	 * @date : 2023/2/29 10:49
+	 */
+	@Transactional(
+			rollbackFor = {Exception.class}
+	)
+	public ResponseResultVO<Boolean> update(MoneyAccountVO moneyAccountVO) {
+		// 转化实体
+		MoneyAccount moneyAccount = moneyAccountConvert.convertToPo(moneyAccountVO);
+		return ResponseResultUtil.success(super.update(moneyAccount, new UpdateWrapper<MoneyAccount>().lambda().eq(MoneyAccount::getMacId,
+				UUID.fromString(moneyAccount.getMacId()))));
+	}
 }