【小写ncc文件夹】

This commit is contained in:
weizhihong 2023-02-27 18:28:32 +08:00
parent 12c898cdd8
commit c5b31292a2
10 changed files with 276 additions and 0 deletions

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>simulation-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

@ -0,0 +1,6 @@
mybatis-plus:
type-aliases-package: club.joylink.rtss.auth.mapper
mapper-locations: classpath:mapper/ncc/*.xml
configuration:
map-underscore-to-camel-case: true

View File

@ -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.RtsNccMapDataMapper">
</mapper>