package cn.huge.module.ctuser.service;
|
|
import cn.huge.base.common.exception.ServiceException;
|
import cn.huge.base.common.utils.DateUtils;
|
import cn.huge.base.common.utils.IdUtils;
|
import cn.huge.base.common.utils.ObjectUtils;
|
import cn.huge.module.constant.BaseConsts;
|
import cn.huge.module.constant.ByBaseConsts;
|
import cn.huge.module.constant.ByUserConsts;
|
import cn.huge.module.ctuser.dao.mapper.CtAccountMapper;
|
import cn.huge.module.ctuser.domain.dto.GZCtAccountDTO;
|
import cn.huge.module.ctuser.domain.dto.GZCtUserDTO;
|
import cn.huge.module.ctuser.domain.po.CtAccount;
|
import cn.huge.module.ctuser.domain.po.Ctuser;
|
import cn.huge.module.cust.constant.UserBaseConsts;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.PageImpl;
|
import org.springframework.data.domain.PageRequest;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.PostConstruct;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @title: 客户用户账号表业务逻辑处理
|
* @Description 客户用户账号表业务逻辑处理
|
* @company hugeinfo
|
* @author liyj
|
* @Time 2024-10-17 17:31:46
|
* @version 1.0.0
|
*/
|
@Slf4j
|
@Service
|
@Transactional(rollbackFor = Exception.class)
|
public class CtAccountService extends ServiceImpl<CtAccountMapper, CtAccount>{
|
|
@Autowired
|
private CtAccountMapper mapper;
|
|
@Autowired
|
private CtuserService ctuserService;
|
|
/**
|
* 更新对象
|
* @param entity 对象
|
*/
|
public void updateCtAccount(CtAccount entity){
|
try{
|
mapper.updateCtAccount(entity);
|
}catch (Exception e){
|
log.error("[CtAccountService.updateCtAccount]调用失败,异常信息:"+e, e);
|
throw new ServiceException("CtAccountService.updateCtAccount", e);
|
}
|
}
|
|
/**
|
* 条件更新对象
|
* @param entity 对象
|
* @param terms 条件
|
*/
|
public void updateCtAccountTerms(CtAccount entity, Map<String, Object> terms){
|
try{
|
mapper.updateCtAccountTerms(entity, terms);
|
}catch (Exception e){
|
log.error("[CtAccountService.updateCtAccountTerms]调用失败,异常信息:"+e, e);
|
throw new ServiceException("CtAccountService.updateCtAccountTerms", e);
|
}
|
}
|
|
/**
|
* 根据编号物理删除
|
* @param id 查询条件集合
|
*/
|
public void deleteCtAccount(String id){
|
try{
|
mapper.deleteCtAccount(id);
|
}catch (Exception e){
|
log.error("[CtAccountService.deleteCtAccount]调用失败,异常信息:"+e, e);
|
throw new ServiceException("CtAccountService.deleteCtAccount", e);
|
}
|
}
|
|
/**
|
* 按条件查询
|
* @param terms 条件
|
* @return List
|
*/
|
public List<CtAccount> listTerms(Map<String, Object> terms){
|
return mapper.listTerms(terms);
|
}
|
|
/**
|
* 按条件统计
|
* @param terms 条件
|
* @return long
|
*/
|
public long countTerms(Map<String, Object> terms){
|
return mapper.countTerms(terms);
|
}
|
|
/**
|
* 按条件分页查询
|
* @param page 分页对象
|
* @param terms 条件
|
* @return Page
|
*/
|
public Page<CtAccount> pageQuery(PageRequest page, Map<String, Object> terms){
|
long total = mapper.countTerms(terms);
|
List<CtAccount> content = mapper.pageTerms(page, terms);
|
return new PageImpl<CtAccount>(content, page, total);
|
}
|
|
/**
|
* 数据割接-账号信息
|
* @return
|
*/
|
public List<GZCtAccountDTO> byToGzCtAccount(){
|
List<GZCtAccountDTO> gzCtAccountDTOList = new ArrayList<>();
|
List<CtAccount> ctAccountList = this.list();
|
for (CtAccount ctAccount: ctAccountList){
|
Ctuser ctuser = ctuserService.getById(ctAccount.getUserId());
|
if (ObjectUtils.isNotEmpty(ctuser)) {
|
GZCtAccountDTO gzCtAccountDTO = new GZCtAccountDTO();
|
BeanUtils.copyProperties(ctAccount, gzCtAccountDTO);
|
// 帐号类型
|
if (ByUserConsts.ACC_TYPE_1.equals(ctAccount.getAccType())){
|
gzCtAccountDTO.setAccType(UserBaseConsts.ACC_TYPE_1);
|
}else if (ByUserConsts.ACC_TYPE_2.equals(ctAccount.getAccType())){
|
gzCtAccountDTO.setAccType(UserBaseConsts.ACC_TYPE_2);
|
}
|
// 映射删除状态
|
if (ByBaseConsts.DELETE_STATUS_1.equals(ctAccount.getDeleteStatus())) {
|
gzCtAccountDTO.setDeleteStatus(BaseConsts.DELETE_STATUS_0);
|
} else {
|
gzCtAccountDTO.setDeleteStatus(BaseConsts.DELETE_STATUS_1);
|
}
|
gzCtAccountDTOList.add(gzCtAccountDTO);
|
}
|
}
|
return gzCtAccountDTOList;
|
}
|
|
}
|