21 changed files with 473 additions and 55 deletions
			
			
		| @ -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<Long> createEnterpriseTag(@Valid @RequestBody EnterpriseTagSaveReqVO createReqVO) { | ||||||
|  |         return success(enterpriseTagService.createEnterpriseTag(createReqVO)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @PutMapping("/update") | ||||||
|  |     @Operation(summary = "更新企业标签") | ||||||
|  |     @PreAuthorize("@ss.hasPermission('system:enterprise-tag:update')") | ||||||
|  |     public CommonResult<Boolean> 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<Boolean> 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<EnterpriseTagRespVO> 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<PageResult<EnterpriseTagRespVO>> getEnterpriseTagPage(@Valid EnterpriseTagPageReqVO pageReqVO) { | ||||||
|  |         PageResult<EnterpriseTagDO> 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<EnterpriseTagDO> list = enterpriseTagService.getEnterpriseTagPage(pageReqVO).getList(); | ||||||
|  |         // 导出 Excel
 | ||||||
|  |         ExcelUtils.write(response, "企业标签.xls", "数据", EnterpriseTagRespVO.class, | ||||||
|  |                         BeanUtils.toBean(list, EnterpriseTagRespVO.class)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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; | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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; | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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; | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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; | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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<EnterpriseTagDO> { | ||||||
|  | 
 | ||||||
|  |     default PageResult<EnterpriseTagDO> selectPage(EnterpriseTagPageReqVO reqVO) { | ||||||
|  |         return selectPage(reqVO, new LambdaQueryWrapperX<EnterpriseTagDO>() | ||||||
|  |                 .eqIfPresent(EnterpriseTagDO::getEnterpriseId, reqVO.getEnterpriseId()) | ||||||
|  |                 .eqIfPresent(EnterpriseTagDO::getTagId, reqVO.getTagId()) | ||||||
|  |                 .betweenIfPresent(EnterpriseTagDO::getCreateTime, reqVO.getCreateTime()) | ||||||
|  |                 .orderByDesc(EnterpriseTagDO::getId)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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<EnterpriseTagDO> getEnterpriseTagPage(EnterpriseTagPageReqVO pageReqVO); | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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<EnterpriseTagDO> getEnterpriseTagPage(EnterpriseTagPageReqVO pageReqVO) { | ||||||
|  |         return enterpriseTagMapper.selectPage(pageReqVO); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
					Loading…
					
					
				
		Reference in new issue