mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
完善煤参数配置
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cn.lihongjie.coal.coalParameterDef.controller;
|
||||
|
||||
import cn.lihongjie.coal.annotation.Anonymous;
|
||||
import cn.lihongjie.coal.annotation.OrgScope;
|
||||
import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.base.controller.BaseController;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
@@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@SysLog(module = "煤参数配置")
|
||||
@Anonymous
|
||||
@OrgScope
|
||||
public class CoalParameterDefController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package cn.lihongjie.coal.coalParameterDef.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonDto;
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CoalParameterDefDto extends CommonDto {
|
||||
public class CoalParameterDefDto extends OrgCommonDto {
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package cn.lihongjie.coal.coalParameterDef.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonDto;
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateCoalParameterDefDto extends CommonDto {
|
||||
public class CreateCoalParameterDefDto extends OrgCommonDto {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package cn.lihongjie.coal.coalParameterDef.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonDto;
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateCoalParameterDefDto extends CommonDto {
|
||||
public class UpdateCoalParameterDefDto extends OrgCommonDto {
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package cn.lihongjie.coal.coalParameterDef.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.CommonEntity;
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import jakarta.persistence.Entity;
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class CoalParameterDefEntity extends CommonEntity {
|
||||
public class CoalParameterDefEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,4 +6,5 @@ import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CoalParameterDefRepository extends BaseRepository<CoalParameterDefEntity> {
|
||||
long countByOrganizationId(String organizationId);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import cn.lihongjie.coal.coalParameterDef.dto.UpdateCoalParameterDefDto;
|
||||
import cn.lihongjie.coal.coalParameterDef.entity.CoalParameterDefEntity;
|
||||
import cn.lihongjie.coal.coalParameterDef.mapper.CoalParameterDefMapper;
|
||||
import cn.lihongjie.coal.coalParameterDef.repository.CoalParameterDefRepository;
|
||||
import cn.lihongjie.coal.organization.service.OrganizationService;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -94,10 +95,19 @@ public class CoalParameterDefService extends BaseService<CoalParameterDefEntity,
|
||||
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Autowired
|
||||
OrganizationService organizationService;
|
||||
|
||||
public void initDefault() {
|
||||
|
||||
if (this.count() == 0) {
|
||||
organizationService.findAll().forEach(organizationEntity -> initDefault(organizationEntity.getId()));
|
||||
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void initDefault(String orgId) {
|
||||
|
||||
if (repository.countByOrganizationId(orgId) == 0) {
|
||||
|
||||
ClassPathResource classPathResource = new ClassPathResource("/config/CoalParameterDef.json");
|
||||
|
||||
@@ -109,6 +119,7 @@ public class CoalParameterDefService extends BaseService<CoalParameterDefEntity,
|
||||
coalParameterDefs = mapper.readValue(inputStream, new TypeReference<List<CoalParameterDefEntity>>() {
|
||||
});
|
||||
|
||||
coalParameterDefs.forEach(x -> x.setOrganizationId(orgId));
|
||||
|
||||
this.repository.saveAll(coalParameterDefs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user