Compare commits
	
		
			5 Commits 
		
	
	
		
			23906540cf
			...
			0ae2d562a0
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 0ae2d562a0 | 9 months ago | 
|  | 8678f85294 | 9 months ago | 
|  | 43444095ca | 9 months ago | 
|  | 7aeb8b22f5 | 9 months ago | 
|  | e1df6c86f3 | 9 months ago | 
				 24 changed files with 676 additions and 9 deletions
			
			
		| @ -0,0 +1,95 @@ | |||||||
|  | package cn.iocoder.yudao.module.system.controller.admin.enterprises; | ||||||
|  | 
 | ||||||
|  | import org.springframework.web.bind.annotation.*; | ||||||
|  | import jakarta.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 jakarta.validation.constraints.*; | ||||||
|  | import jakarta.validation.*; | ||||||
|  | import jakarta.servlet.http.*; | ||||||
|  | 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.enterprises.vo.*; | ||||||
|  | import cn.iocoder.yudao.module.system.dal.dataobject.enterprises.EnterprisesDO; | ||||||
|  | import cn.iocoder.yudao.module.system.service.enterprises.EnterprisesService; | ||||||
|  | 
 | ||||||
|  | @Tag(name = "管理后台 - 企业") | ||||||
|  | @RestController | ||||||
|  | @RequestMapping("/system/enterprises") | ||||||
|  | @Validated | ||||||
|  | public class EnterprisesController { | ||||||
|  | 
 | ||||||
|  |     @Resource | ||||||
|  |     private EnterprisesService enterprisesService; | ||||||
|  | 
 | ||||||
|  |     @PostMapping("/create") | ||||||
|  |     @Operation(summary = "创建企业") | ||||||
|  |     @PreAuthorize("@ss.hasPermission('system:enterprises:create')") | ||||||
|  |     public CommonResult<Long> createEnterprises(@Valid @RequestBody EnterprisesSaveReqVO createReqVO) { | ||||||
|  |         return success(enterprisesService.createEnterprises(createReqVO)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @PutMapping("/update") | ||||||
|  |     @Operation(summary = "更新企业") | ||||||
|  |     @PreAuthorize("@ss.hasPermission('system:enterprises:update')") | ||||||
|  |     public CommonResult<Boolean> updateEnterprises(@Valid @RequestBody EnterprisesSaveReqVO updateReqVO) { | ||||||
|  |         enterprisesService.updateEnterprises(updateReqVO); | ||||||
|  |         return success(true); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @DeleteMapping("/delete") | ||||||
|  |     @Operation(summary = "删除企业") | ||||||
|  |     @Parameter(name = "id", description = "编号", required = true) | ||||||
|  |     @PreAuthorize("@ss.hasPermission('system:enterprises:delete')") | ||||||
|  |     public CommonResult<Boolean> deleteEnterprises(@RequestParam("id") Long id) { | ||||||
|  |         enterprisesService.deleteEnterprises(id); | ||||||
|  |         return success(true); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @GetMapping("/get") | ||||||
|  |     @Operation(summary = "获得企业") | ||||||
|  |     @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||||||
|  |     @PreAuthorize("@ss.hasPermission('system:enterprises:query')") | ||||||
|  |     public CommonResult<EnterprisesRespVO> getEnterprises(@RequestParam("id") Long id) { | ||||||
|  |         EnterprisesDO enterprises = enterprisesService.getEnterprises(id); | ||||||
|  |         return success(BeanUtils.toBean(enterprises, EnterprisesRespVO.class)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @GetMapping("/page") | ||||||
|  |     @Operation(summary = "获得企业分页") | ||||||
|  |     @PreAuthorize("@ss.hasPermission('system:enterprises:query')") | ||||||
|  |     public CommonResult<PageResult<EnterprisesRespVO>> getEnterprisesPage(@Valid EnterprisesPageReqVO pageReqVO) { | ||||||
|  |         PageResult<EnterprisesDO> pageResult = enterprisesService.getEnterprisesPage(pageReqVO); | ||||||
|  |         return success(BeanUtils.toBean(pageResult, EnterprisesRespVO.class)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @GetMapping("/export-excel") | ||||||
|  |     @Operation(summary = "导出企业 Excel") | ||||||
|  |     @PreAuthorize("@ss.hasPermission('system:enterprises:export')") | ||||||
|  |     @ApiAccessLog(operateType = EXPORT) | ||||||
|  |     public void exportEnterprisesExcel(@Valid EnterprisesPageReqVO pageReqVO, | ||||||
|  |               HttpServletResponse response) throws IOException { | ||||||
|  |         pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||||||
|  |         List<EnterprisesDO> list = enterprisesService.getEnterprisesPage(pageReqVO).getList(); | ||||||
|  |         // 导出 Excel
 | ||||||
|  |         ExcelUtils.write(response, "企业.xls", "数据", EnterprisesRespVO.class, | ||||||
|  |                         BeanUtils.toBean(list, EnterprisesRespVO.class)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,62 @@ | |||||||
|  | package cn.iocoder.yudao.module.system.controller.admin.enterprises.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 EnterprisesPageReqVO extends PageParam { | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "所属部门ID", example = "15442") | ||||||
|  |     private Long departmentId; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "邀请人", example = "981") | ||||||
|  |     private Long userId; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业类型", example = "1") | ||||||
|  |     private String type; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业所属区域") | ||||||
|  |     private String region; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业名称", example = "芋艿") | ||||||
|  |     private String enterprisesName; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业地址") | ||||||
|  |     private String address; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "环保负责人姓名", example = "王五") | ||||||
|  |     private String contactName; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业环保负责人联系电话") | ||||||
|  |     private String environmentalContactPhone; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业注册号") | ||||||
|  |     private String registrationNumber; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业图文介绍") | ||||||
|  |     private String introduction; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业成立时间") | ||||||
|  |     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||||
|  |     private LocalDate[] establishmentDate; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业经纬度") | ||||||
|  |     private String gpsLocation; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "创建时间") | ||||||
|  |     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||||
|  |     private LocalDateTime[] createTime; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "管理部门", example = "978") | ||||||
|  |     private Long managerDeptId; | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,79 @@ | |||||||
|  | package cn.iocoder.yudao.module.system.controller.admin.enterprises.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.*; | ||||||
|  | import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | ||||||
|  | import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | ||||||
|  | 
 | ||||||
|  | @Schema(description = "管理后台 - 企业 Response VO") | ||||||
|  | @Data | ||||||
|  | @ExcelIgnoreUnannotated | ||||||
|  | public class EnterprisesRespVO { | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业ID,主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "13265") | ||||||
|  |     @ExcelProperty("企业ID,主键") | ||||||
|  |     private Long id; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "所属部门ID", example = "15442") | ||||||
|  |     @ExcelProperty("所属部门ID") | ||||||
|  |     private Long departmentId; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "邀请人", example = "981") | ||||||
|  |     @ExcelProperty("邀请人") | ||||||
|  |     private Long userId; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||||||
|  |     @ExcelProperty(value = "企业类型", converter = DictConvert.class) | ||||||
|  |     @DictFormat("enterprises_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
 | ||||||
|  |     private String type; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业所属区域") | ||||||
|  |     @ExcelProperty(value = "企业所属区域", converter = DictConvert.class) | ||||||
|  |     @DictFormat("enterprises_area") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
 | ||||||
|  |     private String region; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||||||
|  |     @ExcelProperty("企业名称") | ||||||
|  |     private String enterprisesName; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业地址") | ||||||
|  |     @ExcelProperty("企业地址") | ||||||
|  |     private String address; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "环保负责人姓名", example = "王五") | ||||||
|  |     @ExcelProperty("环保负责人姓名") | ||||||
|  |     private String contactName; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业环保负责人联系电话") | ||||||
|  |     @ExcelProperty("企业环保负责人联系电话") | ||||||
|  |     private String environmentalContactPhone; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业注册号") | ||||||
|  |     @ExcelProperty("企业注册号") | ||||||
|  |     private String registrationNumber; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业图文介绍") | ||||||
|  |     @ExcelProperty("企业图文介绍") | ||||||
|  |     private String introduction; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业成立时间") | ||||||
|  |     @ExcelProperty("企业成立时间") | ||||||
|  |     private LocalDate establishmentDate; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业经纬度") | ||||||
|  |     @ExcelProperty("企业经纬度") | ||||||
|  |     private String gpsLocation; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||||||
|  |     @ExcelProperty("创建时间") | ||||||
|  |     private LocalDateTime createTime; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "管理部门", example = "978") | ||||||
|  |     @ExcelProperty("管理部门") | ||||||
|  |     private Long managerDeptId; | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,56 @@ | |||||||
|  | package cn.iocoder.yudao.module.system.controller.admin.enterprises.vo; | ||||||
|  | 
 | ||||||
|  | import io.swagger.v3.oas.annotations.media.Schema; | ||||||
|  | import lombok.*; | ||||||
|  | import java.util.*; | ||||||
|  | import jakarta.validation.constraints.*; | ||||||
|  | 
 | ||||||
|  | @Schema(description = "管理后台 - 企业新增/修改 Request VO") | ||||||
|  | @Data | ||||||
|  | public class EnterprisesSaveReqVO { | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业ID,主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "13265") | ||||||
|  |     private Long id; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "所属部门ID", example = "15442") | ||||||
|  |     private Long departmentId; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "邀请人", example = "981") | ||||||
|  |     private Long userId; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||||||
|  |     @NotEmpty(message = "企业类型不能为空") | ||||||
|  |     private String type; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业所属区域") | ||||||
|  |     private String region; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||||||
|  |     @NotEmpty(message = "企业名称不能为空") | ||||||
|  |     private String enterprisesName; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业地址") | ||||||
|  |     private String address; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "环保负责人姓名", example = "王五") | ||||||
|  |     private String contactName; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业环保负责人联系电话") | ||||||
|  |     private String environmentalContactPhone; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业注册号") | ||||||
|  |     private String registrationNumber; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业图文介绍") | ||||||
|  |     private String introduction; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业成立时间") | ||||||
|  |     private LocalDate establishmentDate; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "企业经纬度") | ||||||
|  |     private String gpsLocation; | ||||||
|  | 
 | ||||||
