修改
This commit is contained in:
parent
0396b88c2b
commit
6838e18531
@ -1 +1 @@
|
||||
Subproject commit 12bfb1243559f366ddaa1f36b0a8cbaed3a3c694
|
||||
Subproject commit 449ed3da31bbe3eb5d8d1485e83dd075d5c7c1be
|
@ -27,8 +27,8 @@
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -6,16 +6,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端
|
||||
* </p>
|
||||
* ncc 数据管理
|
||||
*
|
||||
* @author walker
|
||||
* @since 2023-02-27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/simulation/ncc/manage/v1")
|
||||
public class RtsNccMapDataController {
|
||||
public class NccMapManageController {
|
||||
@Autowired
|
||||
private IRtsNccMapDataRepository mapDataService;
|
||||
|
||||
@ -29,8 +27,12 @@ public class RtsNccMapDataController {
|
||||
return this.mapDataService.findById(id);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/change/{state}")
|
||||
public void changeState(@PathVariable("id") Long id, @PathVariable("state") NccMapDataDto.MapDataEnum state){
|
||||
this.mapDataService.changeState(id,state);
|
||||
@GetMapping("/publish/{id}")
|
||||
public void publish(@PathVariable("id") Long id){
|
||||
this.mapDataService.publish(id);
|
||||
}
|
||||
/* @GetMapping("/publish/{id}")
|
||||
public void publish(){
|
||||
|
||||
}*/
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package club.joylink.rtss.simulation.ncc.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author walker
|
||||
* @since 2023-03-03
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/rtsNccMapDataPublish")
|
||||
public class RtsNccMapDataPublishController {
|
||||
|
||||
}
|
@ -35,8 +35,5 @@ public class RtsNccMapData implements Serializable {
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 状态0=发布,1=编辑,2=删除
|
||||
*/
|
||||
private NccMapDataDto.MapDataEnum state;
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
package club.joylink.rtss.simulation.ncc.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author walker
|
||||
* @since 2023-03-06
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("rts_ncc_map_data_publish")
|
||||
public class RtsNccMapDataPublish implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private byte[] mapData;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private Integer version;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 0=启用,1=禁用
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
@ -7,7 +7,8 @@ public enum NccExceptionAssertEnum implements ServerExceptionAssert {
|
||||
DataNotExist(4000, "data not exist"),
|
||||
FieldMustUnique(4001, "the unique filed repeat"),
|
||||
RuntimeException(4002,"system runtime exception"),
|
||||
ParamNotEmpty(4003,"param must not empty")
|
||||
ParamNotEmpty(4003,"param must not empty"),
|
||||
StateNotMatch(4004,"state not match")
|
||||
;
|
||||
|
||||
NccExceptionAssertEnum(int code, String message) {
|
||||
|
@ -0,0 +1,18 @@
|
||||
package club.joylink.rtss.simulation.ncc.mapper;
|
||||
|
||||
import club.joylink.rtss.simulation.ncc.entity.RtsNccMapDataPublish;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author walker
|
||||
* @since 2023-03-03
|
||||
*/
|
||||
@Mapper
|
||||
public interface RtsNccMapDataPublishMapper extends BaseMapper<RtsNccMapDataPublish> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package club.joylink.rtss.simulation.ncc.repository;
|
||||
|
||||
import club.joylink.rtss.simulation.ncc.entity.RtsNccMapDataPublish;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author walker
|
||||
* @since 2023-03-03
|
||||
*/
|
||||
public interface IRtsNccMapDataPublishRepository extends IService<RtsNccMapDataPublish> {
|
||||
Optional<RtsNccMapDataPublish> findLast();
|
||||
}
|
@ -13,7 +13,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
* @since 2023-02-27
|
||||
*/
|
||||
public interface IRtsNccMapDataRepository extends IService<RtsNccMapData> {
|
||||
void changeState(Long id, NccMapDataDto.MapDataEnum state);
|
||||
void publish(Long id);
|
||||
void saveOrUpdate(NccMapDataDto mapDataVO);
|
||||
NccMapDataDto findById(Long id);
|
||||
|
||||
// void publish(Long id);
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package club.joylink.rtss.simulation.ncc.repository.impl;
|
||||
|
||||
import club.joylink.rtss.simulation.ncc.entity.RtsNccMapDataPublish;
|
||||
import club.joylink.rtss.simulation.ncc.mapper.RtsNccMapDataPublishMapper;
|
||||
import club.joylink.rtss.simulation.ncc.repository.IRtsNccMapDataPublishRepository;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author walker
|
||||
* @since 2023-03-03
|
||||
*/
|
||||
@Service
|
||||
public class RtsNccMapDataPublishRepository extends ServiceImpl<RtsNccMapDataPublishMapper, RtsNccMapDataPublish> implements IRtsNccMapDataPublishRepository {
|
||||
|
||||
@Override
|
||||
public Optional<RtsNccMapDataPublish> findLast() {
|
||||
QueryWrapper<RtsNccMapDataPublish> qw = new QueryWrapper();
|
||||
qw.select("max(version) as version,id");
|
||||
List<RtsNccMapDataPublish> listDatas = this.list(qw);
|
||||
if(CollectionUtils.isEmpty(listDatas)){
|
||||
return Optional.empty();
|
||||
}
|
||||
Long id = listDatas.get(0).getId();
|
||||
RtsNccMapDataPublish data = this.getById(id);
|
||||
return Optional.of(data);
|
||||
}
|
||||
}
|
@ -2,14 +2,19 @@ package club.joylink.rtss.simulation.ncc.repository.impl;
|
||||
|
||||
import club.joylink.rtss.simulation.ncc.dto.NccMapDataDto;
|
||||
import club.joylink.rtss.simulation.ncc.entity.RtsNccMapData;
|
||||
import club.joylink.rtss.simulation.ncc.entity.RtsNccMapDataPublish;
|
||||
import club.joylink.rtss.simulation.ncc.exception.NccExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.ncc.mapper.RtsNccMapDataMapper;
|
||||
import club.joylink.rtss.simulation.ncc.repository.IRtsNccMapDataPublishRepository;
|
||||
import club.joylink.rtss.simulation.ncc.repository.IRtsNccMapDataRepository;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.RegEx;
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -21,20 +26,32 @@ import java.util.Objects;
|
||||
*/
|
||||
@Service
|
||||
public class RtsNccMapDataRepository extends ServiceImpl<RtsNccMapDataMapper, RtsNccMapData> implements IRtsNccMapDataRepository {
|
||||
|
||||
@Resource
|
||||
private IRtsNccMapDataPublishRepository publishRepository;
|
||||
|
||||
private RtsNccMapData byId(Long id){
|
||||
NccExceptionAssertEnum.ParamNotEmpty.assertTrue(Objects.nonNull(id),"id信息不能为空");
|
||||
RtsNccMapData nccMapData = this.getById(id);
|
||||
NccExceptionAssertEnum.DataNotExist.assertTrue(Objects.nonNull(nccMapData),"未找到对应的数据");
|
||||
return nccMapData;
|
||||
}
|
||||
@Override
|
||||
public void changeState(Long id, NccMapDataDto.MapDataEnum state) {
|
||||
RtsNccMapData newData = this.byId(id);
|
||||
|
||||
@Override
|
||||
public void publish(Long id) {
|
||||
RtsNccMapData newData = this.byId(id);
|
||||
NccExceptionAssertEnum.StateNotMatch.assertTrue(newData.getState() == NccMapDataDto.MapDataEnum.PUBLISH,"已经发布的数据不能修改");
|
||||
NccExceptionAssertEnum.StateNotMatch.assertTrue(newData.getState() == NccMapDataDto.MapDataEnum.DELETE,"已经删除的数据不能修改");
|
||||
newData.setId(id);
|
||||
newData.setState(NccMapDataDto.MapDataEnum.PUBLISH);
|
||||
newData.setUpdateTime(LocalDateTime.now());
|
||||
newData.setState(state);
|
||||
this.getBaseMapper().updateById(newData);
|
||||
Optional<RtsNccMapDataPublish> dataPublishOptional = this.publishRepository.findLast();
|
||||
RtsNccMapDataPublish dataPublish = dataPublishOptional.orElse(null);
|
||||
int version = 0;
|
||||
if(Objects.isNull(dataPublish)){
|
||||
version = dataPublishOptional.get().getVersion() + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -44,6 +61,7 @@ public class RtsNccMapDataRepository extends ServiceImpl<RtsNccMapDataMapper, Rt
|
||||
RtsNccMapData mapData = mapDataVO.convert();
|
||||
LocalDateTime dateTime = LocalDateTime.now();
|
||||
if(Objects.nonNull(mapData.getId())){
|
||||
NccExceptionAssertEnum.StateNotMatch.assertTrue(mapData.getState() == NccMapDataDto.MapDataEnum.DELETE,"已经发布的数据不能修改");
|
||||
mapData = this.byId(mapData.getId());
|
||||
mapData.setMapData(mapData.getMapData());
|
||||
mapData.setUpdateTime(dateTime);
|
||||
@ -60,4 +78,5 @@ public class RtsNccMapDataRepository extends ServiceImpl<RtsNccMapDataMapper, Rt
|
||||
RtsNccMapData mapData = this.byId(id);
|
||||
return new NccMapDataDto(mapData);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
<?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="club.joylink.rtss.simulation.ncc.mapper.RtsNccMapDataPublishMapper">
|
||||
|
||||
</mapper>
|
@ -18,7 +18,7 @@ public class MybatisPlusAutoGenerator {
|
||||
|
||||
public static void main(String[] args) {
|
||||
GeneratorModule generatorModule = GeneratorModule.SimulationNcc;
|
||||
String[] tableNames = new String[]{"rts_ncc_map_data"};
|
||||
String[] tableNames = new String[]{"rts_ncc_map_data_publish"};
|
||||
// String baseDir = String.join(File.separator, Arrays.asList(System.getProperty("user.dir"), "jl-rtss-auth", "src", "main"));
|
||||
String baseDir = generatorModule.projectPath;
|
||||
String outBaseDir = baseDir + File.separator + "java";
|
||||
|
Loading…
Reference in New Issue
Block a user