Browse Source

新增报销帐号表

anderx 2 years ago
parent
commit
f373e70bf1

+ 0 - 17
src/main/java/com/goafanti/common/dao/ExpenseAccountAccountsMapper.java

@@ -1,17 +0,0 @@
-package com.goafanti.common.dao;
-
-import com.goafanti.common.model.ExpenseAccountAccounts;
-
-public interface ExpenseAccountAccountsMapper {
-    int deleteByPrimaryKey(Integer id);
-
-    int insert(ExpenseAccountAccounts record);
-
-    int insertSelective(ExpenseAccountAccounts record);
-
-    ExpenseAccountAccounts selectByPrimaryKey(Integer id);
-
-    int updateByPrimaryKeySelective(ExpenseAccountAccounts record);
-
-    int updateByPrimaryKey(ExpenseAccountAccounts record);
-}

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

@@ -0,0 +1,19 @@
+package com.goafanti.common.dao;
+
+import com.goafanti.common.model.ExpenseAccountPrivate;
+
+public interface ExpenseAccountPrivateMapper {
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(ExpenseAccountPrivate record);
+
+    int insertSelective(ExpenseAccountPrivate record);
+
+    ExpenseAccountPrivate selectByPrimaryKey(Integer id);
+
+    int updateByPrimaryKeySelective(ExpenseAccountPrivate record);
+
+    int updateByPrimaryKey(ExpenseAccountPrivate record);
+
+    Integer checkAid(String aid);
+}

+ 23 - 17
src/main/java/com/goafanti/common/mapper/ExpenseAccountAccountsMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.goafanti.common.dao.ExpenseAccountAccountsMapper">
-  <resultMap id="BaseResultMap" type="com.goafanti.common.model.ExpenseAccountAccounts">
+<mapper namespace="com.goafanti.common.dao.ExpenseAccountPrivateMapper">
+  <resultMap id="BaseResultMap" type="com.goafanti.common.model.ExpenseAccountPrivate">
     <id column="id" jdbcType="INTEGER" property="id" />
     <result column="aid" jdbcType="VARCHAR" property="aid" />
     <result column="name" jdbcType="VARCHAR" property="name" />
@@ -15,25 +15,26 @@
     id, aid, `name`, bank, accounts, open_bank, `status`, create_time
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
-    select 
+    select
     <include refid="Base_Column_List" />
-    from expense_account_accounts
+    from expense_account_private
     where id = #{id,jdbcType=INTEGER}
   </select>
+
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
-    delete from expense_account_accounts
+    delete from expense_account_private
     where id = #{id,jdbcType=INTEGER}
   </delete>
