proto及 rtss cros配置(修改基于boot 2.7)

This commit is contained in:
tiger_zhou 2023-02-22 10:45:37 +08:00
parent c38d4748d5
commit 94177b2581
13 changed files with 1185 additions and 0 deletions

View File

@ -32,6 +32,11 @@
<artifactId>jl-ecs</artifactId> <artifactId>jl-ecs</artifactId>
<version>0.1</version> <version>0.1</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<resources> <resources>

View File

@ -0,0 +1,5 @@
package club.joylink.ncc.constants;
public class NccTypeEnum {
}

View File

@ -0,0 +1,29 @@
package club.joylink.ncc.controller;
import club.joylink.ncc.services.MapDataService;
import club.joylink.ncc.vo.NccMapDataVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/ncc/manage")
public class NccManageController {
@Autowired
private MapDataService mapDataService;
@PostMapping("saveOrUpdate")
public void saveOrUpdate(@RequestBody NccMapDataVO dataVO){
this.mapDataService.saveOrUpdate(dataVO);
}
@GetMapping()
public NccMapDataVO findId(Long id){
return this.mapDataService.findById(id);
}
@GetMapping("/{id}/change/{state}")
public void changeState(@PathVariable("id") Long id, @PathVariable("state") NccMapDataVO.MapDataEnum state){
this.mapDataService.changeState(id,state);
}
}

View File

@ -0,0 +1,40 @@
package club.joylink.ncc.dao;
import club.joylink.ncc.entity.NccMapData;
import club.joylink.ncc.entity.NccMapDataExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface NccMapDataDAO {
long countByExample(NccMapDataExample example);
int deleteByExample(NccMapDataExample example);
int deleteByPrimaryKey(Long id);
int insert(NccMapData record);
int insertSelective(NccMapData record);
List<NccMapData> selectByExampleWithBLOBs(NccMapDataExample example);
List<NccMapData> selectByExample(NccMapDataExample example);
NccMapData selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") NccMapData record, @Param("example") NccMapDataExample example);
int updateByExampleWithBLOBs(@Param("record") NccMapData record, @Param("example") NccMapDataExample example);
int updateByExample(@Param("record") NccMapData record, @Param("example") NccMapDataExample example);
int updateByPrimaryKeySelective(NccMapData record);
int updateByPrimaryKeyWithBLOBs(NccMapData record);
int updateByPrimaryKey(NccMapData record);
}

View File