|  |     @Schema(description = "管理部门", example = "978") | ||||||
|  |     private Long managerDeptId; | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,87 @@ | |||||||
|  | package cn.iocoder.yudao.module.system.dal.dataobject.enterprises; | ||||||
|  | 
 | ||||||
|  | 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("enterprises") | ||||||
|  | @KeySequence("enterprises_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
 | ||||||
|  | @Data | ||||||
|  | @EqualsAndHashCode(callSuper = true) | ||||||
|  | @ToString(callSuper = true) | ||||||
|  | @Builder | ||||||
|  | @NoArgsConstructor | ||||||
|  | @AllArgsConstructor | ||||||
|  | public class EnterprisesDO extends BaseDO { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 企业ID,主键 | ||||||
|  |      */ | ||||||
|  |     @TableId | ||||||
|  |     private Long id; | ||||||
|  |     /** | ||||||
|  |      * 所属部门ID | ||||||
|  |      */ | ||||||
|  |     private Long departmentId; | ||||||
|  |     /** | ||||||
|  |      * 邀请人 | ||||||
|  |      */ | ||||||
|  |     private Long userId; | ||||||
|  |     /** | ||||||
|  |      * 企业类型 | ||||||
|  |      * | ||||||
|  |      * 枚举 {@link TODO enterprises_type 对应的类} | ||||||
|  |      */ | ||||||
|  |     private String type; | ||||||
|  |     /** | ||||||
|  |      * 企业所属区域 | ||||||
|  |      * | ||||||
|  |      * 枚举 {@link TODO enterprises_area 对应的类} | ||||||
|  |      */ | ||||||
|  |     private String region; | ||||||
|  |     /** | ||||||
|  |      * 企业名称 | ||||||
|  |      */ | ||||||
|  |     private String enterprisesName; | ||||||
|  |     /** | ||||||
|  |      * 企业地址 | ||||||
|  |      */ | ||||||
|  |     private String address; | ||||||
|  |     /** | ||||||
|  |      * 环保负责人姓名 | ||||||
|  |      */ | ||||||
|  |     private String contactName; | ||||||
|  |     /** | ||||||
|  |      * 企业环保负责人联系电话 | ||||||
|  |      */ | ||||||
|  |     private String environmentalContactPhone; | ||||||
|  |     /** | ||||||
|  |      * 企业注册号 | ||||||
|  |      */ | ||||||
|  |     private String registrationNumber; | ||||||
|  |     /** | ||||||
|  |      * 企业图文介绍 | ||||||
|  |      */ | ||||||
|  |     private String introduction; | ||||||
|  |     /** | ||||||
|  |      * 企业成立时间 | ||||||
|  |      */ | ||||||
|  |     private LocalDate establishmentDate; | ||||||
|  |     /** | ||||||
|  |      * 企业经纬度 | ||||||
|  |      */ | ||||||
|  |     private String gpsLocation; | ||||||
|  |     /** | ||||||
|  |      * 管理部门 | ||||||
|  |      */ | ||||||
|  |     private Long managerDeptId; | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,39 @@ | |||||||
|  | package cn.iocoder.yudao.module.system.dal.mysql.enterprises; | ||||||
|  | 
 | ||||||
|  | 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.enterprises.EnterprisesDO; | ||||||
|  | import org.apache.ibatis.annotations.Mapper; | ||||||
|  | import cn.iocoder.yudao.module.system.controller.admin.enterprises.vo.*; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 企业 Mapper | ||||||
|  |  * | ||||||
|  |  * @author 芋道源码 | ||||||
|  |  */ | ||||||
|  | @Mapper | ||||||
|  | public interface EnterprisesMapper extends BaseMapperX<EnterprisesDO> { | ||||||
|  | 
 | ||||||
|  |     default PageResult<EnterprisesDO> selectPage(EnterprisesPageReqVO reqVO) { | ||||||
|  |         return selectPage(reqVO, new LambdaQueryWrapperX<EnterprisesDO>() | ||||||
|  |                 .eqIfPresent(EnterprisesDO::getDepartmentId, reqVO.getDepartmentId()) | ||||||
|  |                 .eqIfPresent(EnterprisesDO::getUserId, reqVO.getUserId()) | ||||||
|  |                 .eqIfPresent(EnterprisesDO::getType, reqVO.getType()) | ||||||
|  |                 .eqIfPresent(EnterprisesDO::getRegion, reqVO.getRegion()) | ||||||
|  |                 .likeIfPresent(EnterprisesDO::getEnterprisesName, reqVO.getEnterprisesName()) | ||||||
|  |                 .eqIfPresent(EnterprisesDO::getAddress, reqVO.getAddress()) | ||||||
|  |                 .likeIfPresent(EnterprisesDO::getContactName, reqVO.getContactName()) | ||||||
|  |                 .eqIfPresent(EnterprisesDO::getEnvironmentalContactPhone, reqVO.getEnvironmentalContactPhone()) | ||||||
|  |                 .eqIfPresent(EnterprisesDO::getRegistrationNumber, reqVO.getRegistrationNumber()) | ||||||
|  |                 .eqIfPresent(EnterprisesDO::getIntroduction, reqVO.getIntroduction()) | ||||||
|  |                 .betweenIfPresent(EnterprisesDO::getEstablishmentDate, reqVO.getEstablishmentDate()) | ||||||
|  |                 .eqIfPresent(EnterprisesDO::getGpsLocation, reqVO.getGpsLocation()) | ||||||
|  |                 .betweenIfPresent(EnterprisesDO::getCreateTime, reqVO.getCreateTime()) | ||||||
|  |                 .eqIfPresent(EnterprisesDO::getManagerDeptId, reqVO.getManagerDeptId()) | ||||||
|  |                 .orderByDesc(EnterprisesDO::getId)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,55 @@ | |||||||
|  | package cn.iocoder.yudao.module.system.service.enterprises; | ||||||
|  | 
 | ||||||
|  | import java.util.*; | ||||||
|  | import jakarta.validation.*; | ||||||
|  | import cn.iocoder.yudao.module.system.controller.admin.enterprises.vo.*; | ||||||
|  | import cn.iocoder.yudao.module.system.dal.dataobject.enterprises.EnterprisesDO; | ||||||
|  | import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||||
|  | import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 企业 Service 接口 | ||||||
|  |  * | ||||||
|  |  * @author 芋道源码 | ||||||
|  |  */ | ||||||
|  | public interface EnterprisesService { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 创建企业 | ||||||
|  |      * | ||||||
|  |      * @param createReqVO 创建信息 | ||||||
|  |      * @return 编号 | ||||||
|  |      */ | ||||||
|  |     Long createEnterprises(@Valid EnterprisesSaveReqVO createReqVO); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 更新企业 | ||||||
|  |      * | ||||||
|  |      * @param updateReqVO 更新信息 | ||||||
|  |      */ | ||||||
|  |     void updateEnterprises(@Valid EnterprisesSaveReqVO updateReqVO); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 删除企业 | ||||||
|  |      * | ||||||
|  |      * @param id 编号 | ||||||
|  |      */ | ||||||
|  |     void deleteEnterprises(Long id); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 获得企业 | ||||||
|  |      * | ||||||
|  |      * @param id 编号 | ||||||
|  |      * @return 企业 | ||||||
|  |      */ | ||||||
|  |     EnterprisesDO getEnterprises(Long id); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 获得企业分页 | ||||||
|  |      * | ||||||
|  |      * @param pageReqVO 分页查询 | ||||||
|  |      * @return 企业分页 | ||||||
|  |      */ | ||||||
|  |     PageResult<EnterprisesDO> getEnterprisesPage(EnterprisesPageReqVO pageReqVO); | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,74 @@ | |||||||
|  | package cn.iocoder.yudao.module.system.service.enterprises; | ||||||
|  | 
 | ||||||
|  | import org.springframework.stereotype.Service; | ||||||
|  | import jakarta.annotation.Resource; | ||||||
|  | import org.springframework.validation.annotation.Validated; | ||||||
|  | import org.springframework.transaction.annotation.Transactional; | ||||||
|  | 
 | ||||||
|  | import java.util.*; | ||||||
|  | import cn.iocoder.yudao.module.system.controller.admin.enterprises.vo.*; | ||||||
|  | import cn.iocoder.yudao.module.system.dal.dataobject.enterprises.EnterprisesDO; | ||||||
|  | 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.enterprises.EnterprisesMapper; | ||||||
|  | 
 | ||||||
|  | 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 EnterprisesServiceImpl implements EnterprisesService { | ||||||
|  | 
 | ||||||
|  |     @Resource | ||||||
|  |     private EnterprisesMapper enterprisesMapper; | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public Long createEnterprises(EnterprisesSaveReqVO createReqVO) { | ||||||
|  |         // 插入
 | ||||||
|  |         EnterprisesDO enterprises = BeanUtils.toBean(createReqVO, EnterprisesDO.class); | ||||||
|  |         enterprisesMapper.insert(enterprises); | ||||||
|  |         // 返回
 | ||||||
|  |         return enterprises.getId(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public void updateEnterprises(EnterprisesSaveReqVO updateReqVO) { | ||||||
|  |         // 校验存在
 | ||||||
|  |         validateEnterprisesExists(updateReqVO.getId()); | ||||||
|  |         // 更新
 | ||||||
|  |         EnterprisesDO updateObj = BeanUtils.toBean(updateReqVO, EnterprisesDO.class); | ||||||
|  |         enterprisesMapper.updateById(updateObj); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public void deleteEnterprises(Long id) { | ||||||
|  |         // 校验存在
 | ||||||
|  |         validateEnterprisesExists(id); | ||||||
|  |         // 删除
 | ||||||
|  |         enterprisesMapper.deleteById(id); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private void validateEnterprisesExists(Long id) { | ||||||
|  |         if (enterprisesMapper.selectById(id) == null) { | ||||||
|  |             throw exception(ENTERPRISES_NOT_EXISTS); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public EnterprisesDO getEnterprises(Long id) { | ||||||
|  |         return enterprisesMapper.selectById(id); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public PageResult<EnterprisesDO> getEnterprisesPage(EnterprisesPageReqVO pageReqVO) { | ||||||
|  |         return enterprisesMapper.selectPage(pageReqVO); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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.system.dal.mysql.enterprises.EnterprisesMapper"> | ||||||
|  | 
 | ||||||
|  |     <!-- | ||||||
|  |         一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | ||||||
|  |         无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | ||||||
|  |         代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | ||||||
|  |         文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | ||||||
|  |      --> | ||||||
|  | 
 | ||||||
|  | </mapper> | ||||||
					Loading…
					
					
				
		Reference in new issue