mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	crm联系人
This commit is contained in:
		| @@ -0,0 +1,102 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.contact; | ||||
|  | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
|  | ||||
| import javax.validation.constraints.*; | ||||
| import javax.validation.*; | ||||
| import javax.servlet.http.*; | ||||
| import java.util.*; | ||||
| import java.io.IOException; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||
| import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||||
|  | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; | ||||
| import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; | ||||
| import cn.iocoder.yudao.module.crm.service.contact.ContactService; | ||||
|  | ||||
| @Tag(name = "管理后台 - crm联系人") | ||||
| @RestController | ||||
| @RequestMapping("/crm/contact") | ||||
| @Validated | ||||
| public class ContactController { | ||||
|  | ||||
|     @Resource | ||||
|     private ContactService contactService; | ||||
|  | ||||
|     @PostMapping("/create") | ||||
|     @Operation(summary = "创建crm联系人") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:contact:create')") | ||||
|     public CommonResult<Long> createContact(@Valid @RequestBody ContactCreateReqVO createReqVO) { | ||||
|         return success(contactService.createContact(createReqVO)); | ||||
|     } | ||||
|  | ||||
|     @PutMapping("/update") | ||||
|     @Operation(summary = "更新crm联系人") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:contact:update')") | ||||
|     public CommonResult<Boolean> updateContact(@Valid @RequestBody ContactUpdateReqVO updateReqVO) { | ||||
|         contactService.updateContact(updateReqVO); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @DeleteMapping("/delete") | ||||
|     @Operation(summary = "删除crm联系人") | ||||
|     @Parameter(name = "id", description = "编号", required = true) | ||||
|     @PreAuthorize("@ss.hasPermission('crm:contact:delete')") | ||||
|     public CommonResult<Boolean> deleteContact(@RequestParam("id") Long id) { | ||||
|         contactService.deleteContact(id); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/get") | ||||
|     @Operation(summary = "获得crm联系人") | ||||
|     @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:contact:query')") | ||||
|     public CommonResult<ContactRespVO> getContact(@RequestParam("id") Long id) { | ||||
|         ContactDO contact = contactService.getContact(id); | ||||
|         return success(ContactConvert.INSTANCE.convert(contact)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/list") | ||||
|     @Operation(summary = "获得crm联系人列表") | ||||
|     @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:contact:query')") | ||||
|     public CommonResult<List<ContactRespVO>> getContactList(@RequestParam("ids") Collection<Long> ids) { | ||||
|         List<ContactDO> list = contactService.getContactList(ids); | ||||
|         return success(ContactConvert.INSTANCE.convertList(list)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/page") | ||||
|     @Operation(summary = "获得crm联系人分页") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:contact:query')") | ||||
|     public CommonResult<PageResult<ContactRespVO>> getContactPage(@Valid ContactPageReqVO pageVO) { | ||||
|         PageResult<ContactDO> pageResult = contactService.getContactPage(pageVO); | ||||
|         return success(ContactConvert.INSTANCE.convertPage(pageResult)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/export-excel") | ||||
|     @Operation(summary = "导出crm联系人 Excel") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:contact:export')") | ||||
|     @OperateLog(type = EXPORT) | ||||
|     public void exportContactExcel(@Valid ContactExportReqVO exportReqVO, | ||||
|               HttpServletResponse response) throws IOException { | ||||
|         List<ContactDO> list = contactService.getContactList(exportReqVO); | ||||
|         // 导出 Excel | ||||
|         List<ContactExcelVO> datas = ContactConvert.INSTANCE.convertList02(list); | ||||
|         ExcelUtils.write(response, "crm联系人.xls", "数据", ContactExcelVO.class, datas); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,55 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalDateTime; | ||||
| import javax.validation.constraints.*; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
|  | ||||
| /** | ||||
|  * crm联系人 Base VO,提供给添加、修改、详细的子 VO 使用 | ||||
|  * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||||
|  */ | ||||
| @Data | ||||
| public class ContactBaseVO { | ||||
|  | ||||
|     @Schema(description = "联系人名称", example = "张三") | ||||
|     @NotNull(message = "姓名不能为空") | ||||
|     private String name; | ||||
|  | ||||
|     @Schema(description = "下次联系时间") | ||||
|     private LocalDateTime nextTime; | ||||
|  | ||||
|     @Schema(description = "手机号") | ||||
|     private String mobile; | ||||
|  | ||||
|     @Schema(description = "电话") | ||||
|     private String telephone; | ||||
|  | ||||
|     @Schema(description = "电子邮箱") | ||||
|     private String email; | ||||
|  | ||||
|     @Schema(description = "职务") | ||||
|     private String post; | ||||
|  | ||||
|     @Schema(description = "客户编号", example = "10795") | ||||
|     private Long customerId; | ||||
|  | ||||
|     @Schema(description = "地址") | ||||
|     private String address; | ||||
|  | ||||
|     @Schema(description = "备注", example = "你说的对") | ||||
|     private String remark; | ||||
|  | ||||
|     @Schema(description = "负责人用户编号", example = "7648") | ||||
|     private Long ownerUserId; | ||||
|  | ||||
|     @Schema(description = "最后跟进时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime lastTime; | ||||
| } | ||||
| @@ -0,0 +1,14 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import javax.validation.constraints.*; | ||||
|  | ||||
| @Schema(description = "管理后台 - crm联系人创建 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class ContactCreateReqVO extends ContactBaseVO { | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,59 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| import com.alibaba.excel.annotation.ExcelProperty; | ||||
|  | ||||
| /** | ||||
|  * crm联系人 Excel VO | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Data | ||||
| public class ContactExcelVO { | ||||
|  | ||||
|     @ExcelProperty("主键") | ||||
|     private Long id; | ||||
|  | ||||
|     @ExcelProperty("联系人名称") | ||||
|     private String name; | ||||
|  | ||||
|     @ExcelProperty("下次联系时间") | ||||
|     private LocalDateTime nextTime; | ||||
|  | ||||
|     @ExcelProperty("手机号") | ||||
|     private String mobile; | ||||
|  | ||||
|     @ExcelProperty("电话") | ||||
|     private String telephone; | ||||
|  | ||||
|     @ExcelProperty("电子邮箱") | ||||
|     private String email; | ||||
|  | ||||
|     @ExcelProperty("职务") | ||||
|     private String post; | ||||
|  | ||||
|     @ExcelProperty("客户编号") | ||||
|     private Long customerId; | ||||
|  | ||||
|     @ExcelProperty("地址") | ||||
|     private String address; | ||||
|  | ||||
|     @ExcelProperty("备注") | ||||
|     private String remark; | ||||
|  | ||||
|     @ExcelProperty("负责人用户编号") | ||||
|     private Long ownerUserId; | ||||
|  | ||||
|     @ExcelProperty("创建时间") | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
|     @ExcelProperty("最后跟进时间") | ||||
|     private LocalDateTime lastTime; | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,55 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import java.time.LocalDateTime; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
|  | ||||
| @Schema(description = "管理后台 - crm联系人 Excel 导出 Request VO,参数和 ContactPageReqVO 是一致的") | ||||
| @Data | ||||
| public class ContactExportReqVO { | ||||
|  | ||||
|     @Schema(description = "联系人名称", example = "张三") | ||||
|     private String name; | ||||
|  | ||||
|     @Schema(description = "下次联系时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] nextTime; | ||||
|  | ||||
|     @Schema(description = "手机号") | ||||
|     private String mobile; | ||||
|  | ||||
|     @Schema(description = "电话") | ||||
|     private String telephone; | ||||
|  | ||||
|     @Schema(description = "电子邮箱") | ||||
|     private String email; | ||||
|  | ||||
|     @Schema(description = "职务") | ||||
|     private String post; | ||||
|  | ||||
|     @Schema(description = "客户编号", example = "10795") | ||||
|     private Long customerId; | ||||
|  | ||||
|     @Schema(description = "地址") | ||||
|     private String address; | ||||
|  | ||||
|     @Schema(description = "备注", example = "你说的对") | ||||
|     private String remark; | ||||
|  | ||||
|     @Schema(description = "负责人用户编号", example = "7648") | ||||
|     private Long ownerUserId; | ||||
|  | ||||
|     @Schema(description = "创建时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] createTime; | ||||
|  | ||||
|     @Schema(description = "最后跟进时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] lastTime; | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,57 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
|  | ||||
| @Schema(description = "管理后台 - crm联系人分页 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class ContactPageReqVO extends PageParam { | ||||
|  | ||||
|     @Schema(description = "联系人名称", example = "张三") | ||||
|     private String name; | ||||
|  | ||||
|     @Schema(description = "下次联系时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] nextTime; | ||||
|  | ||||
|     @Schema(description = "手机号") | ||||
|     private String mobile; | ||||
|  | ||||
|     @Schema(description = "电话") | ||||
|     private String telephone; | ||||
|  | ||||
|     @Schema(description = "电子邮箱") | ||||
|     private String email; | ||||
|  | ||||
|     @Schema(description = "职务") | ||||
|     private String post; | ||||
|  | ||||
|     @Schema(description = "客户编号", example = "10795") | ||||
|     private Long customerId; | ||||
|  | ||||
|     @Schema(description = "地址") | ||||
|     private String address; | ||||
|  | ||||
|     @Schema(description = "备注", example = "你说的对") | ||||
|     private String remark; | ||||
|  | ||||
|     @Schema(description = "负责人用户编号", example = "7648") | ||||
|     private Long ownerUserId; | ||||
|  | ||||
|     @Schema(description = "创建时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] createTime; | ||||
|  | ||||
|     @Schema(description = "最后跟进时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] lastTime; | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,20 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| @Schema(description = "管理后台 - crm联系人 Response VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class ContactRespVO extends ContactBaseVO { | ||||
|  | ||||
|     @Schema(description = "主键", example = "23210") | ||||
|     private Long id; | ||||
|  | ||||
|     @Schema(description = "创建时间") | ||||
|     private LocalDateTime createTime; | ||||
|     @Schema(description = "创建人") | ||||
|     private String creator; | ||||
| } | ||||
| @@ -0,0 +1,17 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import javax.validation.constraints.*; | ||||
|  | ||||
| @Schema(description = "管理后台 - crm联系人更新 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class ContactUpdateReqVO extends ContactBaseVO { | ||||
|  | ||||
|     @Schema(description = "主键", example = "23210") | ||||
|     private Long id; | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,34 @@ | ||||
| package cn.iocoder.yudao.module.crm.convert.contact; | ||||
|  | ||||
| import java.util.*; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
|  | ||||
| import org.mapstruct.Mapper; | ||||
| import org.mapstruct.factory.Mappers; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; | ||||
|  | ||||
| /** | ||||
|  * crm联系人 Convert | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Mapper | ||||
| public interface ContactConvert { | ||||
|  | ||||
|     ContactConvert INSTANCE = Mappers.getMapper(ContactConvert.class); | ||||
|  | ||||
|     ContactDO convert(ContactCreateReqVO bean); | ||||
|  | ||||
|     ContactDO convert(ContactUpdateReqVO bean); | ||||
|  | ||||
|     ContactRespVO convert(ContactDO bean); | ||||
|  | ||||
|     List<ContactRespVO> convertList(List<ContactDO> list); | ||||
|  | ||||
|     PageResult<ContactRespVO> convertPage(PageResult<ContactDO> page); | ||||
|  | ||||
|     List<ContactExcelVO> convertList02(List<ContactDO> list); | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,76 @@ | ||||
| package cn.iocoder.yudao.module.crm.dal.dataobject.contact; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalDateTime; | ||||
| import com.baomidou.mybatisplus.annotation.*; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||||
|  | ||||
| /** | ||||
|  * crm联系人 DO | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @TableName("crm_contact") | ||||
| @KeySequence("crm_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| @Builder | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class ContactDO extends BaseDO { | ||||
|  | ||||
|     /** | ||||
|      * 主键 | ||||
|      */ | ||||
|     @TableId | ||||
|     private Long id; | ||||
|     /** | ||||
|      * 联系人名称 | ||||
|      */ | ||||
|     private String name; | ||||
|     /** | ||||
|      * 下次联系时间 | ||||
|      */ | ||||
|     private LocalDateTime nextTime; | ||||
|     /** | ||||
|      * 手机号 | ||||
|      */ | ||||
|     private String mobile; | ||||
|     /** | ||||
|      * 电话 | ||||
|      */ | ||||
|     private String telephone; | ||||
|     /** | ||||
|      * 电子邮箱 | ||||
|      */ | ||||
|     private String email; | ||||
|     /** | ||||
|      * 职务 | ||||
|      */ | ||||
|     private String post; | ||||
|     /** | ||||
|      * 客户编号 | ||||
|      */ | ||||
|     private Long customerId; | ||||
|     /** | ||||
|      * 地址 | ||||
|      */ | ||||
|     private String address; | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     private String remark; | ||||
|     /** | ||||
|      * 负责人用户编号 | ||||
|      */ | ||||
|     private Long ownerUserId; | ||||
|     /** | ||||
|      * 最后跟进时间 | ||||
|      */ | ||||
|     private LocalDateTime lastTime; | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,54 @@ | ||||
| package cn.iocoder.yudao.module.crm.dal.mysql.contact; | ||||
|  | ||||
| import java.util.*; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; | ||||
| import org.apache.ibatis.annotations.Mapper; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | ||||
|  | ||||
| /** | ||||
|  * crm联系人 Mapper | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Mapper | ||||
| public interface ContactMapper extends BaseMapperX<ContactDO> { | ||||
|  | ||||
|     default PageResult<ContactDO> selectPage(ContactPageReqVO reqVO) { | ||||
|         return selectPage(reqVO, new LambdaQueryWrapperX<ContactDO>() | ||||
|                 .likeIfPresent(ContactDO::getName, reqVO.getName()) | ||||
|                 .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime()) | ||||
|                 .eqIfPresent(ContactDO::getMobile, reqVO.getMobile()) | ||||
|                 .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone()) | ||||
|                 .eqIfPresent(ContactDO::getEmail, reqVO.getEmail()) | ||||
|                 .eqIfPresent(ContactDO::getPost, reqVO.getPost()) | ||||
|                 .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) | ||||
|                 .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) | ||||
|                 .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) | ||||
|                 .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId()) | ||||
|                 .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) | ||||
|                 .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) | ||||
|                 .orderByDesc(ContactDO::getId)); | ||||
|     } | ||||
|  | ||||
|     default List<ContactDO> selectList(ContactExportReqVO reqVO) { | ||||
|         return selectList(new LambdaQueryWrapperX<ContactDO>() | ||||
|                 .likeIfPresent(ContactDO::getName, reqVO.getName()) | ||||
|                 .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime()) | ||||
|                 .eqIfPresent(ContactDO::getMobile, reqVO.getMobile()) | ||||
|                 .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone()) | ||||
|                 .eqIfPresent(ContactDO::getEmail, reqVO.getEmail()) | ||||
|                 .eqIfPresent(ContactDO::getPost, reqVO.getPost()) | ||||
|                 .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) | ||||
|                 .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) | ||||
|                 .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) | ||||
|                 .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId()) | ||||
|                 .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) | ||||
|                 .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) | ||||
|                 .orderByDesc(ContactDO::getId)); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,70 @@ | ||||
| package cn.iocoder.yudao.module.crm.service.contact; | ||||
|  | ||||
| import java.util.*; | ||||
| import javax.validation.*; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
|  | ||||
| /** | ||||
|  * crm联系人 Service 接口 | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| public interface ContactService { | ||||
|  | ||||
|     /** | ||||
|      * 创建crm联系人 | ||||
|      * | ||||
|      * @param createReqVO 创建信息 | ||||
|      * @return 编号 | ||||
|      */ | ||||
|     Long createContact(@Valid ContactCreateReqVO createReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 更新crm联系人 | ||||
|      * | ||||
|      * @param updateReqVO 更新信息 | ||||
|      */ | ||||
|     void updateContact(@Valid ContactUpdateReqVO updateReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 删除crm联系人 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      */ | ||||
|     void deleteContact(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 获得crm联系人 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      * @return crm联系人 | ||||
|      */ | ||||
|     ContactDO getContact(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 获得crm联系人列表 | ||||
|      * | ||||
|      * @param ids 编号 | ||||
|      * @return crm联系人列表 | ||||
|      */ | ||||
|     List<ContactDO> getContactList(Collection<Long> ids); | ||||
|  | ||||
|     /** | ||||
|      * 获得crm联系人分页 | ||||
|      * | ||||
|      * @param pageReqVO 分页查询 | ||||
|      * @return crm联系人分页 | ||||
|      */ | ||||
|     PageResult<ContactDO> getContactPage(ContactPageReqVO pageReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 获得crm联系人列表, 用于 Excel 导出 | ||||
|      * | ||||
|      * @param exportReqVO 查询条件 | ||||
|      * @return crm联系人列表 | ||||
|      */ | ||||
|     List<ContactDO> getContactList(ContactExportReqVO exportReqVO); | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,88 @@ | ||||
| package cn.iocoder.yudao.module.crm.service.contact; | ||||
|  | ||||
| import org.springframework.stereotype.Service; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
|  | ||||
| import java.util.*; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
|  | ||||
| import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; | ||||
| import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.collection.ListUtil; | ||||
|  | ||||
| /** | ||||
|  * crm联系人 Service 实现类 | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Service | ||||
| @Validated | ||||
| public class ContactServiceImpl implements ContactService { | ||||
|  | ||||
|     @Resource | ||||
|     private ContactMapper contactMapper; | ||||
|  | ||||
|     @Override | ||||
|     public Long createContact(ContactCreateReqVO createReqVO) { | ||||
|         // 插入 | ||||
|         ContactDO contact = ContactConvert.INSTANCE.convert(createReqVO); | ||||
|         contactMapper.insert(contact); | ||||
|         // 返回 | ||||
|         return contact.getId(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateContact(ContactUpdateReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         validateContactExists(updateReqVO.getId()); | ||||
|         // 更新 | ||||
|         ContactDO updateObj = ContactConvert.INSTANCE.convert(updateReqVO); | ||||
|         contactMapper.updateById(updateObj); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void deleteContact(Long id) { | ||||
|         // 校验存在 | ||||
|         validateContactExists(id); | ||||
|         // 删除 | ||||
|         contactMapper.deleteById(id); | ||||
|     } | ||||
|  | ||||
|     private void validateContactExists(Long id) { | ||||
|         if (contactMapper.selectById(id) == null) { | ||||
|             throw exception(CONTACT_NOT_EXISTS); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ContactDO getContact(Long id) { | ||||
|         return contactMapper.selectById(id); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<ContactDO> getContactList(Collection<Long> ids) { | ||||
|         if (CollUtil.isEmpty(ids)) { | ||||
|             return ListUtil.empty(); | ||||
|         } | ||||
|         return contactMapper.selectBatchIds(ids); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public PageResult<ContactDO> getContactPage(ContactPageReqVO pageReqVO) { | ||||
|         return contactMapper.selectPage(pageReqVO); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<ContactDO> getContactList(ContactExportReqVO exportReqVO) { | ||||
|         return contactMapper.selectList(exportReqVO); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,12 @@ | ||||
| <?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="cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper"> | ||||
|  | ||||
|     <!-- | ||||
|         一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | ||||
|         无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | ||||
|         代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | ||||
|         文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | ||||
|      --> | ||||
|  | ||||
| </mapper> | ||||
		Reference in New Issue
	
	Block a user
	 zyna
					zyna