Merge branch 'test-module' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-module

# Conflicts:
#	jl-rtss-simulation/pom.xml
This commit is contained in:
weizhihong 2023-02-27 16:32:35 +08:00
commit 7e3bff68ff
14 changed files with 326 additions and 11 deletions

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "ecs"]
path = ecs
url = https://git.code.tencent.com/joylink-common/ecs.git
[submodule "jl-rtss-simulation/ncc-message"]
path = jl-rtss-simulation/ncc-message
url = https://git.code.tencent.com/lian-cbtc/NCC/ncc-message.git

View File

@ -4,11 +4,18 @@ import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.NonNull;
import lombok.Setter;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.util.CollectionUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class MybatisPlusAutoGenerator {
@ -18,8 +25,10 @@ public class MybatisPlusAutoGenerator {
;
public static void main(String[] args) {
String baseDir = String.join(File.separator, Arrays.asList(System.getProperty("user.dir"), "jl-rtss-auth", "src", "main"));
// String baseDir = System.getProperty("user.dir") + File.separator + "src" + File.separator + "main";
GeneratorModule generatorModule = GeneratorModule.SimulationNcc;
String[] tableNames = new String[]{"rts_ncc_map_data"};
// 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";
String xmlDir = baseDir + File.separator + "resources" + File.separator + "mapper";
System.out.println(outBaseDir);
@ -31,15 +40,17 @@ public class MybatisPlusAutoGenerator {
.outputDir(outBaseDir);
})
.packageConfig(builder -> {
builder.parent("club.joylink.rtss.auth")
builder.parent(generatorModule.rootPackAges)
.service("repository")
.serviceImpl("repository.impl")
.pathInfo(Collections.singletonMap(OutputFile.xml, xmlDir));
})
.strategyConfig(builder -> {
builder.addInclude("sys_account", "sys_account_login");
builder.addInclude(tableNames);
// entity生成策略
builder.entityBuilder()
.enableLombok()
.enableFileOverride(); // 覆盖旧文件
// mapper生成策略
builder.mapperBuilder()
@ -62,4 +73,24 @@ public class MybatisPlusAutoGenerator {
.execute();
}
enum GeneratorModule{
Auth("club.joylink.rtss.auth",new String[]{"jl-rtss-auth"})
,SimulationNcc("club.joylink.rtss.simulation.ncc",new String[]{"jl-rtss-simulation","ncc"});
GeneratorModule(String d,String[] p){
this.rootPackAges = d;
List<String> projectDir = new ArrayList<>();
for (String s : p) {
projectDir.add(s);
}
projectDir.add(0,System.getProperty("user.dir"));
projectDir.add("src");
projectDir.add("main");
this.projectPath = String.join(File.separator, projectDir);
}
private String rootPackAges;
private String projectPath;
}
}

View File

@ -24,6 +24,12 @@
<groupId>club.joylink.rtss</groupId>
<artifactId>auth</artifactId>
</dependency>
<dependency>
<groupId>club.joylink.rtss</groupId>
<artifactId>ncc</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>

View File

@ -3,17 +3,24 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>simulation</artifactId>
<groupId>club.joylink.rtss</groupId>
<artifactId>simulation</artifactId>
<version>0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>NCC</artifactId>
<!-- <groupId>club.joylink.rtss.simulation</groupId>-->
<artifactId>ncc</artifactId>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
</project>
<dependencies>
<dependency>
<groupId>club.joylink.rtss</groupId>
<artifactId>ncc-message</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1 @@
Subproject commit 93ac97d80ec4821262076af460cb80e18010e65f

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>club.joylink.rtss</groupId>
<artifactId>simulation</artifactId>
<version>0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<!-- <groupId>club.joylink.rtss.simulation</groupId>-->
<artifactId>ncc</artifactId>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>club.joylink.rtss</groupId>
<artifactId>ncc-message</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,36 @@
package club.joylink.rtss.simulation.ncc.controller;
import club.joylink.rtss.simulation.ncc.dto.NccMapDataDto;
import club.joylink.rtss.simulation.ncc.repository.IRtsNccMapDataRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* <p>
* 前端控制器
* </p>
*
* @author walker
* @since 2023-02-27
*/
@RestController
@RequestMapping("/api/simulation/v1")
public class RtsNccMapDataController {
@Autowired
private IRtsNccMapDataRepository mapDataService;
@PostMapping("saveOrUpdate")
public void saveOrUpdate(@RequestBody NccMapDataDto dataVO){
this.mapDataService.saveOrUpdate(dataVO);
}
@GetMapping()
public NccMapDataDto findId(Long id){
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);
}
}

View File

@ -0,0 +1,32 @@
package club.joylink.rtss.simulation.ncc.dto;
import club.joylink.rtss.simulation.ncc.entity.RtsNccMapData;
import lombok.Data;
import java.io.Serializable;
@Data
public class NccMapDataDto implements Serializable {
private Long id;
private String name;
private byte[] data;
private MapDataEnum state;
public NccMapDataDto(RtsNccMapData mapData){
this.id = mapData.getId();
this.name = mapData.getName();
this.data = mapData.getMapData();
this.state = mapData.getState();
}
public RtsNccMapData convert(){
RtsNccMapData mapData = new RtsNccMapData();
mapData.setMapData(this.data);
mapData.setId(this.id);
mapData.setName(this.name);
mapData.setState(this.getState());
return mapData;
}
public enum MapDataEnum{
PUBLISH,EDIT,DELETE;
}
}

View File

@ -0,0 +1,42 @@
package club.joylink.rtss.simulation.ncc.entity;
import club.joylink.rtss.simulation.ncc.dto.NccMapDataDto;
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-02-27
*/
@Getter
@Setter
@TableName("rts_ncc_map_data")
public class RtsNccMapData 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 LocalDateTime updateTime;
/**
* 状态0=发布1=编辑,2=删除
*/
private NccMapDataDto.MapDataEnum state;
}

View File

@ -0,0 +1,29 @@
package club.joylink.rtss.simulation.ncc.exception;
import club.joylink.rtss.auth.exception.ServerExceptionAssert;
import org.apache.ibatis.annotations.Param;
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")
;
NccExceptionAssertEnum(int code, String message) {
this.code = code;
this.message = message;
}
int code;
String message;
@Override
public int getCode() {
return 0;
}
@Override
public String getMessage() {
return null;
}
}

