feat(oa/crm): 新增供应商信息管理模块

- 新增供应商信息实体类 CrmSupplierInfo 及相关字段定义
- 新增供应商信息业务对象 CrmSupplierInfoBo 并配置校验规则
- 新增供应商信息视图对象 CrmSupplierInfoVo 支持Excel导出- 新增供应商信息控制器 CrmSupplierInfoController 实现CRUD接口
- 新增供应商信息Mapper接口及XML映射文件
- 新增供应商信息服务实现类 CrmSupplierInfoServiceImpl
- 支持附件信息填充与远程文件关联展示
- 提供分页查询、详情查看、新增、修改、删除功能
- 支持供应商信息导出Excel功能
- 添加权限控制注解确保接口安全性- 实现下拉框查询供应商信息列表接口
dev
zangch@mesnac.com 1 month ago
parent 9b4d00a042
commit 7b444396d5

@ -0,0 +1,116 @@
package org.dromara.oa.crm.controller;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.oa.crm.domain.vo.CrmSupplierInfoVo;
import org.dromara.oa.crm.domain.bo.CrmSupplierInfoBo;
import org.dromara.oa.crm.service.ICrmSupplierInfoService;
import org.dromara.common.mybatis.core.page.TableDataInfo;
/**
*
* 访:/oa/crm/crmSupplierInfo
*
* @author Yinq
* @date 2025-11-05
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/crm/crmSupplierInfo")
public class CrmSupplierInfoController extends BaseController {
private final ICrmSupplierInfoService crmSupplierInfoService;
/**
*
*/
@SaCheckPermission("oa/crm:crmSupplierInfo:list")
@GetMapping("/list")
public TableDataInfo<CrmSupplierInfoVo> list(CrmSupplierInfoBo bo, PageQuery pageQuery) {
return crmSupplierInfoService.queryPageList(bo, pageQuery);
}
/**
*
*/
@SaCheckPermission("oa/crm:crmSupplierInfo:export")
@Log(title = "供应商信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(CrmSupplierInfoBo bo, HttpServletResponse response) {
List<CrmSupplierInfoVo> list = crmSupplierInfoService.queryList(bo);
ExcelUtil.exportExcel(list, "供应商信息", CrmSupplierInfoVo.class, response);
}
/**
*
*
* @param supplierId
*/
@SaCheckPermission("oa/crm:crmSupplierInfo:query")
@GetMapping("/{supplierId}")
public R<CrmSupplierInfoVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable("supplierId") Long supplierId) {
return R.ok(crmSupplierInfoService.queryById(supplierId));
}
/**
*
*/
@SaCheckPermission("oa/crm:crmSupplierInfo:add")
@Log(title = "供应商信息", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody CrmSupplierInfoBo bo) {
return toAjax(crmSupplierInfoService.insertByBo(bo));
}
/**
*
*/
@SaCheckPermission("oa/crm:crmSupplierInfo:edit")
@Log(title = "供应商信息", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody CrmSupplierInfoBo bo) {
return toAjax(crmSupplierInfoService.updateByBo(bo));
}
/**
*
*
* @param supplierIds
*/
@SaCheckPermission("oa/crm:crmSupplierInfo:remove")
@Log(title = "供应商信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{supplierIds}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable("supplierIds") Long[] supplierIds) {
return toAjax(crmSupplierInfoService.deleteWithValidByIds(List.of(supplierIds), true));
}
/**
*
*/
@GetMapping("/getCrmSupplierInfoList")
public R<List<CrmSupplierInfoVo>> getCrmSupplierInfoList(CrmSupplierInfoBo bo) {
List<CrmSupplierInfoVo> list = crmSupplierInfoService.queryList(bo);
return R.ok(list);
}
}

