Commit 0ee5bdf2 by guojuxing

打款账户接口

parent 23e2bc95
package com.gic.finance.dao.mapper;
import com.gic.finance.entity.TabPayAccount;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabPayAccountMapper {
/**
* 根据主键删除
*
* @param payAccountId 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer payAccountId);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabPayAccount record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabPayAccount record);
/**
* 根据主键查询
*
* @param payAccountId 主键
* @return 实体对象
*/
TabPayAccount selectByPrimaryKey(Integer payAccountId);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabPayAccount record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabPayAccount record);
/**
* 查询列表数据
* @Title: listPayAccount

* @Description:

 * @author guojuxing 

* @return java.util.List<com.gic.finance.entity.TabPayAccount>


 */
List<TabPayAccount> listPayAccount();
/**
* 查询排序值最大的,即排在最末
* @Title: getMaxSort

* @Description:

 * @author guojuxing 

* @return int


 */
int getMaxSort();
int getMinSort();
/**
* 查询排序值前面的记录
* @Title: getPreOfSort

* @Description:

 * @author guojuxing
* @param sort

* @return com.gic.finance.entity.TabPayAccount


 */
TabPayAccount getPreOfSort(@Param("sort") Integer sort);
/**
* 查询排序值后面的记录
* @Title: getNextOfSort

* @Description:

 * @author guojuxing
* @param sort

* @return com.gic.finance.entity.TabPayAccount


 */