View File

@ -0,0 +1,18 @@
package club.joylink.rtss.simulation.ncc.mapper;
import club.joylink.rtss.simulation.ncc.entity.RtsNccMapData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author walker
* @since 2023-02-27
*/
@Mapper
public interface RtsNccMapDataMapper extends BaseMapper<RtsNccMapData> {
}

View File

@ -0,0 +1,19 @@
package club.joylink.rtss.simulation.ncc.repository;
import club.joylink.rtss.simulation.ncc.dto.NccMapDataDto;
import club.joylink.rtss.simulation.ncc.entity.RtsNccMapData;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author walker
* @since 2023-02-27
*/
public interface IRtsNccMapDataRepository extends IService<RtsNccMapData> {
void changeState(Long id, NccMapDataDto.MapDataEnum state);
void saveOrUpdate(NccMapDataDto mapDataVO);
NccMapDataDto findById(Long id);
}

View File

@ -0,0 +1,63 @@
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.exception.NccExceptionAssertEnum;
import club.joylink.rtss.simulation.ncc.mapper.RtsNccMapDataMapper;
import club.joylink.rtss.simulation.ncc.repository.IRtsNccMapDataRepository;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.Objects;
/**
* <p>
* 服务实现类
* </p>
*
* @author walker
* @since 2023-02-27
*/
@Service
public class RtsNccMapDataRepository extends ServiceImpl<RtsNccMapDataMapper, RtsNccMapData> implements IRtsNccMapDataRepository {
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);
newData.setId(id);
newData.setUpdateTime(LocalDateTime.now());
newData.setState(state);
this.getBaseMapper().updateById(newData);
}
@Override
public void saveOrUpdate(NccMapDataDto mapDataVO) {
NccExceptionAssertEnum.ParamNotEmpty.assertTrue(Objects.nonNull(mapDataVO.getName()),"名称信息不能为空");
RtsNccMapData mapData = mapDataVO.convert();
LocalDateTime dateTime = LocalDateTime.now();
if(Objects.nonNull(mapData.getId())){
mapData = this.byId(mapData.getId());
mapData.setMapData(mapData.getMapData());
mapData.setUpdateTime(dateTime);
}else{
mapData.setState(NccMapDataDto.MapDataEnum.EDIT);
mapData.setCreateTime(dateTime);
mapData.setUpdateTime(dateTime);
}
this.saveOrUpdate(mapData);
}
@Override
public NccMapDataDto findById(Long id) {
RtsNccMapData mapData = this.byId(id);
return new NccMapDataDto(mapData);
}
}

View File

@ -4,8 +4,9 @@
<modelVersion>4.0.0</modelVersion>
<modules>
<module>ISCS</module>
<module>NCC</module>
</modules>
<module>NCC</module>
<module>ncc-message</module>
</modules>
<parent>
<groupId>club.joylink.rtss</groupId>
<artifactId>rtss-server</artifactId>
@ -27,6 +28,7 @@
<dependency>
<groupId>club.joylink.rtss</groupId>
<artifactId>auth</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>