@ -0,0 +1,178 @@
package org.dromara.oa.crm.domain;
import org.dromara.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serial;
/**
* crm_supplier_info
*
* @author Yinq
* @date 2025-11-05
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("crm_supplier_info")
public class CrmSupplierInfo extends TenantEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* ID
*/
@TableId(value = "supplier_id", type = IdType.AUTO)
private Long supplierId;
/**
*
*/
private String supplierName;
/**
*
*/
private String mnemonicName;
/**
* 1 2 3
*/
private String supplierType;
/**
*
*/
private BigDecimal registeredCapital;
/**
*
*/
private Date establishmentDate;
/**
*
*/
private String businessScope;
/**
*
*/
private String mainIndustry;
/**
*
*/
private String legalRepresentative;
/**
*
*/
private String businessLicenseNumber;
/**
*
*/
private String taxNumber;
/**
*
*/
private String bankAccountOpening;
/**
*
*/
private String bankNumber;
/**
*
*/
private String registeredAddress;
/**
*
*/
private String businessAddress;
/**
*
*/
private String contactPerson;
/**
*
*/
private String contactPhone;
/**
*
*/
private String contactMobile;
/**
*
*/
private String contactEmail;
/**
*
*/
private String contactFax;
/**
*
*/
private String website;
/**
* ID
*/
private Long ownerId;
/**
*
*/
private String detailedAddress;
/**
* ID
*/
private String ossId;
/**
*
*/
private String remark;
/**
* 1 0
*/
private String activeFlag;
/**
* 0 1
*/
@TableLogic
private String delFlag;
/**
*
*/
@TableField(exist = false)
private String ownerName;
/**
*
*/
@TableField(exist = false)
private String ownerDeptName;
}

@ -0,0 +1,158 @@
package org.dromara.oa.crm.domain.bo;
import org.dromara.oa.crm.domain.CrmSupplierInfo;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* crm_supplier_info
*
* @author Yinq
* @date 2025-11-05
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = CrmSupplierInfo.class, reverseConvertGenerate = false)
public class CrmSupplierInfoBo extends BaseEntity {
/**
* ID
*/
@NotNull(message = "供应商ID不能为空", groups = { EditGroup.class })
private Long supplierId;
/**
*
*/
private String supplierName;
/**
*
*/
private String mnemonicName;
/**
* 1 2 3
*/
private String supplierType;
/**
*
*/
private BigDecimal registeredCapital;
/**
*
*/
private Date establishmentDate;
/**
*
*/
private String businessScope;
/**
*
*/
private String mainIndustry;
/**
*
*/
private String legalRepresentative;
/**
*
*/
private String businessLicenseNumber;
/**
*
*/
private String taxNumber;
/**
*
*/
private String bankAccountOpening;
/**
*
*/
private String bankNumber;
/**
*
*/
private String registeredAddress;
/**
*
*/
private String businessAddress;
/**
*
*/
private String contactPerson;
/**
*
*/
private String contactPhone;
/**
*
*/
private String contactMobile;
/**
*
*/
private String contactEmail;
/**
*
*/
private String contactFax;
/**
*
*/
private String website;
/**
* ID
*/
private Long ownerId;
/**
*
*/
private String detailedAddress;
/**
* ID
*/
private String ossId;
/**
*
*/
private String remark;
/**
* 1 0
*/
private String activeFlag;
}

@ -0,0 +1,209 @@
package org.dromara.oa.crm.domain.vo;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.dromara.oa.crm.domain.CrmSupplierInfo;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import org.dromara.common.excel.annotation.ExcelDictFormat;
import org.dromara.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.dromara.resource.api.domain.RemoteFile;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* crm_supplier_info
*
* @author Yinq
* @date 2025-11-05
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = CrmSupplierInfo.class)
public class CrmSupplierInfoVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* ID
*/
@ExcelProperty(value = "供应商ID")
private Long supplierId;
/**
*
*/
@ExcelProperty(value = "供应商名称")
private String supplierName;
/**
*
*/
@ExcelProperty(value = "助记名称")
private String mnemonicName;
/**
* 1 2 3
*/
@ExcelProperty(value = "供应商类型", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "supplier_type")
private String supplierType;
/**
*
*/
@ExcelProperty(value = "注册资本", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "万=元")
private BigDecimal registeredCapital;
/**
*
*/
@ExcelProperty(value = "成立日期")
private Date establishmentDate;
/**
*
*/
@ExcelProperty(value = "经营范围")
private String businessScope;
/**
*
*/
@ExcelProperty(value = "主营行业")
private String mainIndustry;
/**
*
*/
@ExcelProperty(value = "法定代表人")
private String legalRepresentative;
/**
*
*/
@ExcelProperty(value = "营业执照号码")
private String businessLicenseNumber;
/**
*
*/
@ExcelProperty(value = "税号")
private String taxNumber;
/**
*
*/
@ExcelProperty(value = "开户银行")
private String bankAccountOpening;
/**
*
*/
@ExcelProperty(value = "银行账号")
private String bankNumber;
/**
*
*/
@ExcelProperty(value = "注册地址")
private String registeredAddress;
/**
*
*/
@ExcelProperty(value = "经营地址")
private String businessAddress;
/**
*
*/
@ExcelProperty(value = "联系人")
private String contactPerson;
/**
*
*/
@ExcelProperty(value = "联系电话")
private String contactPhone;
/**
*
*/
@ExcelProperty(value = "联系手机")
private String contactMobile;
/**
*
*/
@ExcelProperty(value = "联系邮箱")
private String contactEmail;
/**
*
*/
@ExcelProperty(value = "传真")
private String contactFax;
/**
*
*/
@ExcelProperty(value = "网址")
private String website;
/**
* ID
*/
@ExcelProperty(value = "归属人员ID")
private Long ownerId;
/**
*
*/
@ExcelProperty(value = "详细地址")
private String detailedAddress;
/**
* ID
*/
@ExcelProperty(value = "附件ID")
private String ossId;
/**
*
*/
@ExcelProperty(value = "备注")
private String remark;
/**
* 1 0
*/
@ExcelProperty(value = "激活标识", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "active_flag")
private String activeFlag;
/**
* sys_user
*/
@ExcelProperty(value = "归属人员名称")
private String ownerName;
/**
*
*/
@ExcelIgnore
private List<RemoteFile> attachmentList;
}

@ -0,0 +1,113 @@
package org.dromara.oa.crm.mapper;
import java.util.List;
import java.util.Collection;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.dromara.oa.crm.domain.CrmSupplierInfo;
import org.dromara.oa.crm.domain.vo.CrmSupplierInfoVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
/**
* Mapper
*
* @author Yinq
* @date 2025-11-05
*/
public interface CrmSupplierInfoMapper extends BaseMapperPlus<CrmSupplierInfo, CrmSupplierInfoVo> {
/**
*
*
* @param page
* @param queryWrapper
* @return
*/
public Page<CrmSupplierInfoVo> selectCustomCrmSupplierInfoVoList(@Param("page") Page<CrmSupplierInfoVo> page, @Param(Constants.WRAPPER) MPJLambdaWrapper<CrmSupplierInfo> queryWrapper);
/**
*
*
* @param queryWrapper
* @return
*/
public List<CrmSupplierInfoVo> selectCustomCrmSupplierInfoVoList(@Param(Constants.WRAPPER) MPJLambdaWrapper<CrmSupplierInfo> queryWrapper);
/**
* ID
*
* @param supplierId ID
* @return
*/
CrmSupplierInfoVo selectCustomCrmSupplierInfoVoById(@Param("supplierId") Long supplierId);
/**
* ID
*
* @param ids ID
* @return
*/
List<CrmSupplierInfoVo> selectCustomCrmSupplierInfoVoByIds(@Param("ids") Collection<Long> ids);
/**
*
*
* @param queryWrapper
* @return
*/
Long countCustomCrmSupplierInfo(@Param(Constants.WRAPPER) Wrapper<CrmSupplierInfo> queryWrapper);
/**
*
*
* @param page
* @param queryWrapper
* @return
*/
Page<CrmSupplierInfoVo> selectCustomCrmSupplierInfoVoPage(@Param("page") Page<CrmSupplierInfoVo> page, @Param(Constants.WRAPPER) Wrapper<CrmSupplierInfo> queryWrapper);
/**
*
*
* @param list
* @return
*/
int batchInsertCrmSupplierInfo(@Param("list") List<CrmSupplierInfo> list);
/**
*
*
* @param list
* @return
*/
int batchUpdateCrmSupplierInfo(@Param("list") List<CrmSupplierInfo> list);
/**
*
*
* @param queryWrapper
* @return
*/
int deleteCustomCrmSupplierInfo(@Param(Constants.WRAPPER) Wrapper<CrmSupplierInfo> queryWrapper);
/**
* ID
*
* @param ids ID
* @return
*/
int deleteCustomCrmSupplierInfoByIds(@Param("ids") Collection<Long> ids);
/**
*
*
* @param queryWrapper
* @return
*/
Boolean existsCrmSupplierInfo(@Param(Constants.WRAPPER) Wrapper<CrmSupplierInfo> queryWrapper);
}

