38 changed files with 1090 additions and 10 deletions
@ -0,0 +1,40 @@ |
|||||
|
package cn.iocoder.yudao.module.alert.controller.admin.device; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
||||
|
import cn.iocoder.yudao.module.alert.controller.admin.calcgroup.vo.CalcGroupPageReqVO; |
||||
|
import cn.iocoder.yudao.module.alert.controller.admin.calcgroup.vo.CalcGroupRespVO; |
||||
|
import cn.iocoder.yudao.module.alert.controller.admin.device.vo.DeviceRespVO; |
||||
|
import cn.iocoder.yudao.module.alert.dal.dataobject.calcgroup.CalcGroupDO; |
||||
|
import cn.iocoder.yudao.module.alert.dal.dataobject.device.DeviceDO; |
||||
|
import cn.iocoder.yudao.module.alert.service.calcgroup.CalcGroupService; |
||||
|
import cn.iocoder.yudao.module.alert.service.device.DeviceService; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import jakarta.annotation.Resource; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.Comparator; |
||||
|
import java.util.List; |
||||
|
|
||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
||||
|
|
||||
|
@Tag(name = "设备 - 设备首页") |
||||
|
@RestController |
||||
|
@RequestMapping("/device") |
||||
|
@Validated |
||||
|
public class DeviceController { |
||||
|
@Resource |
||||
|
private DeviceService deviceService; |
||||
|
|
||||
|
@GetMapping("/info") |
||||
|
@Operation(summary = "获取页面属性", description = "用于构造前端页面") |
||||
|
public CommonResult<DeviceRespVO> getdeviceInfo(Long id) { |
||||
|
DeviceDO list = deviceService.getDeviceInfo(id); |
||||
|
return success(BeanUtils.toBean(list, DeviceRespVO.class)); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
package cn.iocoder.yudao.module.alert.controller.admin.device.vo; |
||||
|
|
||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Schema(description = "设备 - 设备首页") |
||||
|
@Data |
||||
|
@ExcelIgnoreUnannotated |
||||
|
public class DeviceRespVO { |
||||
|
@JsonProperty("ID") |
||||
|
|
||||
|
@Schema(description = "id", example = "id") |
||||
|
private Long id; |
||||
|
|
||||
|
@JsonProperty("Unit_ID") |
||||
|
@Schema(description = "机组id", example = "id") |
||||
|
|
||||
|
private Long unitId; |
||||
|
|
||||
|
@JsonProperty("System_ID") |
||||
|
|
||||
|
@Schema(description = "系统id", example = "id") |
||||
|
|
||||
|
private Long systemId; |
||||
|
|
||||
|
@JsonProperty("Name") |
||||
|
|
||||
|
@Schema(description = "页面名称", example = "yudao") |
||||
|
private String name; |
||||
|
|
||||
|
@JsonProperty("Page_Content") |
||||
|
|
||||
|
@Schema(description = "页面信息", example = "yudao") |
||||
|
private String pageContent; |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
package cn.iocoder.yudao.module.alert.controller.admin.instant; |
||||
|
|
||||
|
import cn.iocoder.yudao.module.alert.service.instant.InstantService; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import jakarta.annotation.Resource; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
@Tag(name = "运行中心 - 模型实例-回算") |
||||
|
@RestController |
||||
|
@RequestMapping("/alert/instant/calc") |
||||
|
@Validated |
||||
|
public class InstantCalcController { |
||||
|
@Resource |
||||
|
private InstantService instantService; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,46 @@ |
|||||
|
package cn.iocoder.yudao.module.alert.dal.dataobject.device; |
||||
|
|
||||
|
import com.baomidou.dynamic.datasource.annotation.DS; |
||||
|
import com.baomidou.mybatisplus.annotation.KeySequence; |
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import com.fasterxml.jackson.annotation.JsonAlias; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
@DS("slave") |
||||
|
@TableName(value = "Page_Display", autoResultMap = true) |
||||
|
@KeySequence("system_role_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = false) |
||||
|
public class DeviceDO { |
||||
|
@TableId("ID") |
||||
|
|
||||
|
@Schema(description = "id", example = "id") |
||||
|
private Long id; |
||||
|
|
||||
|
@TableField("Unit_ID") |
||||
|
@Schema(description = "机组id", example = "id") |
||||
|
|
||||
|
private Long unitId; |
||||
|
|
||||
|
@TableField("System_ID") |
||||
|
|
||||
|
@Schema(description = "系统id", example = "id") |
||||
|
|
||||
|
private Long systemId; |
||||
|
|
||||
|
@TableField("Name") |
||||
|
|
||||
|
@Schema(description = "页面名称", example = "yudao") |
||||
|
private String name; |
||||
|
|
||||
|
@TableField("Page_Content") |
||||
|
|
||||
|
@Schema(description = "页面信息", example = "yudao") |
||||
|
private String pageContent; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
package cn.iocoder.yudao.module.alert.dal.mysql.device; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
||||
|
import cn.iocoder.yudao.module.alert.dal.dataobject.device.DeviceDO; |
||||
|
import cn.iocoder.yudao.module.alert.dal.dataobject.instant.InstantTableDO; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface DeviceMapper extends BaseMapperX<DeviceDO> { |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package cn.iocoder.yudao.module.alert.service.device; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
|
import cn.iocoder.yudao.module.alert.controller.admin.instant.vo.*; |
||||
|
import cn.iocoder.yudao.module.alert.dal.dataobject.device.DeviceDO; |
||||
|
import cn.iocoder.yudao.module.alert.dal.dataobject.instant.InstantDO; |
||||
|
import jakarta.validation.Valid; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface DeviceService { |
||||
|
DeviceDO getDeviceInfo(Long id); |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,52 @@ |
|||||
|
package cn.iocoder.yudao.module.alert.service.device; |
||||
|
|
||||
|
import cn.hutool.core.util.ObjUtil; |
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
||||
|
import cn.iocoder.yudao.module.alert.controller.admin.exa.vo.Point; |
||||
|
import cn.iocoder.yudao.module.alert.controller.admin.instant.vo.*; |
||||
|
import cn.iocoder.yudao.module.alert.controller.admin.model.vo.RunModelInfoVO; |
||||
|
import cn.iocoder.yudao.module.alert.dal.dataobject.device.DeviceDO; |
||||
|
import cn.iocoder.yudao.module.alert.dal.dataobject.instant.InstantDO; |
||||
|
import cn.iocoder.yudao.module.alert.dal.dataobject.instant.InstantTableDO; |
||||
|
import cn.iocoder.yudao.module.alert.dal.mysql.device.DeviceMapper; |
||||
|
import cn.iocoder.yudao.module.alert.dal.mysql.instant.InstantMapper; |
||||
|
import cn.iocoder.yudao.module.alert.dal.mysql.instant.InstantTableMapper; |
||||
|
import cn.iocoder.yudao.module.alert.utils.EXAUtils; |
||||
|
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; |
||||
|
import com.baomidou.dynamic.datasource.annotation.DS; |
||||
|
import com.baomidou.dynamic.datasource.annotation.Slave; |
||||
|
import com.google.common.annotations.VisibleForTesting; |
||||
|
import com.mzt.logapi.context.LogRecordContext; |
||||
|
import com.mzt.logapi.service.impl.DiffParseFunction; |
||||
|
import com.mzt.logapi.starter.annotation.LogRecord; |
||||
|
import jakarta.annotation.Resource; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.cache.annotation.CacheEvict; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.Objects; |
||||
|
|
||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
||||
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.INSTANT_NOT_EXISTS; |
||||
|
import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.*; |
||||
|
|
||||
|
@Slave |
||||
|
@Service |
||||
|
@Slf4j |
||||
|
public class DeviceServiceImpl implements DeviceService { |
||||
|
@Resource |
||||
|
private DeviceMapper deviceMapper; |
||||
|
@Override |
||||
|
public DeviceDO getDeviceInfo(Long id) { |
||||
|
return deviceMapper.selectById(id); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,63 @@ |
|||||
|
package cn.iocoder.yudao.module.system.controller.admin.config.Factory; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryPageReqVO; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryRespVO; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactorySaveReqVO; |
||||
|
import cn.iocoder.yudao.module.system.convert.config.FactoryConvert; |
||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.config.FactoryDO; |
||||
|
import cn.iocoder.yudao.module.system.service.config.Factory.FactoryService; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import jakarta.validation.Valid; |
||||
|
import lombok.RequiredArgsConstructor; // 新增导入
|
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
||||
|
|
||||
|
@Tag(name = "管理后台 - 厂级管理") |
||||
|
@RestController |
||||
|
@RequestMapping("/system/Factory") |
||||
|
@Validated |
||||
|
@RequiredArgsConstructor // << 修改点1:新增注解
|
||||
|
public class FactoryController { |
||||
|
|
||||
|
private final FactoryService factoryService; // << 修改点2:移除@Resource, 添加final
|
||||
|
|
||||
|
@GetMapping("/page") |
||||
|
@Operation(summary = "获得厂级分页列表") |
||||
|
public CommonResult<PageResult<FactoryRespVO>> getFactoryPage(@Valid FactoryPageReqVO reqVO) { |
||||
|
PageResult<FactoryRespVO> pageResult = factoryService.getFactoryPage(reqVO); |
||||
|
return success(pageResult); |
||||
|
} |
||||
|
|
||||
|
// ... 其他方法保持不变 ...
|
||||
|
@GetMapping("/get") |
||||
|
@Operation(summary = "获得厂级详情") |
||||
|
public CommonResult<FactoryRespVO> getFactory(@RequestParam("id") Long id) { |
||||
|
FactoryDO factory = factoryService.getFactory(id); |
||||
|
return success(FactoryConvert.INSTANCE.convert(factory)); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/create") |
||||
|
@Operation(summary = "创建厂级") |
||||
|
public CommonResult<Long> createFactory(@Valid @RequestBody FactorySaveReqVO reqVO) { |
||||
|
return success(factoryService.createFactory(reqVO)); |
||||
|
} |
||||
|
|
||||
|
@PutMapping("/update") |
||||
|
@Operation(summary = "修改厂级") |
||||
|
public CommonResult<Boolean> updateFactory(@Valid @RequestBody FactorySaveReqVO reqVO) { |
||||
|
factoryService.updateFactory(reqVO); |
||||
|
return success(true); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping("/delete") |
||||
|
@Operation(summary = "删除厂级") |
||||
|
public CommonResult<Boolean> deleteFactory(@RequestParam("id") Long id) { |
||||
|
factoryService.deleteFactory(id); |
||||
|
return success(true); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,24 @@ |
|||||
|
package cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 厂级基础VO") |
||||
|
@Data |
||||
|
public class FactoryBaseVO { |
||||
|
|
||||
|
@Schema(description = "序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
||||
|
|
||||
|
private Long id; |
||||
|
|
||||
|
@Schema(description = "厂级序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001") |
||||
|
|
||||
|
private Long num; |
||||
|
|
||||
|
@Schema(description = "厂级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试厂级") |
||||
|
|
||||
|
private String name; |
||||
|
|
||||
|
@Schema(description = "厂级简称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试") |
||||
|
private String shortName; |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
package cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo; |
||||
|
|
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Company.vo.CompanyBaseVO; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 厂级创建请求VO") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
public class FactoryCreateReqVO extends CompanyBaseVO { |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 厂级分页请求VO") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
public class FactoryPageReqVO extends PageParam { |
||||
|
|
||||
|
@Schema(description = "厂级名称", example = "测试") |
||||
|
private String name; |
||||
|
private Long num; |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
package cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 电厂响应 VO") |
||||
|
@Data |
||||
|
public class FactoryRespVO { |
||||
|
@Schema(description = "电厂编号 (对应 plant_id)", requiredMode = Schema.RequiredMode.REQUIRED) |
||||
|
private Long id; |
||||
|
@Schema(description = "电厂名称 (对应 plant_name)", requiredMode = Schema.RequiredMode.REQUIRED) |
||||
|
private String name; |
||||
|
@Schema(description = "电厂简称 (对应 plant_shortname)") |
||||
|
private String shortName; |
||||
|
@Schema(description = "所属集团编号 (对应 area_id)", requiredMode = Schema.RequiredMode.REQUIRED) |
||||
|
private Long areaId; |
||||
|
@Schema(description = "所属集团名称 (后端关联查询得到)") |
||||
|
private String areaName; |
||||
|
@Schema(description = "创建时间") |
||||
|
private LocalDateTime createTime; |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
package cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import jakarta.validation.constraints.NotBlank; |
||||
|
import jakarta.validation.constraints.NotNull; |
||||
|
import jakarta.validation.constraints.Size; |
||||
|
import lombok.Data; // 新增导入
|
||||
|
|
||||
|
@Schema(description = "管理后台 - 电厂创建/修改 Request VO") |
||||
|
@Data // << 修改点:新增注解,并移除所有手写的getter/setter
|
||||
|
public class FactorySaveReqVO { |
||||
|
|
||||
|
@Schema(description = "电厂编号,更新时必填", example = "1") |
||||
|
private Long id; |
||||
|
|
||||
|
@Schema(description = "电厂名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "正宁电厂") |
||||
|
@NotBlank(message = "电厂名称不能为空") |
||||
|
@Size(max = 255) |
||||
|
private String name; |
||||
|
|
||||
|
@Schema(description = "电厂简称", example = "正宁") |
||||
|
@Size(max = 50) |
||||
|
private String shortName; |
||||
|
|
||||
|
@Schema(description = "所属集团编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9") |
||||
|
@NotNull(message = "所属集团不能为空") |
||||
|
private Long areaId; |
||||
|
|
||||
|
// --- 此处所有手写的 Getter 和 Setter 方法均已删除 ---
|
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo; |
||||
|
|
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Company.vo.CompanyBaseVO; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
|
||||
|
@Schema(description = "管理后台 - 厂级更新请求VO") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
public class FactoryUpdateReqVO extends CompanyBaseVO { |
||||
|
|
||||
|
@Schema(description = "序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
||||
|
private Long id; |
||||
|
} |
||||
@ -0,0 +1,72 @@ |
|||||
|
package cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.*; |
||||
|
import cn.iocoder.yudao.module.system.convert.config.SystemConfigConvert; // 确保引入正确的Convert
|
||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.config.SystemConfigDO; |
||||
|
import cn.iocoder.yudao.module.system.service.config.SystemConfig.SystemConfigService; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.Parameter; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import jakarta.annotation.Resource; |
||||
|
import jakarta.validation.Valid; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
||||
|
|
||||
|
@Tag(name = "管理后台 - 系统配置") |
||||
|
@RestController |
||||
|
@RequestMapping("/system/system-config") |
||||
|
@Validated |
||||
|
public class SystemConfigController { |
||||
|
|
||||
|
@Resource |
||||
|
private SystemConfigService systemConfigService; |
||||
|
|
||||
|
@Resource |
||||
|
private SystemConfigConvert systemConfigConvert; // 【关键修正】注入Converter
|
||||
|
|
||||
|
@PostMapping("/create") |
||||
|
@Operation(summary = "创建系统配置") |
||||
|
@PreAuthorize("@ss.hasPermission('system:system-config:create')") |
||||
|
public CommonResult<Long> createSystemConfig(@Valid @RequestBody SystemConfigSaveReqVO createReqVO) { |
||||
|
return success(systemConfigService.createSystemConfig(createReqVO)); |
||||
|
} |
||||
|
|
||||
|
@PutMapping("/update") |
||||
|
@Operation(summary = "更新系统配置") |
||||
|
@PreAuthorize("@ss.hasPermission('system:system-config:update')") |
||||
|
public CommonResult<Boolean> updateSystemConfig(@Valid @RequestBody SystemConfigSaveReqVO updateReqVO) { |
||||
|
systemConfigService.updateSystemConfig(updateReqVO); |
||||
|
return success(true); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping("/delete") |
||||
|
@Operation(summary = "删除系统配置") |
||||
|
@Parameter(name = "id", description = "编号", required = true) |
||||
|
@PreAuthorize("@ss.hasPermission('system:system-config:delete')") |
||||
|
public CommonResult<Boolean> deleteSystemConfig(@RequestParam("id") Long id) { |
||||
|
systemConfigService.deleteSystemConfig(id); |
||||
|
return success(true); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/get") |
||||
|
@Operation(summary = "获得系统配置") |
||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
||||
|
@PreAuthorize("@ss.hasPermission('system:system-config:query')") |
||||
|
public CommonResult<SystemConfigRespVO> getSystemConfig(@RequestParam("id") Long id) { |
||||
|
SystemConfigDO config = systemConfigService.getSystemConfig(id); |
||||
|
return success(systemConfigConvert.convert(config)); // 【关键修正】使用注入的bean进行转换
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/page") |
||||
|
@Operation(summary = "获得系统配置分页") |
||||
|
@PreAuthorize("@ss.hasPermission('system:system-config:query')") |
||||
|
public CommonResult<PageResult<SystemConfigRespVO>> getSystemConfigPage(@Valid SystemConfigPageReqVO pageVO) { |
||||
|
PageResult<SystemConfigDO> pageResult = systemConfigService.getSystemConfigPage(pageVO); |
||||
|
return success(systemConfigConvert.convertPage(pageResult)); // 【关键修正】使用注入的bean进行转换
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
package cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import jakarta.validation.constraints.NotBlank; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class SystemConfigBaseVO { |
||||
|
@Schema(description = "系统名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "锅炉系统") |
||||
|
@NotBlank(message = "系统名称不能为空") |
||||
|
private String name; |
||||
|
|
||||
|
@Schema(description = "系统简称", example = "锅炉") |
||||
|
private String abbreviation; |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
package cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 系统配置分页请求 VO") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
public class SystemConfigPageReqVO extends PageParam { |
||||
|
@Schema(description = "系统名称", example = "锅炉") |
||||
|
private String name; |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
package cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 系统配置响应 VO") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
public class SystemConfigRespVO extends SystemConfigBaseVO { |
||||
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) |
||||
|
private Long id; |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
package cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 系统配置创建/修改 Request VO") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
public class SystemConfigSaveReqVO extends SystemConfigBaseVO { |
||||
|
@Schema(description = "编号,更新时必填", example = "1") |
||||
|
private Long id; |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
package cn.iocoder.yudao.module.system.convert.config; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryRespVO; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactorySaveReqVO; |
||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.config.FactoryDO; |
||||
|
import org.mapstruct.Mapper; |
||||
|
import org.mapstruct.factory.Mappers; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Mapper(componentModel = "spring") // 【核心修正】添加 componentModel = "spring" 属性
|
||||
|
public interface FactoryConvert { |
||||
|
|
||||
|
FactoryConvert INSTANCE = Mappers.getMapper(FactoryConvert.class); |
||||
|
|
||||
|
// 将 SaveReqVO 转换为 DO
|
||||
|
FactoryDO convert(FactorySaveReqVO bean); |
||||
|
|
||||
|
// 将 DO 转换为 RespVO
|
||||
|
FactoryRespVO convert(FactoryDO bean); |
||||
|
|
||||
|
// 将 DO 列表转换为 RespVO 列表
|
||||
|
List<FactoryRespVO> convertList(List<FactoryDO> list); |
||||
|
|
||||
|
// 将 DO 分页 转换为 RespVO 分页
|
||||
|
PageResult<FactoryRespVO> convertPage(PageResult<FactoryDO> page); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
package cn.iocoder.yudao.module.system.convert.config; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigRespVO; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigSaveReqVO; |
||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.config.SystemConfigDO; |
||||
|
import org.mapstruct.Mapper; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Mapper(componentModel = "spring") |
||||
|
public interface SystemConfigConvert { |
||||
|
|
||||
|
default SystemConfigRespVO convert(SystemConfigDO bean) { |
||||
|
if (bean == null) { |
||||
|
return null; |
||||
|
} |
||||
|
SystemConfigRespVO respVO = new SystemConfigRespVO(); |
||||
|
|
||||
|
respVO.setId(bean.getId()); |
||||
|
respVO.setName(bean.getName()); |
||||
|
respVO.setAbbreviation(bean.getAbbreviation()); |
||||
|
|
||||
|
return respVO; |
||||
|
} |
||||
|
|
||||
|
default List<SystemConfigRespVO> convertList(List<SystemConfigDO> list) { |
||||
|
if (list == null) { |
||||
|
return null; |
||||
|
} |
||||
|
List<SystemConfigRespVO> result = new ArrayList<>(list.size()); |
||||
|
for (SystemConfigDO systemConfigDO : list) { |
||||
|
result.add(convert(systemConfigDO)); |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
default PageResult<SystemConfigRespVO> convertPage(PageResult<SystemConfigDO> page) { |
||||
|
if (page == null) { |
||||
|
return null; |
||||
|
} |
||||
|
return new PageResult<>(convertList(page.getList()), page.getTotal()); |
||||
|
} |
||||
|
|
||||
|
SystemConfigDO convert(SystemConfigSaveReqVO bean); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
package cn.iocoder.yudao.module.system.dal.dataobject.config; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import lombok.*; |
||||
|
|
||||
|
@TableName("plant_cfg") |
||||
|
@Data |
||||
|
@Builder |
||||
|
@NoArgsConstructor |
||||
|
@AllArgsConstructor |
||||
|
public class FactoryDO { |
||||
|
|
||||
|
@TableId("plant_id") |
||||
|
private Long id; |
||||
|
|
||||
|
@TableField("plant_name") |
||||
|
private String name; |
||||
|
|
||||
|
@TableField("plant_shortname") |
||||
|
private String shortName; |
||||
|
|
||||
|
@TableField("area_id") |
||||
|
private Long areaId; |
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
private String areaName; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
package cn.iocoder.yudao.module.system.dal.dataobject.config; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import lombok.*; |
||||
|
|
||||
|
/** |
||||
|
* 系统配置 DO |
||||
|
* |
||||
|
* @author 芋道源码 |
||||
|
*/ |
||||
|
@TableName("system_cfg") |
||||
|
@Data |
||||
|
@Builder |
||||
|
@NoArgsConstructor |
||||
|
@AllArgsConstructor |
||||
|
public class SystemConfigDO { |
||||
|
|
||||
|
@TableId("system_id") |
||||
|
private Long id; |
||||
|
|
||||
|
@TableField("system_name") |
||||
|
private String name; |
||||
|
|
||||
|
@TableField("system_shortname") |
||||
|
private String abbreviation; |
||||
|
|
||||
|
@TableField("system_type_id") |
||||
|
private Integer systemTypeId; |
||||
|
|
||||
|
@TableField("unit_id") |
||||
|
private Integer unitId; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package cn.iocoder.yudao.module.system.dal.mysql.config; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryPageReqVO; |
||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.config.FactoryDO; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface FactoryMapper extends BaseMapperX<FactoryDO> { |
||||
|
|
||||
|
IPage<FactoryDO> selectFactoryPage(Page<?> page, @Param("reqVO") FactoryPageReqVO reqVO); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
package cn.iocoder.yudao.module.system.dal.mysql.config; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigPageReqVO; |
||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.config.SystemConfigDO; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface SystemConfigMapper extends BaseMapperX<SystemConfigDO> { |
||||
|
|
||||
|
// 【关键修正】恢复使用框架默认的分页查询,无需XML
|
||||
|
default PageResult<SystemConfigDO> selectPage(SystemConfigPageReqVO reqVO) { |
||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<SystemConfigDO>() |
||||
|
.likeIfPresent(SystemConfigDO::getName, reqVO.getName()) |
||||
|
.orderByDesc(SystemConfigDO::getId)); |
||||
|
} |
||||
|
|
||||
|
default SystemConfigDO selectByName(String name) { |
||||
|
return selectOne(SystemConfigDO::getName, name); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,60 @@ |
|||||
|
package cn.iocoder.yudao.module.system.service.config.Factory; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryPageReqVO; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryRespVO; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactorySaveReqVO; |
||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.config.FactoryDO; |
||||
|
import jakarta.validation.Valid; |
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface FactoryService { |
||||
|
|
||||
|
/** |
||||
|
* 创建电厂 |
||||
|
* |
||||
|
* @param createReqVO 创建信息 |
||||
|
* @return 编号 |
||||
|
*/ |
||||
|
Long createFactory(@Valid FactorySaveReqVO createReqVO); |
||||
|
|
||||
|
/** |
||||
|
* 更新电厂 |
||||
|
* |
||||
|
* @param updateReqVO 更新信息 |
||||
|
*/ |
||||
|
void updateFactory(@Valid FactorySaveReqVO updateReqVO); |
||||
|
|
||||
|
/** |
||||
|
* 删除电厂 |
||||
|
* |
||||
|
* @param id 编号 |
||||
|
*/ |
||||
|
void deleteFactory(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 获得电厂 |
||||
|
* |
||||
|
* @param id 编号 |
||||
|
* @return 电厂 |
||||
|
*/ |
||||
|
FactoryDO getFactory(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 获得电厂列表 |
||||
|
* |
||||
|
* @param ids 编号 |
||||
|
* @return 电厂列表 |
||||
|
*/ |
||||
|
List<FactoryDO> getFactoryList(Collection<Long> ids); |
||||
|
|
||||
|
/** |
||||
|
* 获得电厂分页 |
||||
|
* |
||||
|
* @param pageReqVO 分页查询 |
||||
|
* @return 电厂分页 |
||||
|
*/ |
||||
|
PageResult<FactoryRespVO> getFactoryPage(FactoryPageReqVO pageReqVO); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,65 @@ |
|||||
|
package cn.iocoder.yudao.module.system.service.config.Factory; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryPageReqVO; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryRespVO; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactorySaveReqVO; |
||||
|
import cn.iocoder.yudao.module.system.convert.config.FactoryConvert; |
||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.config.FactoryDO; |
||||
|
import cn.iocoder.yudao.module.system.dal.mysql.config.FactoryMapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import lombok.RequiredArgsConstructor; // 新增导入
|
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
|
||||
|
import java.util.Collection; |
||||
|
import java.util.Collections; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
@Validated |
||||
|
@RequiredArgsConstructor // << 修改点1:新增注解
|
||||
|
public class FactoryServiceImpl implements FactoryService { |
||||
|
|
||||
|
private final FactoryMapper factoryMapper; // << 修改点2:移除@Resource, 添加final
|
||||
|
private final FactoryConvert factoryConvert; // << 修改点3:移除@Resource, 添加final
|
||||
|
|
||||
|
@Override |
||||
|
public Long createFactory(FactorySaveReqVO createReqVO) { |
||||
|
FactoryDO factory = factoryConvert.convert(createReqVO); |
||||
|
factoryMapper.insert(factory); |
||||
|
return factory.getId(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void updateFactory(FactorySaveReqVO updateReqVO) { |
||||
|
FactoryDO updateObj = factoryConvert.convert(updateReqVO); |
||||
|
factoryMapper.updateById(updateObj); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void deleteFactory(Long id) { |
||||
|
factoryMapper.deleteById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public FactoryDO getFactory(Long id) { |
||||
|
return factoryMapper.selectById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<FactoryDO> getFactoryList(Collection<Long> ids) { |
||||
|
if (ids == null || ids.isEmpty()) { |
||||
|
return Collections.emptyList(); |
||||
|
} |
||||
|
return factoryMapper.selectBatchIds(ids); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public PageResult<FactoryRespVO> getFactoryPage(FactoryPageReqVO pageReqVO) { |
||||
|
Page<FactoryDO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); |
||||
|
IPage<FactoryDO> pageResult = factoryMapper.selectFactoryPage(page, pageReqVO); |
||||
|
return new PageResult<>(factoryConvert.convertList(pageResult.getRecords()), pageResult.getTotal()); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,44 @@ |
|||||
|
package cn.iocoder.yudao.module.system.service.config.SystemConfig; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigPageReqVO; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigSaveReqVO; |
||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.config.SystemConfigDO; |
||||
|
import jakarta.validation.Valid; |
||||
|
|
||||
|
public interface SystemConfigService { |
||||
|
|
||||
|
/** |
||||
|
* 创建系统配置 |
||||
|
* @param createReqVO 创建信息 |
||||
|
* @return 编号 |
||||
|
*/ |
||||
|
Long createSystemConfig(@Valid SystemConfigSaveReqVO createReqVO); |
||||
|
|
||||
|
/** |
||||
|
* 更新系统配置 |
||||
|
* @param updateReqVO 更新信息 |
||||
|
*/ |
||||
|
void updateSystemConfig(@Valid SystemConfigSaveReqVO updateReqVO); |
||||
|
|
||||
|
/** |
||||
|
* 删除系统配置 |
||||
|
* @param id 编号 |
||||
|
*/ |
||||
|
void deleteSystemConfig(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 获得系统配置 |
||||
|
* @param id 编号 |
||||
|
* @return 系统配置 |
||||
|
*/ |
||||
|
SystemConfigDO getSystemConfig(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 获得系统配置分页 |
||||
|
* @param pageReqVO 分页查询 |
||||
|
* @return 系统配置分页 |
||||
|
*/ |
||||
|
PageResult<SystemConfigDO> getSystemConfigPage(SystemConfigPageReqVO pageReqVO); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,75 @@ |
|||||
|
package cn.iocoder.yudao.module.system.service.config.SystemConfig; |
||||
|
|
||||
|
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; |
||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigPageReqVO; |
||||
|
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigSaveReqVO; |
||||
|
import cn.iocoder.yudao.module.system.convert.config.SystemConfigConvert; |
||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.config.SystemConfigDO; |
||||
|
import cn.iocoder.yudao.module.system.dal.mysql.config.SystemConfigMapper; |
||||
|
import jakarta.annotation.Resource; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
|
||||
|
import java.util.Objects; |
||||
|
|
||||
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; |
||||
|
|
||||
|
@Service |
||||
|
@Validated |
||||
|
public class SystemConfigServiceImpl implements SystemConfigService { |
||||
|
|
||||
|
@Resource |
||||
|
private SystemConfigMapper systemConfigMapper; |
||||
|
|
||||
|
@Resource |
||||
|
private SystemConfigConvert systemConfigConvert; |
||||
|
|
||||
|
@Override |
||||
|
public Long createSystemConfig(SystemConfigSaveReqVO createReqVO) { |
||||
|
validateNameDuplicate(createReqVO.getName(), null); |
||||
|
SystemConfigDO systemConfig = systemConfigConvert.convert(createReqVO); |
||||
|
systemConfigMapper.insert(systemConfig); |
||||
|
return systemConfig.getId(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void updateSystemConfig(SystemConfigSaveReqVO updateReqVO) { |
||||
|
validateExists(updateReqVO.getId()); |
||||
|
validateNameDuplicate(updateReqVO.getName(), updateReqVO.getId()); |
||||
|
SystemConfigDO updateObj = systemConfigConvert.convert(updateReqVO); |
||||
|
systemConfigMapper.updateById(updateObj); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void deleteSystemConfig(Long id) { |
||||
|
validateExists(id); |
||||
|
systemConfigMapper.deleteById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public SystemConfigDO getSystemConfig(Long id) { |
||||
|
return systemConfigMapper.selectById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public PageResult<SystemConfigDO> getSystemConfigPage(SystemConfigPageReqVO pageReqVO) { |
||||
|
return systemConfigMapper.selectPage(pageReqVO); |
||||
|
} |
||||
|
|
||||
|
private void validateExists(Long id) { |
||||
|
if (systemConfigMapper.selectById(id) == null) { |
||||
|
throw ServiceExceptionUtil.exception(SYSTEM_CONFIG_NOT_EXISTS); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void validateNameDuplicate(String name, Long id) { |
||||
|
SystemConfigDO config = systemConfigMapper.selectByName(name); |
||||
|
if (config == null) { |
||||
|
return; |
||||
|
} |
||||
|
if (id == null || !Objects.equals(config.getId(), id)) { |
||||
|
throw ServiceExceptionUtil.exception(SYSTEM_CONFIG_NAME_DUPLICATE); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<?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.config.FactoryMapper"> |
||||
|
|
||||
|
<select id="selectFactoryPage" resultType="cn.iocoder.yudao.module.system.dal.dataobject.config.FactoryDO"> |
||||
|
SELECT |
||||
|
p.plant_id AS id, |
||||
|
p.plant_name AS name, |
||||
|
p.plant_shortname AS short_name, |
||||
|
p.area_id, |
||||
|
a.area_name AS area_name |
||||
|
FROM |
||||
|
plant_cfg AS p |
||||
|
LEFT JOIN area_cfg AS a ON p.area_id = a.area_id |
||||
|
<where> |
||||
|
<if test="reqVO.name != null and reqVO.name != ''"> |
||||
|
AND p.plant_name LIKE CONCAT('%', #{reqVO.name}, '%') |
||||
|
</if> |
||||
|
</where> |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
||||
@ -0,0 +1,29 @@ |
|||||
|
package cn.iocoder.yudao.server.config; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
|
||||
|
/** |
||||
|
* MyBatis Plus 的自定义配置类 |
||||
|
* |
||||
|
* @author 芋道源码 |
||||
|
*/ |
||||
|
@Configuration |
||||
|
public class MybatisPlusCustomConfig { |
||||
|
|
||||
|
/** |
||||
|
* 创建一个 MybatisPlusPropertiesCustomizer Bean |
||||
|
* 用于在 Spring Boot 自动配置 MyBatis-Plus 之前,自定义其属性 |
||||
|
*/ |
||||
|
@Bean |
||||
|
public MybatisPlusPropertiesCustomizer mybatisPlusPropertiesCustomizer() { |
||||
|
return properties -> { |
||||
|
// 【核心配置】在这里用代码的方式,为 mybatis-plus.mapper-locations 赋上我们期望的值
|
||||
|
// "classpath*:mapper/**/*.xml" 会递归扫描所有模块下 resources/mapper 目录中的所有xml文件
|
||||
|
String[] mapperLocations = {"classpath*:mapper/**/*.xml"}; |
||||
|
properties.setMapperLocations(mapperLocations); |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue