12.9修改
This commit is contained in:
+100
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user