@ -0,0 +1,69 @@
package org.dromara.oa.crm.service;
import org.dromara.oa.crm.domain.CrmSupplierInfo;
import org.dromara.oa.crm.domain.vo.CrmSupplierInfoVo;
import org.dromara.oa.crm.domain.bo.CrmSupplierInfoBo;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import java.util.Collection;
import java.util.List;
/**
* Service
*
* @author Yinq
* @date 2025-11-05
*/
public interface ICrmSupplierInfoService {
/**
*
*
* @param supplierId
* @return
*/
CrmSupplierInfoVo queryById(Long supplierId);
/**
*
*
* @param bo
* @param pageQuery
* @return
*/
TableDataInfo<CrmSupplierInfoVo> queryPageList(CrmSupplierInfoBo bo, PageQuery pageQuery);
/**
*
*
* @param bo
* @return
*/
List<CrmSupplierInfoVo> queryList(CrmSupplierInfoBo bo);
/**
*
*
* @param bo
* @return
*/
Boolean insertByBo(CrmSupplierInfoBo bo);
/**
*
*
* @param bo
* @return
*/
Boolean updateByBo(CrmSupplierInfoBo bo);
/**
*
*
* @param ids
* @param isValid
* @return
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

@ -0,0 +1,217 @@
package org.dromara.oa.crm.service.impl;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;
import org.dromara.oa.crm.domain.bo.CrmSupplierInfoBo;
import org.dromara.oa.crm.domain.vo.CrmSupplierInfoVo;
import org.dromara.oa.crm.domain.CrmSupplierInfo;
import org.dromara.oa.crm.mapper.CrmSupplierInfoMapper;
import org.dromara.oa.crm.service.ICrmSupplierInfoService;
import org.dromara.resource.api.RemoteFileService;
import org.dromara.resource.api.domain.RemoteFile;
import java.util.List;
import java.util.Map;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.LinkedHashSet;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.stream.Collectors;
/**
* Service
*
* @author Yinq
* @date 2025-11-05
*/
@RequiredArgsConstructor
@Service
public class CrmSupplierInfoServiceImpl implements ICrmSupplierInfoService {
private final CrmSupplierInfoMapper baseMapper;
@DubboReference(mock = "true")
private RemoteFileService remoteFileService;
/**
*
*
* @param supplierId
* @return
*/
@Override
public CrmSupplierInfoVo queryById(Long supplierId){
CrmSupplierInfoVo vo = baseMapper.selectVoById(supplierId);
fillAttachmentInfo(Collections.singletonList(vo));
return vo;
}
/**
*
*
* @param bo
* @param pageQuery
* @return
*/
@Override
public TableDataInfo<CrmSupplierInfoVo> queryPageList(CrmSupplierInfoBo bo, PageQuery pageQuery) {
MPJLambdaWrapper<CrmSupplierInfo> lqw = buildQueryWrapper(bo);
Page<CrmSupplierInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
fillAttachmentInfo(result.getRecords());
return TableDataInfo.build(result);
}
/**
*
*
* @param bo
* @return
*/
@Override
public List<CrmSupplierInfoVo> queryList(CrmSupplierInfoBo bo) {
MPJLambdaWrapper<CrmSupplierInfo> lqw = buildQueryWrapper(bo);
List<CrmSupplierInfoVo> list = baseMapper.selectVoList(lqw);
fillAttachmentInfo(list);
return list;
}
private MPJLambdaWrapper<CrmSupplierInfo> buildQueryWrapper(CrmSupplierInfoBo bo) {
Map<String, Object> params = bo.getParams();
MPJLambdaWrapper<CrmSupplierInfo> lqw = JoinWrappers.lambda(CrmSupplierInfo.class)
.selectAll(CrmSupplierInfo.class)
// // 左连接 sys_user 表获取归属人员名称
// .selectAs(SysUser::getNickName, CrmSupplierInfo::getOwnerName)
// .leftJoin(SysUser.class, SysUser::getUserId, CrmSupplierInfo::getOwnerId)
.eq(CrmSupplierInfo::getDelFlag, "0")
.like(StringUtils.isNotBlank(bo.getSupplierName()), CrmSupplierInfo::getSupplierName, bo.getSupplierName())
.like(StringUtils.isNotBlank(bo.getMnemonicName()), CrmSupplierInfo::getMnemonicName, bo.getMnemonicName())
.eq(StringUtils.isNotBlank(bo.getSupplierType()), CrmSupplierInfo::getSupplierType, bo.getSupplierType())
.eq(bo.getRegisteredCapital() != null, CrmSupplierInfo::getRegisteredCapital, bo.getRegisteredCapital())
.eq(bo.getEstablishmentDate() != null, CrmSupplierInfo::getEstablishmentDate, bo.getEstablishmentDate())
.eq(StringUtils.isNotBlank(bo.getBusinessScope()), CrmSupplierInfo::getBusinessScope, bo.getBusinessScope())
.eq(StringUtils.isNotBlank(bo.getMainIndustry()), CrmSupplierInfo::getMainIndustry, bo.getMainIndustry())
.eq(StringUtils.isNotBlank(bo.getLegalRepresentative()), CrmSupplierInfo::getLegalRepresentative, bo.getLegalRepresentative())
.eq(StringUtils.isNotBlank(bo.getBusinessLicenseNumber()), CrmSupplierInfo::getBusinessLicenseNumber, bo.getBusinessLicenseNumber())
.eq(StringUtils.isNotBlank(bo.getTaxNumber()), CrmSupplierInfo::getTaxNumber, bo.getTaxNumber())
.eq(StringUtils.isNotBlank(bo.getBankAccountOpening()), CrmSupplierInfo::getBankAccountOpening, bo.getBankAccountOpening())
.eq(StringUtils.isNotBlank(bo.getBankNumber()), CrmSupplierInfo::getBankNumber, bo.getBankNumber())
.eq(StringUtils.isNotBlank(bo.getRegisteredAddress()), CrmSupplierInfo::getRegisteredAddress, bo.getRegisteredAddress())
.eq(StringUtils.isNotBlank(bo.getBusinessAddress()), CrmSupplierInfo::getBusinessAddress, bo.getBusinessAddress())
.eq(StringUtils.isNotBlank(bo.getContactPerson()), CrmSupplierInfo::getContactPerson, bo.getContactPerson())
.eq(StringUtils.isNotBlank(bo.getContactPhone()), CrmSupplierInfo::getContactPhone, bo.getContactPhone())
.eq(StringUtils.isNotBlank(bo.getContactMobile()), CrmSupplierInfo::getContactMobile, bo.getContactMobile())
.eq(StringUtils.isNotBlank(bo.getContactEmail()), CrmSupplierInfo::getContactEmail, bo.getContactEmail())
.eq(StringUtils.isNotBlank(bo.getContactFax()), CrmSupplierInfo::getContactFax, bo.getContactFax())
.eq(StringUtils.isNotBlank(bo.getWebsite()), CrmSupplierInfo::getWebsite, bo.getWebsite())
.eq(bo.getOwnerId() != null, CrmSupplierInfo::getOwnerId, bo.getOwnerId())
.eq(StringUtils.isNotBlank(bo.getDetailedAddress()), CrmSupplierInfo::getDetailedAddress, bo.getDetailedAddress())
.eq(StringUtils.isNotBlank(bo.getOssId()), CrmSupplierInfo::getOssId, bo.getOssId())
.eq(StringUtils.isNotBlank(bo.getActiveFlag()), CrmSupplierInfo::getActiveFlag, bo.getActiveFlag());
return lqw;
}
private void fillAttachmentInfo(List<CrmSupplierInfoVo> voList) {
if (voList == null || voList.isEmpty()) {
return;
}
Set<String> ossIdSet = new LinkedHashSet<>();
Map<CrmSupplierInfoVo, List<String>> voOssMapping = new HashMap<>();
for (CrmSupplierInfoVo vo : voList) {
if (vo == null || StringUtils.isBlank(vo.getOssId())) {
continue;
}
List<String> ids = List.of(StringUtils.split(vo.getOssId(), ","));
if (ids.isEmpty()) {
continue;
}
voOssMapping.put(vo, ids);
ossIdSet.addAll(ids);
}
if (ossIdSet.isEmpty()) {
return;
}
try {
List<RemoteFile> files = remoteFileService.selectByIds(String.join(",", ossIdSet));
Map<Long, RemoteFile> fileMap = files.stream()
.filter(item -> item.getOssId() != null)
.collect(Collectors.toMap(RemoteFile::getOssId, item -> item, (a, b) -> a));
for (Entry<CrmSupplierInfoVo, List<String>> entry : voOssMapping.entrySet()) {
List<RemoteFile> voFiles = entry.getValue().stream()
.map(id -> {
if (!StringUtils.isNumeric(id)) {
return null;
}
Long key = Long.parseLong(id);
return fileMap.get(key);
})
.filter(item -> item != null)
.collect(Collectors.toList());
entry.getKey().setAttachmentList(voFiles);
}
} catch (Exception ignored) {
// 远程文件服务异常时忽略附件
}
}
/**
*
*
* @param bo
* @return
*/
@Override
public Boolean insertByBo(CrmSupplierInfoBo bo) {
CrmSupplierInfo add = MapstructUtils.convert(bo, CrmSupplierInfo.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setSupplierId(add.getSupplierId());
}
return flag;
}
/**
*
*
* @param bo
* @return
*/
@Override
public Boolean updateByBo(CrmSupplierInfoBo bo) {
CrmSupplierInfo update = MapstructUtils.convert(bo, CrmSupplierInfo.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
*
*/
private void validEntityBeforeSave(CrmSupplierInfo entity){
//TODO 做一些数据校验,如唯一约束
}
/**
*
*
* @param ids
* @param isValid
* @return
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
}
}

@ -0,0 +1,319 @@
<?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="org.dromara.oa.crm.mapper.CrmSupplierInfoMapper">
<resultMap type="org.dromara.oa.crm.domain.vo.CrmSupplierInfoVo" id="CrmSupplierInfoResult">
</resultMap>
<select id="selectCustomCrmSupplierInfoVoList" resultMap="CrmSupplierInfoResult">
select t.supplier_id, t.tenant_id, t.supplier_name, t.mnemonic_name, t.supplier_type,
t.registered_capital, t.establishment_date, t.business_scope, t.main_industry,
t.legal_representative, t.business_license_number, t.tax_number, t.bank_account_opening,
t.bank_number, t.registered_address, t.business_address, t.contact_person, t.contact_phone, t.contact_mobile,
t.contact_email, t.contact_fax, t.website, t.owner_id, t.detailed_address, t.oss_id, t.remark, t.active_flag, t.del_flag, t.create_dept,
u1.nick_name as ownerName,
t.create_by, t.create_time, t.update_by, t.update_time
from crm_supplier_info t
left join sys_user u1 on u1.user_id = t.owner_id
${ew.getCustomSqlSegment}
</select>
<!-- 根据ID查询详情 -->
<select id="selectCustomCrmSupplierInfoVoById" resultMap="CrmSupplierInfoResult">
select t.supplier_id, t.tenant_id, t.supplier_name, t.mnemonic_name, t.supplier_type, t.registered_capital, t.establishment_date, t.business_scope, t.main_industry, t.legal_representative, t.business_license_number, t.tax_number, t.bank_account_opening, t.bank_number, t.registered_address, t.business_address, t.contact_person, t.contact_phone, t.contact_mobile, t.contact_email, t.contact_fax, t.website, t.owner_id, t.detailed_address, t.oss_id, t.remark, t.active_flag, t.del_flag, t.create_dept, t.create_by, t.create_time, t.update_by, t.update_time
from crm_supplier_info t
where t.supplier_id = #{supplierId}
</select>
<!-- 批量查询 - 根据ID列表 -->
<select id="selectCustomCrmSupplierInfoVoByIds" resultMap="CrmSupplierInfoResult">
select t.supplier_id, t.tenant_id, t.supplier_name, t.mnemonic_name, t.supplier_type, t.registered_capital, t.establishment_date, t.business_scope, t.main_industry, t.legal_representative, t.business_license_number, t.tax_number, t.bank_account_opening, t.bank_number, t.registered_address, t.business_address, t.contact_person, t.contact_phone, t.contact_mobile, t.contact_email, t.contact_fax, t.website, t.owner_id, t.detailed_address, t.oss_id, t.remark, t.active_flag, t.del_flag, t.create_dept, t.create_by, t.create_time, t.update_by, t.update_time
from crm_supplier_info t
where t.supplier_id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<!-- 统计查询 -->
<select id="countCustomCrmSupplierInfo" resultType="java.lang.Long">
select count(1) from crm_supplier_info t
${ew.getCustomSqlSegment}
</select>
<!-- 分页查询(带自定义条件) -->
<select id="selectCustomCrmSupplierInfoVoPage" resultMap="CrmSupplierInfoResult">
select t.supplier_id, t.tenant_id, t.supplier_name, t.mnemonic_name, t.supplier_type, t.registered_capital, t.establishment_date, t.business_scope, t.main_industry, t.legal_representative, t.business_license_number, t.tax_number, t.bank_account_opening, t.bank_number, t.registered_address, t.business_address, t.contact_person, t.contact_phone, t.contact_mobile, t.contact_email, t.contact_fax, t.website, t.owner_id, t.detailed_address, t.oss_id, t.remark, t.active_flag, t.del_flag, t.create_dept, t.create_by, t.create_time, t.update_by, t.update_time
from crm_supplier_info t
${ew.getCustomSqlSegment}
</select>
<!-- 批量插入 -->
<insert id="batchInsertCrmSupplierInfo">
insert into crm_supplier_info(
tenant_id,
supplier_name,
mnemonic_name,
supplier_type,
registered_capital,
establishment_date,
business_scope,
main_industry,
legal_representative,
business_license_number,
tax_number,
bank_account_opening,
bank_number,
registered_address,
business_address,
contact_person,
contact_phone,
contact_mobile,
contact_email,
contact_fax,
website,
owner_id,
detailed_address,
oss_id,
remark,
active_flag,
del_flag,
create_dept,
create_by,
create_time,
update_by,
update_time
)
values
<foreach collection="list" item="item" separator=",">
(
#{item.tenantId},
#{item.supplierName},
#{item.mnemonicName},
#{item.supplierType},
#{item.registeredCapital},
#{item.establishmentDate},
#{item.businessScope},
#{item.mainIndustry},
#{item.legalRepresentative},
#{item.businessLicenseNumber},
#{item.taxNumber},
#{item.bankAccountOpening},
#{item.bankNumber},
#{item.registeredAddress},
#{item.businessAddress},
#{item.contactPerson},
#{item.contactPhone},
#{item.contactMobile},
#{item.contactEmail},
#{item.contactFax},
#{item.website},
#{item.ownerId},
#{item.detailedAddress},
#{item.ossId},
#{item.remark},
#{item.activeFlag},
#{item.delFlag},
#{item.createDept},
#{item.createBy},
#{item.createTime},
#{item.updateBy},
#{item.updateTime}
)
</foreach>
</insert>
<!-- 批量更新 -->
<update id="batchUpdateCrmSupplierInfo">
<foreach collection="list" item="item" separator=";">
update crm_supplier_info
<set>
<if test="item.tenantId != null and item.tenantId != ''">
tenant_id = #{item.tenantId},
</if>
<if test="item.supplierName != null and item.supplierName != ''">
supplier_name = #{item.supplierName},
</if>
<if test="item.mnemonicName != null and item.mnemonicName != ''">
mnemonic_name = #{item.mnemonicName},
</if>
<if test="item.supplierType != null and item.supplierType != ''">
supplier_type = #{item.supplierType},
</if>
<if test="item.registeredCapital != null">
registered_capital = #{item.registeredCapital},
</if>
<if test="item.establishmentDate != null">
establishment_date = #{item.establishmentDate},
</if>
<if test="item.businessScope != null and item.businessScope != ''">
business_scope = #{item.businessScope},
</if>
<if test="item.mainIndustry != null and item.mainIndustry != ''">
main_industry = #{item.mainIndustry},
</if>
<if test="item.legalRepresentative != null and item.legalRepresentative != ''">
legal_representative = #{item.legalRepresentative},
</if>
<if test="item.businessLicenseNumber != null and item.businessLicenseNumber != ''">
business_license_number = #{item.businessLicenseNumber},
</if>
<if test="item.taxNumber != null and item.taxNumber != ''">
tax_number = #{item.taxNumber},
</if>
<if test="item.bankAccountOpening != null and item.bankAccountOpening != ''">
bank_account_opening = #{item.bankAccountOpening},
</if>
<if test="item.bankNumber != null and item.bankNumber != ''">
bank_number = #{item.bankNumber},
</if>
<if test="item.registeredAddress != null and item.registeredAddress != ''">
registered_address = #{item.registeredAddress},
</if>
<if test="item.businessAddress != null and item.businessAddress != ''">
business_address = #{item.businessAddress},
</if>
<if test="item.contactPerson != null and item.contactPerson != ''">
contact_person = #{item.contactPerson},
</if>
<if test="item.contactPhone != null and item.contactPhone != ''">
contact_phone = #{item.contactPhone},
</if>
<if test="item.contactMobile != null and item.contactMobile != ''">
contact_mobile = #{item.contactMobile},
</if>
<if test="item.contactEmail != null and item.contactEmail != ''">
contact_email = #{item.contactEmail},
</if>
<if test="item.contactFax != null and item.contactFax != ''">
contact_fax = #{item.contactFax},
</if>
<if test="item.website != null and item.website != ''">
website = #{item.website},
</if>
<if test="item.ownerId != null">
owner_id = #{item.ownerId},
</if>
<if test="item.detailedAddress != null and item.detailedAddress != ''">
detailed_address = #{item.detailedAddress},
</if>
<if test="item.ossId != null and item.ossId != ''">
oss_id = #{item.ossId},
</if>
<if test="item.remark != null and item.remark != ''">
remark = #{item.remark},
</if>
<if test="item.activeFlag != null and item.activeFlag != ''">
active_flag = #{item.activeFlag},
</if>
<if test="item.delFlag != null and item.delFlag != ''">
del_flag = #{item.delFlag},
</if>
<if test="item.createDept != null">
create_dept = #{item.createDept},
</if>
<if test="item.createBy != null">
create_by = #{item.createBy},
</if>
<if test="item.createTime != null">
create_time = #{item.createTime},
</if>
<if test="item.updateBy != null">
update_by = #{item.updateBy},
</if>
<if test="item.updateTime != null">
update_time = #{item.updateTime}
</if>
</set>
where supplier_id = #{item.supplierId}
</foreach>
</update>
<!-- 根据自定义条件删除 -->
<delete id="deleteCustomCrmSupplierInfo">
delete from crm_supplier_info
${ew.getCustomSqlSegment}
</delete>
<!-- 根据ID列表批量删除 -->
<delete id="deleteCustomCrmSupplierInfoByIds">
delete from crm_supplier_info
where supplier_id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 检查是否存在 -->
<select id="existsCrmSupplierInfo" resultType="java.lang.Boolean">
select count(1) > 0 from crm_supplier_info t
${ew.getCustomSqlSegment}
</select>
</mapper>
Loading…
Cancel
Save