Browse Source

新增私有报销帐号列表

anderx 2 years ago
parent
commit
e76bfed0dc

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

@@ -3,6 +3,7 @@ package com.goafanti.expenseAccount.controller;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.CertifyApiController;
+import com.goafanti.common.model.ExpenseAccountPrivate;
 import com.goafanti.common.utils.ParamUtils;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.expenseAccount.bo.InputExpenseAccountPrivate;
@@ -51,6 +52,10 @@ public class ExpenseAccountController extends CertifyApiController {
     @RequestMapping(value = "/update",method = RequestMethod.POST)
     public Result update(@Validated InputExpenseAccountPrivate in , BindingResult bindingResult){
         Result res =new Result();
+        if (in.getId()==null){
+            res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"我的报销帐号编号"));
+            return res;
+        }
         if (bindingResult.hasErrors()) {
             res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
                     ParamUtils.getParamName(in,bindingResult.getFieldError().getField())));
@@ -64,12 +69,21 @@ public class ExpenseAccountController extends CertifyApiController {
         res.setData(expenseAccountPrivateService.update(in));
         return res;
     }
-
     /**
      * 私有报销帐号列表
      * @return
      */
     @RequestMapping(value = "/selectList",method = RequestMethod.POST)
+    public Result updateStatus(ExpenseAccountPrivate in){
+        Result res =new Result();
+        res.setData(expenseAccountPrivateService.updateStatus(in));
+        return res;
+    }
+    /**
+     * 私有报销帐号列表
+     * @return
+     */
+    @RequestMapping(value = "/selectList",method = RequestMethod.GET)
     public Result selectList(Integer pageSize,Integer pageNo){
         Result res =new Result();
         res.setData(expenseAccountPrivateService.selectList(pageSize,pageNo));

+ 3 - 0
src/main/java/com/goafanti/expenseAccount/service/ExpenseAccountPrivateService.java

@@ -1,5 +1,6 @@
 package com.goafanti.expenseAccount.service;
 
+import com.goafanti.common.model.ExpenseAccountPrivate;
 import com.goafanti.expenseAccount.bo.InputExpenseAccountPrivate;
 
 public interface ExpenseAccountPrivateService {
@@ -13,4 +14,6 @@ public interface ExpenseAccountPrivateService {
     boolean updateCheckAccounts(InputExpenseAccountPrivate in);
 
     boolean addCheckAccounts(InputExpenseAccountPrivate in);
+
+    int updateStatus(ExpenseAccountPrivate in);
 }

+ 14 - 1
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountPrivateServiceImpl.java

@@ -21,6 +21,11 @@ public class ExpenseAccountPrivateServiceImpl extends BaseMybatisDao<ExpenseAcco
 
     @Override
     public int add(InputExpenseAccountPrivate in) {
+        updateStatus(in);
+        return expenseAccountPrivateMapper.insertSelective(in);
+    }
+
+    private void updateStatus(InputExpenseAccountPrivate in) {
         if (in.getStatus()==0){
             Integer defaultCount=chekAccountDefault(in.getAid());
             if (defaultCount>0){
@@ -31,7 +36,6 @@ public class ExpenseAccountPrivateServiceImpl extends BaseMybatisDao<ExpenseAcco
         }else {
             expenseAccountPrivateMapper.updateStatusByAid(in);
         }
-        return expenseAccountPrivateMapper.insertSelective(in);
     }
 
     private Integer chekAccountDefault(String aid) {
@@ -63,6 +67,15 @@ public class ExpenseAccountPrivateServiceImpl extends BaseMybatisDao<ExpenseAcco
 
     }
 
+    @Override
+    public int updateStatus(ExpenseAccountPrivate in) {
+        InputExpenseAccountPrivate update=new InputExpenseAccountPrivate();
+        update.setId(in.getId());
+        update.setStatus(in.getStatus());
+        updateStatus(update);
+        return expenseAccountPrivateMapper.updateByPrimaryKey(update);
+    }
+
     private Integer checkCount(InputExpenseAccountPrivate in) {
         InputExpenseAccountPrivate check=new InputExpenseAccountPrivate();
         check.setAid(in.getAid());