-  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccountAccounts" useGeneratedKeys="true">
-    insert into expense_account_accounts (aid, `name`, bank, 
-      accounts, open_bank, `status`, 
+  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccountPrivate" useGeneratedKeys="true">
+    insert into expense_account_private (aid, `name`, bank,
+      accounts, open_bank, `status`,
       create_time)
-    values (#{aid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{bank,jdbcType=VARCHAR}, 
-      #{accounts,jdbcType=VARCHAR}, #{openBank,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, 
+    values (#{aid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{bank,jdbcType=VARCHAR},
+      #{accounts,jdbcType=VARCHAR}, #{openBank,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
       #{createTime,jdbcType=TIMESTAMP})
   </insert>
-  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccountAccounts" useGeneratedKeys="true">
-    insert into expense_account_accounts
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccountPrivate" useGeneratedKeys="true">
+    insert into expense_account_private
     <trim prefix="(" suffix=")" suffixOverrides=",">
       <if test="aid != null">
         aid,
@@ -81,8 +82,8 @@
       </if>
     </trim>
   </insert>
-  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.ExpenseAccountAccounts">
-    update expense_account_accounts
+  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.ExpenseAccountPrivate">
+    update expense_account_private
     <set>
       <if test="aid != null">
         aid = #{aid,jdbcType=VARCHAR},
@@ -108,8 +109,8 @@
     </set>
     where id = #{id,jdbcType=INTEGER}
   </update>
-  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.ExpenseAccountAccounts">
-    update expense_account_accounts
+  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.ExpenseAccountPrivate">
+    update expense_account_private
     set aid = #{aid,jdbcType=VARCHAR},
       `name` = #{name,jdbcType=VARCHAR},
       bank = #{bank,jdbcType=VARCHAR},
@@ -119,4 +120,9 @@
       create_time = #{createTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=INTEGER}
   </update>
-</mapper>
+
+  <select id="checkAid" resultType="java.lang.Integer">
+    select count(*) from expense_account_private
+    where status=1 and aid =#{aid}
+  </select>
+</mapper>

+ 2 - 2
src/main/java/com/goafanti/common/model/ExpenseAccountAccounts.java

@@ -4,10 +4,10 @@ import java.io.Serializable;
 import java.util.Date;
 
 /**
- * expense_account_accounts
+ * expense_account_private
  * @author 
  */
-public class ExpenseAccountAccounts implements Serializable {
+public class ExpenseAccountPrivate implements Serializable {
     private Integer id;
 
     /**

+ 29 - 0
src/main/java/com/goafanti/expenseAccount/bo/InputExpenseAccountPrivate.java

@@ -0,0 +1,29 @@
+package com.goafanti.expenseAccount.bo;
+
+import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.model.ExpenseAccountPrivate;
+import com.goafanti.common.utils.Param;
+
+import javax.validation.constraints.NotNull;
+
+public class InputExpenseAccountPrivate extends ExpenseAccountPrivate {
+
+    @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "报销帐号")
+    private String aid;
+    @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "帐号名称")
+    private String name;
+    @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "银行名称")
+    private String bank;
+    @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "帐号")
+    private String accounts;
+    @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
+    @Param(name = "开户行名称")
+    private String open_bank;
+
+
+
+}

+ 36 - 0
src/main/java/com/goafanti/expenseAccount/controller/ExpenseAccountController.java

@@ -0,0 +1,36 @@
+package com.goafanti.expenseAccount.controller;
+
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.controller.CertifyApiController;
+import com.goafanti.common.utils.ParamUtils;
+import com.goafanti.expenseAccount.bo.InputExpenseAccountPrivate;
+import com.goafanti.expenseAccount.service.ExpenseAccountService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@RequestMapping("/api/admin/expenseAccount")
+public class ExpenseAccountController extends CertifyApiController {
+
+    @Autowired
+    private ExpenseAccountService expenseAccountService;
+
+    /**
+     * 新增私有报销帐号
+     * @param in
+     * @return
+     */
+    @RequestMapping(value = "/add",method = RequestMethod.POST)
+    public Result add(@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;
+        }
+        res.setData(expenseAccountService.add(in));
+        return res;
+    }
+}

+ 7 - 0
src/main/java/com/goafanti/expenseAccount/service/ExpenseAccountService.java

@@ -0,0 +1,7 @@
+package com.goafanti.expenseAccount.service;
+
+import com.goafanti.expenseAccount.bo.InputExpenseAccountPrivate;
+
+public interface ExpenseAccountService {
+    int add(InputExpenseAccountPrivate in);
+}

+ 28 - 0
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountServiceImpl.java

@@ -0,0 +1,28 @@
+package com.goafanti.expenseAccount.service.impl;
+
+import com.goafanti.common.dao.ExpenseAccountPrivateMapper;
+import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.expenseAccount.bo.InputExpenseAccountPrivate;
+import com.goafanti.expenseAccount.service.ExpenseAccountService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ExpenseAccountServiceImpl implements ExpenseAccountService {
+
+    @Autowired
+    private ExpenseAccountPrivateMapper expenseAccountPrivateMapper;
+
+    @Override
+    public int add(InputExpenseAccountPrivate in) {
+        String aid= TokenManager.getAdminId();
+        Integer defaultCount=0;
+         defaultCount= expenseAccountPrivateMapper.checkAid(aid);
+         if (defaultCount>0){
+             in.setStatus(0);
+         }else {
+             in.setStatus(1);
+         }
+        return expenseAccountPrivateMapper.insertSelective(in);
+    }
+}

+ 4 - 4
src/main/resources/spring/spring-mvc.xml

@@ -60,11 +60,11 @@
 
 	<!-- Handles HTTP GET requests for /assets/** by efficiently serving up
 		static resources in the ${webappRoot}/assets directory -->
-	<mvc:resources mapping="/static/images/**" location="/WEB-INF/images/" />
+<!--	<mvc:resources mapping="/static/images/**" location="/WEB-INF/images/" />-->
 	<mvc:resources mapping="/static/html/**" location="/WEB-INF/html/" />
-	<mvc:resources mapping="/static/**" location="/WEB-INF/build/" />
-	<mvc:resources mapping="/favicon.ico" location="/WEB-INF/assets/favicon.ico" />
-	<mvc:resources mapping="/robots.txt" location="/WEB-INF/assets/robots.txt" />
+<!--	<mvc:resources mapping="/static/**" location="/WEB-INF/build/" />-->
+<!--	<mvc:resources mapping="/favicon.ico" location="/WEB-INF/assets/favicon.ico" />-->
+<!--	<mvc:resources mapping="/robots.txt" location="/WEB-INF/assets/robots.txt" />-->
 
 	<bean id="templateResolver"
         class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver">