12.9修改

This commit is contained in:
赵辉
2025-12-10 09:21:33 +08:00
parent 0b361ba2b7
commit 7b10ff2b25
8 changed files with 468 additions and 0 deletions
@@ -0,0 +1,100 @@
package com.linke.finance.application.server.receivingAccount;
import com.linke.finance.domain.receivingAccount.entity.ReceivingAccount;
import com.linke.finance.domain.receivingAccount.repository.persistence.ReceivingAccountRepository;
import com.linke.finance.domain.receivingAccount.repository.po.ReceivingAccountPO;
import com.linke.finance.domain.receivingAccount.repository.todo.ReceivingAccountDO;
import com.mhd.common.core.utils.bean.BeanUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 收款账户ApplicationService
*
* @author system
* @date 2025-12-06
*/
@Service
@Slf4j
public class ReceivingAccountApplicationService {
@Resource
private ReceivingAccountRepository receivingAccountRepository;
/**
* 查询收款账户列表
*
* @param receivingAccountDO 查询条件
* @return 收款账户列表
*/
public List<ReceivingAccountPO> queryList(ReceivingAccountDO receivingAccountDO) {
log.info("查询收款账户列表,查询条件:{}", receivingAccountDO);
return receivingAccountRepository.queryList(receivingAccountDO);
}
/**
* 新增收款账户
*
* @param receivingAccountDTO 收款账户DTO
* @return 是否成功
*/
public Boolean insert(ReceivingAccountDO receivingAccountDTO) {
log.info("新增收款账户,参数:{}", receivingAccountDTO);
ReceivingAccount receivingAccount = new ReceivingAccount();
BeanUtils.copyProperties(receivingAccountDTO, receivingAccount);
receivingAccount.setDelFlag(1); // 1-正常
receivingAccount.setCreateTime(new Date());
receivingAccount.setUpdateTime(new Date());
int result = receivingAccountRepository.insert(receivingAccount);
return result > 0;
}
/**
* 批量新增收款账户(先删除所有,再新增)
*
* @param receivingAccountDTOList 收款账户DTO列表
* @return 是否成功
*/
@Transactional
public Boolean batchInsert(List<ReceivingAccountDO> receivingAccountDTOList) {
log.info("批量新增收款账户,数量:{}", receivingAccountDTOList.size());
// 先删除所有现有数据
int deleteCount = receivingAccountRepository.deleteAll();
log.info("已删除现有收款账户数量:{}", deleteCount);
List<ReceivingAccount> receivingAccountList = new ArrayList<>();
Date now = new Date();
for (ReceivingAccountDO dto : receivingAccountDTOList) {
ReceivingAccount receivingAccount = new ReceivingAccount();
BeanUtils.copyProperties(dto, receivingAccount);
receivingAccount.setDelFlag(1); // 1-正常
receivingAccount.setCreateTime(now);
receivingAccount.setUpdateTime(now);
receivingAccountList.add(receivingAccount);
}
int result = receivingAccountRepository.batchInsert(receivingAccountList);
log.info("新增收款账户数量:{}", result);
return result > 0;
}
/**
* 根据ID删除收款账户
*
* @param id 主键ID
* @return 是否成功
*/
public Boolean deleteById(Long id) {
log.info("删除收款账户,ID{}", id);
int result = receivingAccountRepository.deleteById(id);
return result > 0;
}
}
@@ -0,0 +1,38 @@
package com.linke.finance.domain.receivingAccount.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.mhd.common.core.web.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* 收款账户实体类
*
* @author system
* @date 2025-12-06
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("receiving_account")
public class ReceivingAccount extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/** 主键ID */
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/** 账户名称 */
private String accountName;
/** 账户信息 */
private String accountInformation;
/** 删除标记:1-正常,2-已删除 */
private Integer delFlag;
}
@@ -0,0 +1,56 @@
package com.linke.finance.domain.receivingAccount.repository.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linke.finance.domain.receivingAccount.entity.ReceivingAccount;
import com.linke.finance.domain.receivingAccount.repository.po.ReceivingAccountPO;
import com.linke.finance.domain.receivingAccount.repository.todo.ReceivingAccountDO;
import java.util.List;
/**
* 收款账户Mapper接口
*
* @author system
* @date 2025-12-06
*/
public interface ReceivingAccountMapper extends BaseMapper<ReceivingAccount> {
/**
* 查询收款账户列表
*
* @param receivingAccountDO 查询条件
* @return 收款账户列表
*/
List<ReceivingAccountPO> queryList(ReceivingAccountDO receivingAccountDO);
/**
* 新增收款账户
*
* @param receivingAccount 收款账户
* @return 影响行数
*/
int insert(ReceivingAccount receivingAccount);
/**
* 批量新增收款账户
*
* @param receivingAccountList 收款账户列表
* @return 影响行数
*/
int batchInsert(List<ReceivingAccount> receivingAccountList);
/**
* 删除所有收款账户
*
* @return 影响行数
*/
int deleteAll();
/**
* 根据ID删除收款账户
*
* @param id 主键ID
* @return 影响行数
*/
int deleteById(Long id);
}
@@ -0,0 +1,72 @@
package com.linke.finance.domain.receivingAccount.repository.persistence;
import com.linke.finance.domain.receivingAccount.entity.ReceivingAccount;
import com.linke.finance.domain.receivingAccount.repository.mapper.ReceivingAccountMapper;
import com.linke.finance.domain.receivingAccount.repository.po.ReceivingAccountPO;
import com.linke.finance.domain.receivingAccount.repository.todo.ReceivingAccountDO;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.util.List;
/**
* 收款账户Repository
*
* @author system
* @date 2025-12-06
*/
@Repository
public class ReceivingAccountRepository {
@Resource
private ReceivingAccountMapper receivingAccountMapper;
/**
* 查询收款账户列表
*
* @param receivingAccountDO 查询条件
* @return 收款账户列表
*/
public List<ReceivingAccountPO> queryList(ReceivingAccountDO receivingAccountDO) {
return receivingAccountMapper.queryList(receivingAccountDO);
}
/**
* 新增收款账户
*
* @param receivingAccount 收款账户
* @return 影响行数
*/
public int insert(ReceivingAccount receivingAccount) {
return receivingAccountMapper.insert(receivingAccount);
}
/**
* 批量新增收款账户
*
* @param receivingAccountList 收款账户列表
* @return 影响行数
*/
public int batchInsert(List<ReceivingAccount> receivingAccountList) {
return receivingAccountMapper.batchInsert(receivingAccountList);
}
/**
* 删除所有收款账户
*
* @return 影响行数
*/
public int deleteAll() {
return receivingAccountMapper.deleteAll();
}
/**
* 根据ID删除收款账户
*
* @param id 主键ID
* @return 影响行数
*/
public int deleteById(Long id) {
return receivingAccountMapper.deleteById(id);
}
}
@@ -0,0 +1,47 @@
package com.linke.finance.domain.receivingAccount.repository.po;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* 收款账户响应对象
*
* @author system
* @date 2025-12-06
*/
@Data
@ApiModel(value = "收款账户对象", description = "收款账户响应对象")
public class ReceivingAccountPO extends BaseVOEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键ID")
private Long id;
@ApiModelProperty("账户名称")
@Excel(name = "账户名称")
private String accountName;
@ApiModelProperty("账户信息")
@Excel(name = "账户信息")
private String accountInformation;
@ApiModelProperty("删除标记:1-正常,2-已删除")
private Integer delFlag;
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@ApiModelProperty("更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
}
@@ -0,0 +1,29 @@
package com.linke.finance.domain.receivingAccount.repository.todo;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 收款账户查询对象
*
* @author system
* @date 2025-12-06
*/
@Data
public class ReceivingAccountDO extends BaseVOEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键ID")
private Long id;
@ApiModelProperty("账户名称")
private String accountName;
@ApiModelProperty("账户信息")
private String accountInformation;
@ApiModelProperty("删除标记:1-正常,2-已删除")
private Integer delFlag;
}
@@ -0,0 +1,39 @@
package com.linke.finance.interfaces.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* 收款账户DTO
*
* @author system
* @date 2025-12-06
*/
@Data
public class ReceivingAccountDTO {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键ID")
private Long id;
@ApiModelProperty("账户名称")
private String accountName;
@ApiModelProperty("账户信息")
private String accountInformation;
@ApiModelProperty("删除标记:1-正常,2-已删除")
private Integer delFlag;
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@ApiModelProperty("更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
@@ -0,0 +1,87 @@
<?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.linke.finance.domain.receivingAccount.repository.mapper.ReceivingAccountMapper">
<resultMap type="com.linke.finance.domain.receivingAccount.repository.po.ReceivingAccountPO" id="ReceivingAccountResult">
<result property="id" column="id" />
<result property="accountName" column="account_name" />
<result property="accountInformation" column="account_information" />
<result property="delFlag" column="del_flag" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectReceivingAccountPo">
select id, account_name, account_information, del_flag, create_time, update_time
from receiving_account
</sql>
<sql id="selectReceivingAccountWhere">
<where>
and del_flag = 1
<if test="id != null">
and id = #{id}
</if>
<if test="accountName != null and accountName != ''">
and account_name like concat('%', #{accountName}, '%')
</if>
<if test="accountInformation != null and accountInformation != ''">
and account_information like concat('%', #{accountInformation}, '%')
</if>
order by create_time desc
</where>
</sql>
<select id="queryList" parameterType="com.linke.finance.domain.receivingAccount.repository.todo.ReceivingAccountDO" resultMap="ReceivingAccountResult">
<include refid="selectReceivingAccountPo"/>
<include refid="selectReceivingAccountWhere"/>
</select>
<insert id="insert" parameterType="com.linke.finance.domain.receivingAccount.entity.ReceivingAccount">
insert into receiving_account
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="accountName != null and accountName != ''">account_name,</if>
<if test="accountInformation != null and accountInformation != ''">account_information,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="accountName != null and accountName != ''">#{accountName},</if>
<if test="accountInformation != null and accountInformation != ''">#{accountInformation},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<insert id="batchInsert" parameterType="java.util.List">
insert into receiving_account (account_name, account_information, del_flag, create_time, update_time)
values
<foreach collection="list" item="item" separator=",">
(
#{item.accountName},
#{item.accountInformation},
#{item.delFlag},
#{item.createTime},
#{item.updateTime}
)
</foreach>
</insert>
<update id="deleteById" parameterType="Long">
update receiving_account
set del_flag = 2,
update_time = now()
where id = #{id}
</update>
<update id="deleteAll">
update receiving_account
set del_flag = 2,
update_time = now()
where del_flag = 1
</update>
</mapper>