diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java index 239c667..443603c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java @@ -2,13 +2,18 @@ package cn.iocoder.yudao.module.system.controller.admin.enterprise; import cn.iocoder.yudao.module.infra.api.file.FileApi; import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseauditlog.EnterpriseAuditLogDO; +import cn.iocoder.yudao.module.system.dal.dataobject.enterprisetag.EnterpriseTagDO; import cn.iocoder.yudao.module.system.dal.dataobject.fileInfo.FileInfoDO; import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; +import cn.iocoder.yudao.module.system.dal.dataobject.taglibrary.TagLibraryDO; import cn.iocoder.yudao.module.system.dal.mysql.enterpriseauditlog.EnterpriseAuditLogMapper; +import cn.iocoder.yudao.module.system.dal.mysql.enterprisetag.EnterpriseTagMapper; import cn.iocoder.yudao.module.system.dal.mysql.fileInfo.FileInfoMapper; import cn.iocoder.yudao.module.system.dal.mysql.qualification.EnterpriseQualificationMapper; +import cn.iocoder.yudao.module.system.dal.mysql.taglibrary.TagLibraryMapper; import cn.iocoder.yudao.module.system.service.fileInfo.FileInfoService; import cn.iocoder.yudao.module.system.service.qualification.EnterpriseQualificationService; +import cn.iocoder.yudao.module.system.service.taglibrary.TagLibraryService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; @@ -59,6 +64,10 @@ public class EnterpriseController { private EnterpriseQualificationMapper enterpriseQualificationMapper; @Resource private EnterpriseAuditLogMapper enterpriseAuditLogMapper; + @Resource + private TagLibraryMapper tagLibraryMapper; + @Resource + private EnterpriseTagMapper enterpriseTagMapper; @PostMapping("/create") @Operation(summary = "创建企业") @@ -108,8 +117,7 @@ public class EnterpriseController { final List enterpriseQualificationList = enterpriseQualificationMapper.selectList(queryWrapper); enterprise.setQualificationList(enterpriseQualificationList); } - //获取企业图片 - + //获取企业标签 return success(BeanUtils.toBean(enterprise, EnterpriseRespVO.class)); } @@ -119,6 +127,41 @@ public class EnterpriseController { @PreAuthorize("@ss.hasPermission('system:enterprise:query')") public CommonResult> getEnterprisePage(@Valid EnterprisePageReqVO pageReqVO) { PageResult pageResult = enterpriseService.getEnterprisePage(pageReqVO); + pageResult.getList().forEach(item->{ + //企业审核状态 + QueryWrapper auditLogDOQueryWrapper = new QueryWrapper<>(); + auditLogDOQueryWrapper.eq("enterprise_id", item.getId()); + EnterpriseAuditLogDO enterpriseAuditLogDO = enterpriseAuditLogMapper.selectOne(auditLogDOQueryWrapper); + if (enterpriseAuditLogDO != null) { + item.setAudit(enterpriseAuditLogDO.getAudit()); + } + + //企业图片 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(FileInfoDO::getDictType, 644l); + wrapper.eq(FileInfoDO::getDictData, 1l); + wrapper.eq(FileInfoDO::getUnitId, item.getId()); + final List collect = fileInfoMapper.selectList(wrapper).stream().map(res -> res.getInfraFileId()).collect(Collectors.toList()); + + if (!collect.isEmpty()) { + final List list = fileApi.listFile(collect); + item.setFiles(list); + } + + // 企业标签 + LambdaQueryWrapper tagDOLambdaQueryWrapper = new LambdaQueryWrapper<>(); + tagDOLambdaQueryWrapper.eq(EnterpriseTagDO::getEnterpriseId, item.getId()); + List enterpriseTagDOS = enterpriseTagMapper.selectList(tagDOLambdaQueryWrapper); + if (enterpriseTagDOS != null && enterpriseTagDOS.size() > 0) { + List tagIds = enterpriseTagDOS.stream().map(EnterpriseTagDO::getTagId).collect(Collectors.toList()); + List tagLibraryDOS = tagLibraryMapper.selectList(new LambdaQueryWrapper().in(TagLibraryDO::getId, tagIds)); + if (tagLibraryDOS != null && tagLibraryDOS.size() > 0) { + List tagNames = tagLibraryDOS.stream().map(TagLibraryDO::getTagName).collect(Collectors.toList()); + item.setTagList(tagNames); + } + } + }); + return success(BeanUtils.toBean(pageResult, EnterpriseRespVO.class)); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseRespVO.java index e460662..e4436f4 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseRespVO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.system.controller.admin.enterprise.vo; import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; +import cn.iocoder.yudao.module.system.dal.dataobject.taglibrary.TagLibraryDO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; @@ -93,4 +94,8 @@ public class EnterpriseRespVO { @Schema(description = "企业资质列表", example = "26433") private List qualificationList; + @Schema(description = "企业标签", example = "26433") + private List tagList; + + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprisetag/EnterpriseTagController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprisetag/EnterpriseTagController.java new file mode 100644 index 0000000..8ff1cfd --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprisetag/EnterpriseTagController.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.system.controller.admin.enterprisetag; + +import org.springframework.web.bind.annotation.*; +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 java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.system.controller.admin.enterprisetag.vo.*; +import cn.iocoder.yudao.module.system.dal.dataobject.enterprisetag.EnterpriseTagDO; +import cn.iocoder.yudao.module.system.service.enterprisetag.EnterpriseTagService; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; + +@Tag(name = "管理后台 - 企业标签") +@RestController +@RequestMapping("/system/enterprise-tag") +@Validated +public class EnterpriseTagController { + + @Resource + private EnterpriseTagService enterpriseTagService; + + @PostMapping("/create") + @Operation(summary = "创建企业标签") + @PreAuthorize("@ss.hasPermission('system:enterprise-tag:create')") + public CommonResult createEnterpriseTag(@Valid @RequestBody EnterpriseTagSaveReqVO createReqVO) { + return success(enterpriseTagService.createEnterpriseTag(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新企业标签") + @PreAuthorize("@ss.hasPermission('system:enterprise-tag:update')") + public CommonResult updateEnterpriseTag(@Valid @RequestBody EnterpriseTagSaveReqVO updateReqVO) { + enterpriseTagService.updateEnterpriseTag(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除企业标签") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('system:enterprise-tag:delete')") + public CommonResult deleteEnterpriseTag(@RequestParam("id") Long id) { + enterpriseTagService.deleteEnterpriseTag(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得企业标签") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('system:enterprise-tag:query')") + public CommonResult getEnterpriseTag(@RequestParam("id") Long id) { + EnterpriseTagDO enterpriseTag = enterpriseTagService.getEnterpriseTag(id); + return success(BeanUtils.toBean(enterpriseTag, EnterpriseTagRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得企业标签分页") + @PreAuthorize("@ss.hasPermission('system:enterprise-tag:query')") + public CommonResult> getEnterpriseTagPage(@Valid EnterpriseTagPageReqVO pageReqVO) { + PageResult pageResult = enterpriseTagService.getEnterpriseTagPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, EnterpriseTagRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出企业标签 Excel") + @PreAuthorize("@ss.hasPermission('system:enterprise-tag:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportEnterpriseTagExcel(@Valid EnterpriseTagPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = enterpriseTagService.getEnterpriseTagPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "企业标签.xls", "数据", EnterpriseTagRespVO.class, + BeanUtils.toBean(list, EnterpriseTagRespVO.class)); + } + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprisetag/vo/EnterpriseTagPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprisetag/vo/EnterpriseTagPageReqVO.java new file mode 100644 index 0000000..a19dda9 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprisetag/vo/EnterpriseTagPageReqVO.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.system.controller.admin.enterprisetag.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 = "管理后台 - 企业标签分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class EnterpriseTagPageReqVO extends PageParam { + + @Schema(description = "企业id", example = "32136") + private Long enterpriseId; + + @Schema(description = "标签id", example = "13027") + private Long tagId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprisetag/vo/EnterpriseTagRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprisetag/vo/EnterpriseTagRespVO.java new file mode 100644 index 0000000..a4d15d5 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprisetag/vo/EnterpriseTagRespVO.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.system.controller.admin.enterprisetag.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 企业标签 Response VO") +@Data +@ExcelIgnoreUnannotated +public class EnterpriseTagRespVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "19630") + @ExcelProperty("主键") + private Long id; + + @Schema(description = "企业id", example = "32136") + @ExcelProperty("企业id") + private Long enterpriseId; + + @Schema(description = "标签id", example = "13027") + @ExcelProperty("标签id") + private Long tagId; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprisetag/vo/EnterpriseTagSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprisetag/vo/EnterpriseTagSaveReqVO.java new file mode 100644 index 0000000..1f785db --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprisetag/vo/EnterpriseTagSaveReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.system.controller.admin.enterprisetag.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; + +@Schema(description = "管理后台 - 企业标签新增/修改 Request VO") +@Data +public class EnterpriseTagSaveReqVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "19630") + private Long id; + + @Schema(description = "企业id", example = "32136") + private Long enterpriseId; + + @Schema(description = "标签id", example = "13027") + private Long tagId; + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java index a9ec972..1a8d92f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.system.dal.dataobject.enterprise; import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; +import cn.iocoder.yudao.module.system.dal.dataobject.taglibrary.TagLibraryDO; import lombok.*; import java.time.LocalDate; @@ -93,4 +94,7 @@ public class EnterpriseDO extends BaseDO { @TableField(exist = false) private List qualificationList; + @TableField(exist = false) + private List tagList; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprisetag/EnterpriseTagDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprisetag/EnterpriseTagDO.java new file mode 100644 index 0000000..3573f86 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprisetag/EnterpriseTagDO.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.system.dal.dataobject.enterprisetag; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 企业标签 DO + * + * @author 芋道源码 + */ +@TableName("enterprise_tag") +@KeySequence("enterprise_tag_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class EnterpriseTagDO extends BaseDO { + + /** + * 主键 + */ + @TableId + private Long id; + /** + * 企业id + */ + private Long enterpriseId; + /** + * 标签id + */ + private Long tagId; + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprisetag/EnterpriseTagMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprisetag/EnterpriseTagMapper.java new file mode 100644 index 0000000..7ebf3f0 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprisetag/EnterpriseTagMapper.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.system.dal.mysql.enterprisetag; + +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.system.dal.dataobject.enterprisetag.EnterpriseTagDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.system.controller.admin.enterprisetag.vo.*; + +/** + * 企业标签 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface EnterpriseTagMapper extends BaseMapperX { + + default PageResult selectPage(EnterpriseTagPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(EnterpriseTagDO::getEnterpriseId, reqVO.getEnterpriseId()) + .eqIfPresent(EnterpriseTagDO::getTagId, reqVO.getTagId()) + .betweenIfPresent(EnterpriseTagDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(EnterpriseTagDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprisetag/EnterpriseTagService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprisetag/EnterpriseTagService.java new file mode 100644 index 0000000..793649a --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprisetag/EnterpriseTagService.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.system.service.enterprisetag; + +import java.util.*; +import cn.iocoder.yudao.module.system.controller.admin.enterprisetag.vo.*; +import cn.iocoder.yudao.module.system.dal.dataobject.enterprisetag.EnterpriseTagDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +import javax.validation.Valid; + +/** + * 企业标签 Service 接口 + * + * @author 芋道源码 + */ +public interface EnterpriseTagService { + + /** + * 创建企业标签 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createEnterpriseTag(@Valid EnterpriseTagSaveReqVO createReqVO); + + /** + * 更新企业标签 + * + * @param updateReqVO 更新信息 + */ + void updateEnterpriseTag(@Valid EnterpriseTagSaveReqVO updateReqVO); + + /** + * 删除企业标签 + * + * @param id 编号 + */ + void deleteEnterpriseTag(Long id); + + /** + * 获得企业标签 + * + * @param id 编号 + * @return 企业标签 + */ + EnterpriseTagDO getEnterpriseTag(Long id); + + /** + * 获得企业标签分页 + * + * @param pageReqVO 分页查询 + * @return 企业标签分页 + */ + PageResult getEnterpriseTagPage(EnterpriseTagPageReqVO pageReqVO); + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprisetag/EnterpriseTagServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprisetag/EnterpriseTagServiceImpl.java new file mode 100644 index 0000000..f31994b --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprisetag/EnterpriseTagServiceImpl.java @@ -0,0 +1,75 @@ +package cn.iocoder.yudao.module.system.service.enterprisetag; + +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.system.controller.admin.enterprisetag.vo.*; +import cn.iocoder.yudao.module.system.dal.dataobject.enterprisetag.EnterpriseTagDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.system.dal.mysql.enterprisetag.EnterpriseTagMapper; + +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; + +/** + * 企业标签 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class EnterpriseTagServiceImpl implements EnterpriseTagService { + + @Resource + private EnterpriseTagMapper enterpriseTagMapper; + + @Override + public Long createEnterpriseTag(EnterpriseTagSaveReqVO createReqVO) { + // 插入 + EnterpriseTagDO enterpriseTag = BeanUtils.toBean(createReqVO, EnterpriseTagDO.class); + enterpriseTagMapper.insert(enterpriseTag); + // 返回 + return enterpriseTag.getId(); + } + + @Override + public void updateEnterpriseTag(EnterpriseTagSaveReqVO updateReqVO) { + // 校验存在 + validateEnterpriseTagExists(updateReqVO.getId()); + // 更新 + EnterpriseTagDO updateObj = BeanUtils.toBean(updateReqVO, EnterpriseTagDO.class); + enterpriseTagMapper.updateById(updateObj); + } + + @Override + public void deleteEnterpriseTag(Long id) { + // 校验存在 + validateEnterpriseTagExists(id); + // 删除 + enterpriseTagMapper.deleteById(id); + } + + private void validateEnterpriseTagExists(Long id) { + if (enterpriseTagMapper.selectById(id) == null) { + throw exception(USER_MOBILE_EXISTS); + } + } + + @Override + public EnterpriseTagDO getEnterpriseTag(Long id) { + return enterpriseTagMapper.selectById(id); + } + + @Override + public PageResult getEnterpriseTagPage(EnterpriseTagPageReqVO pageReqVO) { + return enterpriseTagMapper.selectPage(pageReqVO); + } + +}