@ -0,0 +1,32 @@
package club.joylink.ncc.entity;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import club.joylink.ncc.vo.NccMapDataVO;
import lombok.Data;
/**
* @author
*
*/
@Data
public class NccMapData implements Serializable {
private Long id;
private String name;
private LocalDateTime createTime;
private LocalDateTime updateTime;
/**
* 状态0=发布1=编辑,2=删除
*/
private NccMapDataVO.MapDataEnum state;
private byte[] mapData;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,543 @@
package club.joylink.ncc.entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class NccMapDataExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
private Integer limit;
private Long offset;
public NccMapDataExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Integer getLimit() {
return limit;
}
public void setOffset(Long offset) {
this.offset = offset;
}
public Long getOffset() {
return offset;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("`name` is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("`name` is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("`name` =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("`name` <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("`name` >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("`name` >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("`name` <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("`name` <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("`name` like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("`name` not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("`name` not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("`name` between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("`name` not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andStateIsNull() {
addCriterion("`state` is null");
return (Criteria) this;
}
public Criteria andStateIsNotNull() {
addCriterion("`state` is not null");
return (Criteria) this;
}
public Criteria andStateEqualTo(String value) {
addCriterion("`state` =", value, "state");
return (Criteria) this;
}
public Criteria andStateNotEqualTo(String value) {
addCriterion("`state` <>", value, "state");
return (Criteria) this;
}
public Criteria andStateGreaterThan(String value) {
addCriterion("`state` >", value, "state");
return (Criteria) this;
}
public Criteria andStateGreaterThanOrEqualTo(String value) {
addCriterion("`state` >=", value, "state");
return (Criteria) this;
}
public Criteria andStateLessThan(String value) {
addCriterion("`state` <", value, "state");
return (Criteria) this;
}
public Criteria andStateLessThanOrEqualTo(String value) {
addCriterion("`state` <=", value, "state");
return (Criteria) this;
}
public Criteria andStateLike(String value) {
addCriterion("`state` like", value, "state");
return (Criteria) this;
}
public Criteria andStateNotLike(String value) {
addCriterion("`state` not like", value, "state");
return (Criteria) this;
}
public Criteria andStateIn(List<String> values) {
addCriterion("`state` in", values, "state");
return (Criteria) this;
}
public Criteria andStateNotIn(List<String> values) {
addCriterion("`state` not in", values, "state");
return (Criteria) this;
}
public Criteria andStateBetween(String value1, String value2) {
addCriterion("`state` between", value1, value2, "state");
return (Criteria) this;
}
public Criteria andStateNotBetween(String value1, String value2) {
addCriterion("`state` not between", value1, value2, "state");
return (Criteria) this;
}
}
/**
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -0,0 +1,9 @@
package club.joylink.ncc.services;
import club.joylink.ecs.World;
public interface EcsSystem {
void addSystem(World world);
Object type();
}

View File

@ -0,0 +1,13 @@
package club.joylink.ncc.services;
import club.joylink.ncc.entity.NccMapData;
import club.joylink.ncc.vo.NccMapDataVO;
public interface MapDataService {
NccMapDataVO findById(Long id);
void saveOrUpdate(NccMapDataVO mapDataVO);
void changeState(Long id, NccMapDataVO.MapDataEnum state);
}

View File

@ -0,0 +1,65 @@
package club.joylink.ncc.services.impl;
import club.joylink.exception.BusinessExceptionAssertEnum;
import club.joylink.ncc.dao.NccMapDataDAO;
import club.joylink.ncc.entity.NccMapData;
import club.joylink.ncc.services.MapDataService;
import club.joylink.ncc.vo.NccMapDataVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.Objects;
@Service
@Slf4j
@Transactional
public class MapDataServiceImpl implements MapDataService {
@Autowired
private NccMapDataDAO nccMapDataDAO;
private NccMapData byId(Long id){
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(Objects.nonNull(id),"id信息不能为空");
NccMapData nccMapData = this.nccMapDataDAO.selectByPrimaryKey(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(nccMapData),"未找到对应的数据");
return nccMapData;
}
@Override
public NccMapDataVO findById(Long id) {
NccMapData mapData = this.byId(id);
return new NccMapDataVO(mapData);
}
@Override
public void saveOrUpdate(NccMapDataVO mapDataVO) {
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(Objects.nonNull(mapDataVO.getName()),"名称信息不能为空");
NccMapData mapData = mapDataVO.convert();
LocalDateTime dateTime = LocalDateTime.now();
if(Objects.nonNull(mapData.getId())){
mapData = this.byId(mapData.getId());
mapData.setMapData(mapData.getMapData());
mapData.setUpdateTime(dateTime);
this.nccMapDataDAO.updateByPrimaryKey(mapData);
}else{
mapData.setState(NccMapDataVO.MapDataEnum.EDIT);
mapData.setCreateTime(dateTime);
mapData.setUpdateTime(dateTime);
this.nccMapDataDAO.insert(mapData);
}
}
@Override
public void changeState(Long id, NccMapDataVO.MapDataEnum state) {
this.byId(id);
NccMapData newData = new NccMapData();
newData.setId(id);
newData.setUpdateTime(LocalDateTime.now());
newData.setState(state);
this.nccMapDataDAO.updateByPrimaryKeySelective(newData);
}
}

View File

@ -0,0 +1,35 @@
package club.joylink.ncc.vo;
import club.joylink.ncc.entity.NccMapData;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
public class NccMapDataVO implements Serializable {
@Serial
private static final long serialVersionUID = 5757927953903823727L;
private Long id;
private String name;
private byte[] data;
private MapDataEnum state;
public NccMapDataVO(NccMapData mapData){
this.id = mapData.getId();
this.name = mapData.getName();
this.data = mapData.getMapData();
this.state = mapData.getState();
}
public NccMapData convert(){
NccMapData mapData = new NccMapData();
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,278 @@
<?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.ncc.dao.NccMapDataDAO">
<resultMap id="BaseResultMap" type="club.joylink.ncc.entity.NccMapData">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="state" jdbcType="VARCHAR" property="state" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="club.joylink.ncc.entity.NccMapData">
<result column="map_data" jdbcType="LONGVARBINARY" property="mapData" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, create_time, update_time, `state`
</sql>
<sql id="Blob_Column_List">
map_data
</sql>
<select id="selectByExampleWithBLOBs" parameterType="club.joylink.ncc.entity.NccMapDataExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from ncc_map_data
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limit != null">
<if test="offset != null">
limit ${offset}, ${limit}
</if>
<if test="offset == null">
limit ${limit}
</if>
</if>
</select>
<select id="selectByExample" parameterType="club.joylink.ncc.entity.NccMapDataExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from ncc_map_data
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limit != null">
<if test="offset != null">
limit ${offset}, ${limit}
</if>
<if test="offset == null">
limit ${limit}
</if>
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from ncc_map_data
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from ncc_map_data
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="club.joylink.ncc.entity.NccMapDataExample">
delete from ncc_map_data
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.ncc.entity.NccMapData" useGeneratedKeys="true">
insert into ncc_map_data (`name`, create_time, update_time,
`state`, map_data)
values (#{name,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{state,jdbcType=VARCHAR}, #{mapData,jdbcType=LONGVARBINARY})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.ncc.entity.NccMapData" useGeneratedKeys="true">
insert into ncc_map_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">
`name`,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="state != null">
`state`,
</if>
<if test="mapData != null">
map_data,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="state != null">
#{state,jdbcType=VARCHAR},
</if>
<if test="mapData != null">
#{mapData,jdbcType=LONGVARBINARY},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="club.joylink.ncc.entity.NccMapDataExample" resultType="java.lang.Long">
select count(*) from ncc_map_data
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update ncc_map_data
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.state != null">
`state` = #{record.state,jdbcType=VARCHAR},
</if>
<if test="record.mapData != null">
map_data = #{record.mapData,jdbcType=LONGVARBINARY},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update ncc_map_data
set id = #{record.id,jdbcType=BIGINT},
`name` = #{record.name,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
`state` = #{record.state,jdbcType=VARCHAR},
map_data = #{record.mapData,jdbcType=LONGVARBINARY}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update ncc_map_data
set id = #{record.id,jdbcType=BIGINT},
`name` = #{record.name,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
`state` = #{record.state,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.ncc.entity.NccMapData">
update ncc_map_data
<set>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="state != null">
`state` = #{state,jdbcType=VARCHAR},
</if>
<if test="mapData != null">
map_data = #{mapData,jdbcType=LONGVARBINARY},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="club.joylink.ncc.entity.NccMapData">
update ncc_map_data
set `name` = #{name,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
`state` = #{state,jdbcType=VARCHAR},
map_data = #{mapData,jdbcType=LONGVARBINARY}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="club.joylink.ncc.entity.NccMapData">
update ncc_map_data
set `name` = #{name,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
`state` = #{state,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -0,0 +1,79 @@
package club.joylink.ncc;
import club.joylink.ncc.proto.LineProto;
import club.joylink.ncc.proto.RoadSectionProto;
import club.joylink.ncc.proto.StationProto;
import club.joylink.ncc.proto.StorageProto;
import com.google.common.base.Strings;
public class Data {
public StorageProto.Storage createStorage(){
StorageProto.Storage.Builder storageBuild = StorageProto.Storage.newBuilder();
createLine(storageBuild);
this.createStation(storageBuild);
this.createSection(storageBuild);
return storageBuild.build();
}
private void createLine(StorageProto.Storage.Builder storageBuild){
for(var i = 1 ; i <=1;i++){
LineProto.Line.Builder lineBuild = LineProto.Line.newBuilder();
String code = Strings.padStart(i + "",4,'0');
lineBuild.setCode("line-" + code);
lineBuild.setName("line-" + code);
storageBuild.addLines(lineBuild);
}
}
private void createStation(StorageProto.Storage.Builder storageBuild){
for(var d = 1 ; d <= 20;d++){
StationProto.Station.Builder stationBuild = StationProto.Station.newBuilder();
String code = Strings.padStart(d + "",4,'0');
String nameCode = "station-" + code;
stationBuild.setCode(nameCode);
stationBuild.setName(nameCode);
stationBuild.setTransfer(false);
if(d % 2 == 0){
stationBuild.setTransfer(true);
}
storageBuild.addStations(stationBuild);
}
}
private void createSection(StorageProto.Storage.Builder storageBuild){
String lineCode = "line-001";
for(var i = 1 ; i <= 19;i++){
RoadSectionProto.RoadSection.Builder section = RoadSectionProto.RoadSection.newBuilder();
String code = Strings.padStart(i + "",4,'0');
String nameCode = "section-" + code;
section.setCode(nameCode);
section.setName(nameCode);
section.setLeftStationId(this.findStartStation(i));
section.setRightStationId(this.findEndStation(i,19));
section.setLineId(lineCode);
storageBuild.addSections(section);
}
}
private String findStartStation(int d){
int tmpD = d;
if(d <= 1){
tmpD = 1;
}/*else{
--tmpD;
}*/
String code = Strings.padStart(tmpD + "",4,'0');
return String.format("station-%s",code);
}
private String findEndStation(int d ,int max){
int tmpD = d + 1;
if(d > max){
tmpD = d;
}
String code = Strings.padStart(tmpD + "",4,'0');
return String.format("station-%s",code);
}
}

View File

@ -0,0 +1,52 @@
package club.joylink.ncc;
import club.joylink.ecs.World;
import club.joylink.ecs.WorldManage;
import club.joylink.ncc.proto.LineProto;
import club.joylink.ncc.proto.RoadSectionProto;
import club.joylink.ncc.proto.StationProto;
import club.joylink.ncc.proto.StorageProto;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.stream.Collectors;
public class Service {
public static void main(String[] args) {
Service service = new Service();
StorageProto.Storage storage = service.loadData();
}
public void addTrain(boolean upWay){
}
private StorageProto.Storage loadData(){
Data data = new Data();
StorageProto.Storage storageBuild = data.createStorage();
Map<String,LineProto.Line> tmpLineMap = storageBuild.getLinesList().stream().collect(Collectors.toMap(k->k.getCode(), Function.identity()));
lineMap.putAll(tmpLineMap);
Map<String,StationProto.Station> tmpStationMaper = storageBuild.getStationsList().stream().collect(Collectors.toMap(d->d.getCode(),Function.identity()));
for (RoadSectionProto.RoadSection rs : storageBuild.getSectionsList()) {
List<StationProto.Station> stationList = lineIdStationMap.computeIfAbsent(rs.getLineId(),k-> Lists.newArrayList());
if(stationList.stream().noneMatch(d-> Objects.equals(d.getCode(),rs.getLeftStationId()))){
stationList.add(tmpStationMaper.get(rs.getLeftStationId()));
}
if(stationList.stream().noneMatch(d-> Objects.equals(d.getCode(),rs.getRightStationId()))){
stationList.add(tmpStationMaper.get(rs.getRightStationId()));
}
}
return storageBuild;
}
private static Map<String, LineProto.Line> lineMap = new ConcurrentHashMap<>();
private static Map<String, List<StationProto.Station>> lineIdStationMap = new ConcurrentHashMap<>();
}