Merge branch 'feature/REQ-2559' into 'master'
REQ-2559 图纸识别数据展示 See merge request universal/infrastructure/backend/nanopart!38
This commit is contained in:
commit
fedf5d7c9f
@ -1,6 +1,5 @@
|
||||
package cn.axzo.nanopart.api;
|
||||
|
||||
import cn.axzo.framework.web.http.ApiResponse;
|
||||
import cn.axzo.nanopart.api.constant.enums.BizTypeEnum;
|
||||
import cn.axzo.nanopart.api.request.CreateConfigReq;
|
||||
import cn.axzo.nanopart.api.response.ConfigResp;
|
||||
|
||||
@ -15,7 +15,8 @@ public enum BizTypeEnum {
|
||||
* 前端
|
||||
*/
|
||||
|
||||
FRONT(0, "前端");
|
||||
FRONT(0, "前端"),
|
||||
BACKEND(1, "后端");
|
||||
|
||||
@EnumValue
|
||||
private final Integer value;
|
||||
|
||||
@ -6,6 +6,7 @@ import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
@ -32,7 +33,7 @@ public class CreateConfigReq {
|
||||
/**
|
||||
* 配置内容
|
||||
*/
|
||||
@NotNull(message = "配置内容不能为空")
|
||||
@NotEmpty(message = "配置内容不能为空")
|
||||
private Map<String, Object> content;
|
||||
|
||||
/**
|
||||
|
||||
@ -15,6 +15,11 @@
|
||||
<name>config-server</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.pokonyan</groupId>
|
||||
<artifactId>pokonyan</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-web-spring-boot-starter</artifactId>
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
package cn.axzo.nanopart.server.dao.entity;
|
||||
|
||||
import cn.axzo.nanopart.api.constant.enums.BizTypeEnum;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -19,7 +17,7 @@ import java.util.Map;
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "nanopart_config", autoResultMap = true)
|
||||
public class Config {
|
||||
public class Config extends BaseEntity<Config> {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ -29,10 +27,6 @@ public class Config {
|
||||
@TableField(typeHandler = FastjsonTypeHandler.class)
|
||||
private Map<String, Object> content;
|
||||
|
||||
private Boolean isDelete;
|
||||
private Date createAt;
|
||||
private Date updateAt;
|
||||
|
||||
private Long createBy;
|
||||
private Long updateBy;
|
||||
}
|
||||
|
||||
@ -8,15 +8,12 @@ import cn.axzo.nanopart.api.dto.CreateConfigDto;
|
||||
import cn.axzo.nanopart.server.dao.entity.Config;
|
||||
import cn.axzo.nanopart.server.dao.mapper.ConfigMapper;
|
||||
import cn.axzo.nanopart.server.service.ConfigService;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author wangsiqian
|
||||
@ -26,27 +23,24 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements ConfigService {
|
||||
private final ConfigMapper configMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createOrUpdateConfig(CreateConfigDto dto) {
|
||||
Config config = configMapper.selectOne(
|
||||
Wrappers.<Config>lambdaQuery()
|
||||
.eq(Config::getBizCode, dto.getBizCode())
|
||||
.eq(Config::getBizType, dto.getBizType())
|
||||
);
|
||||
Config config = lambdaQuery().eq(Config::getBizCode, dto.getBizCode())
|
||||
.eq(Config::getBizType, dto.getBizType())
|
||||
// 写入时可能存在的并发问题,取最新的一个
|
||||
.orderByDesc(BaseEntity::getUpdateAt)
|
||||
.last("LIMIT 1")
|
||||
.one();
|
||||
|
||||
if (config == null) {
|
||||
config = BeanMapper.copyBean(dto, Config::new);
|
||||
config.setCreateAt(new Date());
|
||||
config.setUpdateAt(new Date());
|
||||
} else {
|
||||
config.setBizCode(dto.getBizCode());
|
||||
config.setBizType(dto.getBizType());
|
||||
config.setContent(dto.getContent());
|
||||
config.setUpdateBy(dto.getCreateBy());
|
||||
config.setIsDelete(false);
|
||||
config.setUpdateAt(new Date());
|
||||
}
|
||||
|
||||
saveOrUpdate(config);
|
||||
@ -54,12 +48,11 @@ public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> impleme
|
||||
|
||||
@Override
|
||||
public ConfigDto getConfigByBizCode(String bizCode, BizTypeEnum bizType) {
|
||||
Config config = configMapper.selectOne(
|
||||
Wrappers.<Config>lambdaQuery()
|
||||
.eq(Config::getBizCode, bizCode)
|
||||
.eq(Config::getBizType, bizType)
|
||||
.eq(Config::getIsDelete, false)
|
||||
);
|
||||
Config config = lambdaQuery().eq(Config::getBizCode, bizCode)
|
||||
.eq(Config::getBizType, bizType)
|
||||
.orderByDesc(BaseEntity::getUpdateAt)
|
||||
.last("LIMIT 1")
|
||||
.one();
|
||||
if (config == null) {
|
||||
throw new ServiceException("未找到该配置");
|
||||
}
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user