TabPayAccount getNextOfSort(@Param("sort")Integer sort);
}
\ No newline at end of file
package com.gic.finance.entity;
import java.util.Date;
/**
* tab_pay_account
*/
public class TabPayAccount {
/**
*
*/
private Integer payAccountId;
/**
* 开户名称
*/
private String accountName;
/**
* 开户银行
*/
private String bank;
/**
* 支行名称
*/
private String branchName;
/**
* 开户账号
*/
private String bankAccount;
/**
* 状态 0 :删除 1:启用 2:停用
*/
private Integer status;
/**
* 排序
*/
private Integer sort;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public Integer getPayAccountId() {
return payAccountId;
}
public void setPayAccountId(Integer payAccountId) {
this.payAccountId = payAccountId;
}
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public String getBank() {
return bank;
}
public void setBank(String bank) {
this.bank = bank;
}
public String getBranchName() {
return branchName;
}
public void setBranchName(String branchName) {
this.branchName = branchName;
}
public String getBankAccount() {
return bankAccount;
}
public void setBankAccount(String bankAccount) {
this.bankAccount = bankAccount;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
package com.gic.finance.service;
import com.gic.finance.dto.PayAccountDTO;
import com.gic.finance.entity.TabPayAccount;
import java.util.List;
/**
* 打款户接口
* @ClassName: PayAccountService

* @Description: 

* @author guojuxing

* @date 2019/8/29 2:49 PM

*/
public interface PayAccountService {
/**
* 新增
* @Title: save

* @Description:

 * @author guojuxing
* @param dto

* @return void


 */
int save(PayAccountDTO dto);
int update(PayAccountDTO dto);
/**
* 查询列表
* @Title: listPayAccount

* @Description:

 * @author guojuxing 

* @return java.util.List<com.gic.finance.dto.PayAccountDTO>


 */
List<PayAccountDTO> listPayAccount();
/**
* 根据主键查询
* @Title: getById

* @Description:

 * @author guojuxing
* @param id

* @return com.gic.finance.entity.TabPayAccount


 */
TabPayAccount getById(Integer id);
/**
* 查询排序值最大的,即排在最末
* @Title: getTheMaxSort

* @Description:

 * @author guojuxing 

* @return int


 */
int getTheMaxSort();
int getMinSort();
/**
* 查询排序值前面的记录
* @Title: getPreOfSort

* @Description:

 * @author guojuxing
* @param sort

* @return com.gic.finance.entity.TabPayAccount


 */
TabPayAccount getPreOfSort(Integer sort);
/**
* 查询排序值后面的记录
* @Title: getNextOfSort

* @Description:

 * @author guojuxing
* @param sort

* @return com.gic.finance.entity.TabPayAccount


 */
TabPayAccount getNextOfSort(Integer sort);
}
package com.gic.finance.service.impl;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.commons.util.EntityUtil;
import com.gic.finance.dao.mapper.TabPayAccountMapper;
import com.gic.finance.dto.PayAccountDTO;
import com.gic.finance.entity.TabPayAccount;
import com.gic.finance.service.PayAccountService;
@Service("payAccountService")
public class PayAccountServiceImpl implements PayAccountService {
@Autowired
private TabPayAccountMapper tabPayAccountMapper;
@Override
public int save(PayAccountDTO dto) {
return tabPayAccountMapper.insert(EntityUtil.changeEntityNew(TabPayAccount.class, dto));
}
@Override
public int update(PayAccountDTO dto) {
dto.setUpdateTime(new Date());
return tabPayAccountMapper.updateByPrimaryKeySelective(EntityUtil.changeEntityNew(TabPayAccount.class, dto));
}
@Override
public List<PayAccountDTO> listPayAccount() {
return EntityUtil.changeEntityListNew(PayAccountDTO.class, tabPayAccountMapper.listPayAccount());
}
@Override
public TabPayAccount getById(Integer id) {
return tabPayAccountMapper.selectByPrimaryKey(id);
}
@Override
public int getTheMaxSort() {
return tabPayAccountMapper.getMaxSort();
}
@Override
public int getMinSort() {
return tabPayAccountMapper.getMinSort();
}
@Override
public TabPayAccount getPreOfSort(Integer sort) {
return null;
}
@Override
public TabPayAccount getNextOfSort(Integer sort) {
return null;
}
}
package com.gic.finance.service.outer.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.utils.valid.ValidParamsUtils;
import com.gic.finance.dto.PayAccountDTO;
import com.gic.finance.entity.TabPayAccount;
import com.gic.finance.service.PayAccountApiService;
import com.gic.finance.service.PayAccountService;
@Service("payAccountApiService")
public class PayAccountApiServiceImpl implements PayAccountApiService {
@Autowired
private PayAccountService payAccountService;
@Override
public ServiceResponse<Void> save(PayAccountDTO dto) {
ServiceResponse paramValid = ValidParamsUtils.allCheckValidate(dto, PayAccountDTO.SavePayAccount.class);
if (!paramValid.isSuccess()) {
return paramValid;
}
dto.setCreateTime(new Date());
dto.setUpdateTime(new Date());
dto.setStatus(1);
//序号
payAccountService.save(dto);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> update(PayAccountDTO dto) {
ServiceResponse paramValid = ValidParamsUtils.allCheckValidate(dto, PayAccountDTO.SavePayAccount.class,
PayAccountDTO.EditPayAccount.class);
if (!paramValid.isSuccess()) {
return paramValid;
}
payAccountService.update(dto);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> delete(Integer id) {
TabPayAccount tab = payAccountService.getById(id);
if (tab == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "参数有误");
}
PayAccountDTO dto = new PayAccountDTO();
dto.setPayAccountId(id);
dto.setStatus(0);
payAccountService.update(dto);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> upSort(Integer id) {
TabPayAccount tab = payAccountService.getById(id);
if (tab == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "参数有误");
}
int minSort = payAccountService.getMinSort();
if (minSort == tab.getSort().intValue()) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "已在最前面,不能上移");
}
TabPayAccount pre = payAccountService.getNextOfSort(tab.getSort());
updateSortValue(id, pre.getSort());
updateSortValue(pre.getPayAccountId(), tab.getSort());
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> downSort(Integer id) {
TabPayAccount tab = payAccountService.getById(id);
if (tab == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "参数有误");
}
int maxSort = payAccountService.getTheMaxSort();
if (maxSort == tab.getSort().intValue()) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "已在最下面,不能下移");
}
TabPayAccount next = payAccountService.getNextOfSort(tab.getSort());
updateSortValue(id, next.getSort());
updateSortValue(next.getPayAccountId(), tab.getSort());
return ServiceResponse.success();
}
@Override
public ServiceResponse<PayAccountDTO> getById(Integer id) {
TabPayAccount tab = payAccountService.getById(id);
if (tab == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "参数有误");
}
return ServiceResponse.success(EntityUtil.changeEntityNew(PayAccountDTO.class, tab));
}
@Override
public ServiceResponse<List<PayAccountDTO>> listPayAccount() {
List<PayAccountDTO> list = payAccountService.listPayAccount();
if (CollectionUtils.isNotEmpty(list)) {
return ServiceResponse.success(list);
}
return ServiceResponse.success(new ArrayList<>());
}
private void updateSortValue(Integer id, Integer sort) {
PayAccountDTO dto = new PayAccountDTO();
dto.setPayAccountId(id);
dto.setSort(sort);
payAccountService.update(dto);
}
}
......@@ -21,5 +21,7 @@
<dubbo:service interface="com.gic.finance.service.InvoiceManageApiService" ref="invoiceManageApiService" timeout="6000" />
<!--开票户信息-->
<dubbo:service interface="com.gic.finance.service.InvoiceAccountApiService" ref="invoiceAccountApiService" timeout="6000" />
<!--打款户信息-->
<dubbo:service interface="com.gic.finance.service.PayAccountApiService" ref="payAccountApiService" timeout="6000" />
</beans>
<?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.gic.finance.dao.mapper.TabPayAccountMapper">
<resultMap id="BaseResultMap" type="com.gic.finance.entity.TabPayAccount">
<id column="pay_account_id" jdbcType="INTEGER" property="payAccountId" />
<result column="account_name" jdbcType="VARCHAR" property="accountName" />
<result column="bank" jdbcType="VARCHAR" property="bank" />
<result column="branch_name" jdbcType="VARCHAR" property="branchName" />
<result column="bank_account" jdbcType="VARCHAR" property="bankAccount" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
pay_account_id, account_name, bank, branch_name, bank_account, status, sort, create_time,
update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_pay_account
where pay_account_id = #{payAccountId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_pay_account
where pay_account_id = #{payAccountId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.finance.entity.TabPayAccount">
insert into tab_pay_account (pay_account_id, account_name, bank,
branch_name, bank_account, status,
sort, create_time, update_time
)
values (#{payAccountId,jdbcType=INTEGER}, #{accountName,jdbcType=VARCHAR}, #{bank,jdbcType=VARCHAR},
#{branchName,jdbcType=VARCHAR}, #{bankAccount,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
#{sort,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.gic.finance.entity.TabPayAccount">
insert into tab_pay_account
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="payAccountId != null">
pay_account_id,
</if>
<if test="accountName != null">
account_name,
</if>
<if test="bank != null">
bank,
</if>
<if test="branchName != null">
branch_name,
</if>
<if test="bankAccount != null">
bank_account,
</if>
<if test="status != null">
status,
</if>
<if test="sort != null">
sort,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="payAccountId != null">
#{payAccountId,jdbcType=INTEGER},
</if>
<if test="accountName != null">
#{accountName,jdbcType=VARCHAR},
</if>
<if test="bank != null">
#{bank,jdbcType=VARCHAR},
</if>
<if test="branchName != null">
#{branchName,jdbcType=VARCHAR},
</if>
<if test="bankAccount != null">
#{bankAccount,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="sort != null">
#{sort,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.finance.entity.TabPayAccount">
update tab_pay_account
<set>
<if test="accountName != null">
account_name = #{accountName,jdbcType=VARCHAR},
</if>
<if test="bank != null">
bank = #{bank,jdbcType=VARCHAR},
</if>
<if test="branchName != null">
branch_name = #{branchName,jdbcType=VARCHAR},
</if>
<if test="bankAccount != null">
bank_account = #{bankAccount,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where pay_account_id = #{payAccountId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.finance.entity.TabPayAccount">
update tab_pay_account
set account_name = #{accountName,jdbcType=VARCHAR},
bank = #{bank,jdbcType=VARCHAR},
branch_name = #{branchName,jdbcType=VARCHAR},
bank_account = #{bankAccount,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
sort = #{sort,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where pay_account_id = #{payAccountId,jdbcType=INTEGER}
</update>
<select id="listPayAccount" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_pay_account
where status != 0
order by sort
</select>
<select id="getMaxSort" resultType="int">
select
max(sort)
from tab_pay_account
where status != 0
</select>
<select id="getMinSort" resultType="int">
select
min(sort)
from tab_pay_account
where status != 0
</select>
<select id="getPreOfSort" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_pay_account
where status != 0
and sort &lt; #{sort}
</select>
<select id="getNextOfSort" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_pay_account
where status != 0
and sort > #{sort}
</select>
</mapper>
\ No newline at end of file
package com.gic.finance.web.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.utils.ResultControllerUtils;
import com.gic.finance.dto.PayAccountDTO;
import com.gic.finance.service.PayAccountApiService;
/**
* 提现管理
* @ClassName: CashWithdrawalController

* @Description: 

* @author guojuxing

* @date 2019/8/29 3:33 PM

*/
@RestController
@RequestMapping("/cash-withdrawal")
public class CashWithdrawalController {
private static Logger LOGGER = LoggerFactory.getLogger(CashWithdrawalController.class);
@Autowired
private PayAccountApiService payAccountApiService;
/**
* 新增打款账户
* @Title: savePayAccount

* @Description:

 * @author guojuxing
* @param dto

* @return com.gic.commons.webapi.reponse.RestResponse


 */
@RequestMapping("/save-pay-account")
public RestResponse savePayAccount(PayAccountDTO dto) {
return ResultControllerUtils.commonResult(payAccountApiService.save(dto));
}
@RequestMapping("/edit-pay-account")
public RestResponse editPayAccount(PayAccountDTO dto) {
return ResultControllerUtils.commonResult(payAccountApiService.update(dto));
}
/**
* 下移排序
* @Title: downSort

* @Description:

 * @author guojuxing
* @param id

* @return com.gic.commons.webapi.reponse.RestResponse


 */
@RequestMapping("/down-sort")
public RestResponse downSort(Integer id) {
return ResultControllerUtils.commonResult(payAccountApiService.downSort(id));
}
@RequestMapping("/up-sort")
public RestResponse upSort(Integer id) {
return ResultControllerUtils.commonResult(payAccountApiService.upSort(id));
}
@RequestMapping("/delete-pay-account")
public RestResponse deletePayAccount(Integer id) {
return ResultControllerUtils.commonResult(payAccountApiService.delete(id));
}
/**
* 详情
* @Title: getDetail

* @Description:

 * @author guojuxing
* @param id

* @return com.gic.commons.webapi.reponse.RestResponse


 */
@RequestMapping("/get-pay-account-detail")
public RestResponse getPayAccountDetail(Integer id) {
return ResultControllerUtils.commonResult(payAccountApiService.getById(id));
}
/**
* 查询列表数据
* @Title: listPayAccount

* @Description:

 * @author guojuxing 

* @return com.gic.commons.webapi.reponse.RestResponse


 */
@RequestMapping("/list-pay-account")
public RestResponse listPayAccount() {
return ResultControllerUtils.commonResult(payAccountApiService.listPayAccount());
}
}
......@@ -42,6 +42,8 @@
<dubbo:reference interface="com.gic.finance.service.InvoiceManageApiService" id="invoiceManageApiService" timeout="60000" />
<!--开票户信息-->
<dubbo:reference interface="com.gic.finance.service.InvoiceAccountApiService" id="invoiceAccountApiService" timeout="60000" />
<!--打款户信息-->
<dubbo:reference interface="com.gic.finance.service.PayAccountApiService" id="payAccountApiService" timeout="60000" />
<dubbo:reference id="gicLogService" interface="com.gic.authcenter.api.service.GicLogService"/>
<dubbo:reference id="gicAppService" interface="com.gic.authcenter.api.service.GicAppService"/>
<dubbo:reference id="gicUserService" interface="com.gic.authcenter.api.service.GicUserService"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment