Browse Source

新增私有报销帐号列表

anderx 2 years ago
parent
commit
86551f6a63

+ 2 - 0
src/main/java/com/goafanti/common/dao/ExpenseAccountPrivateMapper.java

@@ -20,4 +20,6 @@ public interface ExpenseAccountPrivateMapper {
 
 
     void updateStatusByAid(InputExpenseAccountPrivate in);
+
+    ExpenseAccountPrivate selectByAccount(String accounts);
 }

+ 7 - 1
src/main/java/com/goafanti/common/mapper/ExpenseAccountPrivateMapper.xml

@@ -150,7 +150,13 @@
     from expense_account_private
     where aid = #{aid}
   </select>
-  <update id="updateStatusByAid">
+    <select id="selectByAccount" resultType="com.goafanti.common.model.ExpenseAccountPrivate">
+      select
+      <include refid="Base_Column_List" />
+      from expense_account_private
+      where accounts = #{accounts}
+    </select>
+    <update id="updateStatusByAid">
     update expense_account_private
     set status=0
     where aid =#{aid}

+ 23 - 1
src/main/java/com/goafanti/expenseAccount/controller/ExpenseAccountController.java

@@ -35,7 +35,7 @@ public class ExpenseAccountController extends CertifyApiController {
             return res;
         }
         in.setAid(TokenManager.getAdminId());
-        if (expenseAccountPrivateService.checkAccounts(in)){
+        if (expenseAccountPrivateService.addCheckAccounts(in)){
             res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_BEING_ERROR,"帐号"));
             return res;
         }
@@ -44,6 +44,28 @@ public class ExpenseAccountController extends CertifyApiController {
     }
 
     /**
+     * 新增私有报销帐号
+     * @param in
+     * @return
+     */
+    @RequestMapping(value = "/update",method = RequestMethod.POST)
+    public Result update(@Validated InputExpenseAccountPrivate in , BindingResult bindingResult){
+        Result res =new Result();
+        if (bindingResult.hasErrors()) {
+            res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
+                    ParamUtils.getParamName(in,bindingResult.getFieldError().getField())));
+            return res;
+        }
+        in.setAid(TokenManager.getAdminId());
+        if (expenseAccountPrivateService.updateCheckAccounts(in)){
+            res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_BEING_ERROR,"帐号"));
+            return res;
+        }
+        res.setData(expenseAccountPrivateService.update(in));
+        return res;
+    }
+
+    /**
      * 私有报销帐号列表
      * @return
      */

+ 6 - 1
src/main/java/com/goafanti/expenseAccount/service/ExpenseAccountPrivateService.java

@@ -7,5 +7,10 @@ public interface ExpenseAccountPrivateService {
 
     Object selectList(Integer pageSize, Integer pageNo);
 
-    boolean checkAccounts(InputExpenseAccountPrivate in);
+
+    int update(InputExpenseAccountPrivate in);
+
+    boolean updateCheckAccounts(InputExpenseAccountPrivate in);
+
+    boolean addCheckAccounts(InputExpenseAccountPrivate in);
 }

+ 26 - 5
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountPrivateServiceImpl.java

@@ -1,6 +1,7 @@
 package com.goafanti.expenseAccount.service.impl;
 
 import com.goafanti.common.dao.ExpenseAccountPrivateMapper;
+import com.goafanti.common.model.ExpenseAccountPrivate;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
@@ -52,11 +53,8 @@ public class ExpenseAccountPrivateServiceImpl extends BaseMybatisDao<ExpenseAcco
     }
 
     @Override
-    public boolean checkAccounts(InputExpenseAccountPrivate in) {
-        InputExpenseAccountPrivate check=new InputExpenseAccountPrivate();
-        check.setAid(in.getAid());
-        check.setAccounts(in.getAccounts());
-        Integer checkCount = expenseAccountPrivateMapper.checkParam(check);
+    public boolean addCheckAccounts(InputExpenseAccountPrivate in) {
+        Integer checkCount =checkCount(in);
         if (checkCount>0){
             return true;
         }else {
@@ -64,4 +62,27 @@ public class ExpenseAccountPrivateServiceImpl extends BaseMybatisDao<ExpenseAcco
         }
 
     }
+
+    private Integer checkCount(InputExpenseAccountPrivate in) {
+        InputExpenseAccountPrivate check=new InputExpenseAccountPrivate();
+        check.setAid(in.getAid());
+        check.setAccounts(in.getAccounts());
+        return expenseAccountPrivateMapper.checkParam(check);
+    }
+
+    @Override
+    public int update(InputExpenseAccountPrivate in) {
+        return 0;
+    }
+
+    @Override
+    public boolean updateCheckAccounts(InputExpenseAccountPrivate in) {
+        ExpenseAccountPrivate accountPrivate = expenseAccountPrivateMapper.selectByAccount(in.getAccounts());
+        if (accountPrivate.getAid().equals(in.getAid())){
+            return false;
+        }else {
+            return true;
+        }
+
+    }
 }