大赛管理功能

This commit is contained in:
tiger_zhou 2024-02-23 10:39:11 +08:00
parent 63c1c88312
commit 07e23db1db
4 changed files with 136 additions and 135 deletions

View File

@ -26,78 +26,79 @@ import java.util.List;
@Slf4j
public class CommonResponseBody implements ResponseBodyAdvice {
@Override
public boolean supports(MethodParameter returnType, Class converterType) {
return returnType.getMethod() != null && !returnType.getMethod().getReturnType().getSimpleName().equals("CommonJsonResponse");
}
@Override
public boolean supports(MethodParameter returnType, Class converterType) {
return returnType.getMethod() != null && !returnType.getMethod().getReturnType().getSimpleName().equals("CommonJsonResponse");
}
@Override
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
//byte[]
if(body instanceof byte[]){
response.getHeaders().setContentType(MediaType.APPLICATION_OCTET_STREAM);
return body;
}
//byte[]
if(body instanceof AbstractMessageLite){
@Override
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
//byte[]
if (body instanceof byte[]) {
response.getHeaders().setContentType(MediaType.APPLICATION_OCTET_STREAM);
return body;
}
//byte[]
/*if(body instanceof AbstractMessageLite){
response.getHeaders().setContentType(MediaType.APPLICATION_OCTET_STREAM);
final AbstractMessageLite proto = (AbstractMessageLite) body;
return proto.toByteArray();
}
if(body instanceof CommonJsonResponse) {
return body;
}
if(request.getURI().getPath().startsWith("/swagger")) {
return body;
}
if (request.getURI().getPath().equals("/api/userinfo/ifRegisted")) {
return body;
}
if (request.getURI().getPath().equals("/api/userinfo/identity")) {
return body;
}
CommonJsonResponse commonJsonResponse = CommonJsonResponse.newSuccessResponse(body);
if(returnType.getMethod().getReturnType().equals(String.class) || body instanceof String) {
return commonJsonResponse.toJSONString();
}
return commonJsonResponse;
}*/
if (body instanceof CommonJsonResponse) {
return body;
}
if (request.getURI().getPath().startsWith("/swagger")) {
return body;
}
if (request.getURI().getPath().equals("/api/userinfo/ifRegisted")) {
return body;
}
if (request.getURI().getPath().equals("/api/userinfo/identity")) {
return body;
}
CommonJsonResponse commonJsonResponse = CommonJsonResponse.newSuccessResponse(body);
if (returnType.getMethod().getReturnType().equals(String.class) || body instanceof String) {
return commonJsonResponse.toJSONString();
}
return commonJsonResponse;
}
@ExceptionHandler({PayException.class})
@ResponseStatus
public CommonJsonResponse handleException(PayException e) {
log.error("【支付异常】", e);
return CommonJsonResponse.newErrorResponse();
}
@ExceptionHandler({Exception.class})
@ResponseBody
public CommonJsonResponse handleException(Exception e) {
if (e instanceof MethodArgumentNotValidException) {
// 参数验证异常处理
MethodArgumentNotValidException validException = (MethodArgumentNotValidException) e;
List<ObjectError> errorList = validException.getBindingResult().getAllErrors();
StringBuffer sb = new StringBuffer();
errorList.forEach(error ->
sb.append(error.getDefaultMessage()).append(";"));
log.error("【参数校验异常】{}", e);
return CommonJsonResponse.newErrorResponse(ResponseConsts.VALIDATE_ERROR.getCode(), sb.toString());
}
if (e instanceof BusinessException) {
club.joylink.rtss.exception.BusinessException be = (club.joylink.rtss.exception.BusinessException) e;
log.error("【业务异常】{}", e);
return CommonJsonResponse.newErrorResponse(be.getCode(), be.getVoMessage());
} else if (e instanceof MissingServletRequestParameterException) {
log.error("【接口参数异常】", e);
return CommonJsonResponse.newErrorResponse(ResponseConsts.VALIDATE_ERROR.getCode(), "接口参数异常");
} else if (e instanceof SimulationException) {
club.joylink.rtss.simulation.cbtc.exception.SimulationException simulationException = (club.joylink.rtss.simulation.cbtc.exception.SimulationException) e;
log.error("【仿真系统异常】{}", e);
return CommonJsonResponse.newErrorResponse(simulationException.getCode(), simulationException.getMessage());
}
@ExceptionHandler({PayException.class})
@ResponseStatus
public CommonJsonResponse handleException(PayException e) {
log.error("【支付异常】", e);
return CommonJsonResponse.newErrorResponse();
}
@ExceptionHandler({Exception.class})
@ResponseBody
public CommonJsonResponse handleException(Exception e) {
if(e instanceof MethodArgumentNotValidException) {
// 参数验证异常处理
MethodArgumentNotValidException validException = (MethodArgumentNotValidException) e;
List<ObjectError> errorList = validException.getBindingResult().getAllErrors();
StringBuffer sb = new StringBuffer();
errorList.forEach(error ->
sb.append(error.getDefaultMessage()).append(";"));
log.error("【参数校验异常】{}", e);
return CommonJsonResponse.newErrorResponse(ResponseConsts.VALIDATE_ERROR.getCode(), sb.toString());
} if(e instanceof BusinessException) {
club.joylink.rtss.exception.BusinessException be = (club.joylink.rtss.exception.BusinessException) e;
log.error("【业务异常】{}", e);
return CommonJsonResponse.newErrorResponse(be.getCode(), be.getVoMessage());
} else if(e instanceof MissingServletRequestParameterException) {
log.error("【接口参数异常】", e);
return CommonJsonResponse.newErrorResponse(ResponseConsts.VALIDATE_ERROR.getCode(), "接口参数异常");
} else if (e instanceof SimulationException) {
club.joylink.rtss.simulation.cbtc.exception.SimulationException simulationException = (club.joylink.rtss.simulation.cbtc.exception.SimulationException) e;
log.error("【仿真系统异常】{}", e);
return CommonJsonResponse.newErrorResponse(simulationException.getCode(), simulationException.getMessage());
}
log.error("【系统异常】{}", e);
return CommonJsonResponse.newErrorResponse();
}
log.error("【系统异常】{}", e);
return CommonJsonResponse.newErrorResponse();
}
}

View File

@ -43,7 +43,7 @@ public class RaceScoreRuleController {
this.scoreRuleService.editRule(ruleId, rule, user);
}
@GetMapping("/{id}")
@GetMapping(value = "/{id}", produces = {"application/json"})
public RaceScoringRuleVO detail(@PathVariable("id") Long id) {
return this.scoreRuleService.detail(id);
}

View File

@ -104,9 +104,9 @@ public class RaceSceneService extends RaceService {
}
public void publishHere(RaceScenePublishVO vo, AccountVO user) {
PublishHereVO phvo = this.createSceneProto(vo.getTraningPublishId());
PublishHereVO phvo = this.createSceneProto(vo.getDafitid());
RacetrSceneExample sceneExample = new RacetrSceneExample();
sceneExample.createCriteria().andDraftTrainingIdEqualTo(vo.getTraningPublishId());
sceneExample.createCriteria().andDraftTrainingIdEqualTo(vo.getDafitid());
List<RacetrScene> rsList = this.sceneDAO.selectByExample(sceneExample);
LocalDateTime now = LocalDateTime.now();
RacetrScene rs;
@ -116,7 +116,7 @@ public class RaceSceneService extends RaceService {
rs.setCreatorId(user.getId());
rs.setCreateTime(now);
rs.setType(Type.Local.name());
rs.setDraftTrainingId(vo.getTraningPublishId());
rs.setDraftTrainingId(vo.getDafitid());
} else {
sceneExist = true;
rs = rsList.get(0);
@ -151,7 +151,7 @@ public class RaceSceneService extends RaceService {
ss.setMemberJson(bs.getMemberJson());
ss.setStepJson(bs.getStepJson());
ss.addAllPlayerIds(plays);
return new PublishHereVO(bs.getMapId(), ss.build());
}

View File

@ -2527,20 +2527,20 @@ public final class RaceSceneOuterClass {
/**
* <pre>
*实训id
*实训草稿id
* </pre>
*
* <code>int64 traningPublishId = 1;</code>
* @return The traningPublishId.
* <code>int64 dafitid = 1;</code>
* @return The dafitid.
*/
long getTraningPublishId();
long getDafitid();
/**
* <pre>
* int64 mapId = 2;
* </pre>
*
* <code>string name = 2;</code>
* <code>string name = 3;</code>
* @return The name.
*/
java.lang.String getName();
@ -2549,7 +2549,7 @@ public final class RaceSceneOuterClass {
* int64 mapId = 2;
* </pre>
*
* <code>string name = 2;</code>
* <code>string name = 3;</code>
* @return The bytes for name.
*/
com.google.protobuf.ByteString
@ -2591,22 +2591,22 @@ public final class RaceSceneOuterClass {
club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceScenePublishVO.class, club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceScenePublishVO.Builder.class);
}
public static final int TRANINGPUBLISHID_FIELD_NUMBER = 1;
private long traningPublishId_ = 0L;
public static final int DAFITID_FIELD_NUMBER = 1;
private long dafitid_ = 0L;
/**
* <pre>
*实训id
*实训草稿id
* </pre>
*
* <code>int64 traningPublishId = 1;</code>
* @return The traningPublishId.
* <code>int64 dafitid = 1;</code>
* @return The dafitid.
*/
@java.lang.Override
public long getTraningPublishId() {
return traningPublishId_;
public long getDafitid() {
return dafitid_;
}
public static final int NAME_FIELD_NUMBER = 2;
public static final int NAME_FIELD_NUMBER = 3;
@SuppressWarnings("serial")
private volatile java.lang.Object name_ = "";
/**
@ -2614,7 +2614,7 @@ public final class RaceSceneOuterClass {
* int64 mapId = 2;
* </pre>
*
* <code>string name = 2;</code>
* <code>string name = 3;</code>
* @return The name.
*/
@java.lang.Override
@ -2635,7 +2635,7 @@ public final class RaceSceneOuterClass {
* int64 mapId = 2;
* </pre>
*
* <code>string name = 2;</code>
* <code>string name = 3;</code>
* @return The bytes for name.
*/
@java.lang.Override
@ -2667,11 +2667,11 @@ public final class RaceSceneOuterClass {
@java.lang.Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (traningPublishId_ != 0L) {
output.writeInt64(1, traningPublishId_);
if (dafitid_ != 0L) {
output.writeInt64(1, dafitid_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_);
com.google.protobuf.GeneratedMessageV3.writeString(output, 3, name_);
}
getUnknownFields().writeTo(output);
}
@ -2682,12 +2682,12 @@ public final class RaceSceneOuterClass {
if (size != -1) return size;
size = 0;
if (traningPublishId_ != 0L) {
if (dafitid_ != 0L) {
size += com.google.protobuf.CodedOutputStream
.computeInt64Size(1, traningPublishId_);
.computeInt64Size(1, dafitid_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_);
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, name_);
}
size += getUnknownFields().getSerializedSize();
memoizedSize = size;
@ -2704,8 +2704,8 @@ public final class RaceSceneOuterClass {
}
club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceScenePublishVO other = (club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceScenePublishVO) obj;
if (getTraningPublishId()
!= other.getTraningPublishId()) return false;
if (getDafitid()
!= other.getDafitid()) return false;
if (!getName()
.equals(other.getName())) return false;
if (!getUnknownFields().equals(other.getUnknownFields())) return false;
@ -2719,9 +2719,9 @@ public final class RaceSceneOuterClass {
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + TRANINGPUBLISHID_FIELD_NUMBER;
hash = (37 * hash) + DAFITID_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
getTraningPublishId());
getDafitid());
hash = (37 * hash) + NAME_FIELD_NUMBER;
hash = (53 * hash) + getName().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
@ -2855,7 +2855,7 @@ public final class RaceSceneOuterClass {
public Builder clear() {
super.clear();
bitField0_ = 0;
traningPublishId_ = 0L;
dafitid_ = 0L;
name_ = "";
return this;
}
@ -2891,7 +2891,7 @@ public final class RaceSceneOuterClass {
private void buildPartial0(club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceScenePublishVO result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.traningPublishId_ = traningPublishId_;
result.dafitid_ = dafitid_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.name_ = name_;
@ -2910,8 +2910,8 @@ public final class RaceSceneOuterClass {
public Builder mergeFrom(club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceScenePublishVO other) {
if (other == club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceScenePublishVO.getDefaultInstance()) return this;
if (other.getTraningPublishId() != 0L) {
setTraningPublishId(other.getTraningPublishId());
if (other.getDafitid() != 0L) {
setDafitid(other.getDafitid());
}
if (!other.getName().isEmpty()) {
name_ = other.name_;
@ -2945,15 +2945,15 @@ public final class RaceSceneOuterClass {
done = true;
break;
case 8: {
traningPublishId_ = input.readInt64();
dafitid_ = input.readInt64();
bitField0_ |= 0x00000001;
break;
} // case 8
case 18: {
case 26: {
name_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000002;
break;
} // case 18
} // case 26
default: {
if (!super.parseUnknownField(input, extensionRegistry, tag)) {
done = true; // was an endgroup tag
@ -2971,46 +2971,46 @@ public final class RaceSceneOuterClass {
}
private int bitField0_;
private long traningPublishId_ ;
private long dafitid_ ;
/**
* <pre>
*实训id
*实训草稿id
* </pre>
*
* <code>int64 traningPublishId = 1;</code>
* @return The traningPublishId.
* <code>int64 dafitid = 1;</code>
* @return The dafitid.
*/
@java.lang.Override
public long getTraningPublishId() {
return traningPublishId_;
public long getDafitid() {
return dafitid_;
}
/**
* <pre>
*实训id
*实训草稿id
* </pre>
*
* <code>int64 traningPublishId = 1;</code>
* @param value The traningPublishId to set.
* <code>int64 dafitid = 1;</code>
* @param value The dafitid to set.
* @return This builder for chaining.
*/
public Builder setTraningPublishId(long value) {
public Builder setDafitid(long value) {
traningPublishId_ = value;
dafitid_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
* <pre>
*实训id
*实训草稿id
* </pre>
*
* <code>int64 traningPublishId = 1;</code>
* <code>int64 dafitid = 1;</code>
* @return This builder for chaining.
*/
public Builder clearTraningPublishId() {
public Builder clearDafitid() {
bitField0_ = (bitField0_ & ~0x00000001);
traningPublishId_ = 0L;
dafitid_ = 0L;
onChanged();
return this;
}
@ -3021,7 +3021,7 @@ public final class RaceSceneOuterClass {
* int64 mapId = 2;
* </pre>
*
* <code>string name = 2;</code>
* <code>string name = 3;</code>
* @return The name.
*/
public java.lang.String getName() {
@ -3041,7 +3041,7 @@ public final class RaceSceneOuterClass {
* int64 mapId = 2;
* </pre>
*
* <code>string name = 2;</code>
* <code>string name = 3;</code>
* @return The bytes for name.
*/
public com.google.protobuf.ByteString
@ -3062,7 +3062,7 @@ public final class RaceSceneOuterClass {
* int64 mapId = 2;
* </pre>
*
* <code>string name = 2;</code>
* <code>string name = 3;</code>
* @param value The name to set.
* @return This builder for chaining.
*/
@ -3079,7 +3079,7 @@ public final class RaceSceneOuterClass {
* int64 mapId = 2;
* </pre>
*
* <code>string name = 2;</code>
* <code>string name = 3;</code>
* @return This builder for chaining.
*/
public Builder clearName() {
@ -3093,7 +3093,7 @@ public final class RaceSceneOuterClass {
* int64 mapId = 2;
* </pre>
*
* <code>string name = 2;</code>
* <code>string name = 3;</code>
* @param value The bytes for name to set.
* @return This builder for chaining.
*/
@ -5455,15 +5455,15 @@ public final class RaceSceneOuterClass {
"(\003\022\014\n\004name\030\002 \001(\t\022\"\n\004type\030\003 \001(\0162\024.race.Ra" +
"ceScene.Type\022\r\n\005mapId\030\004 \001(\003\022\017\n\007mapName\030\005" +
" \001(\t\022(\n\nmodifyInfo\030\006 \001(\0132\024.common.Modify" +
"InfoVO\"<\n\022RaceScenePublishVO\022\030\n\020traningP" +
"ublishId\030\001 \001(\003\022\014\n\004name\030\002 \001(\t\"H\n\005Scene\022\013\n" +
"\003url\030\001 \001(\t\0222\n\021storageSimulation\030\002 \001(\0132\027." +
"race.StorageSimulation\"a\n\021StorageSimulat" +
"ion\022\023\n\013bgSceneJson\030\001 \001(\t\022\020\n\010stepJson\030\002 \001" +
"(\t\022\022\n\nmemberJson\030\003 \001(\t\022\021\n\tplayerIds\030\004 \003(" +
"\t\"5\n\tRaceScene\"(\n\004Type\022\013\n\007Unknown\020\000\022\t\n\005L" +
"ocal\020\001\022\010\n\004Link\020\002B\033\n\031club.joylink.rtss.vo" +
".raceb\006proto3"
"InfoVO\"3\n\022RaceScenePublishVO\022\017\n\007dafitid\030" +
"\001 \001(\003\022\014\n\004name\030\003 \001(\t\"H\n\005Scene\022\013\n\003url\030\001 \001(" +
"\t\0222\n\021storageSimulation\030\002 \001(\0132\027.race.Stor" +
"ageSimulation\"a\n\021StorageSimulation\022\023\n\013bg" +
"SceneJson\030\001 \001(\t\022\020\n\010stepJson\030\002 \001(\t\022\022\n\nmem" +
"berJson\030\003 \001(\t\022\021\n\tplayerIds\030\004 \003(\t\"5\n\tRace" +
"Scene\"(\n\004Type\022\013\n\007Unknown\020\000\022\t\n\005Local\020\001\022\010\n" +
"\004Link\020\002B\033\n\031club.joylink.rtss.vo.raceb\006pr" +
"oto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
@ -5487,7 +5487,7 @@ public final class RaceSceneOuterClass {
internal_static_race_RaceScenePublishVO_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_race_RaceScenePublishVO_descriptor,
new java.lang.String[] { "TraningPublishId", "Name", });
new java.lang.String[] { "Dafitid", "Name", });
internal_static_race_Scene_descriptor =
getDescriptor().getMessageTypes().get(3);
internal_static_race_Scene_fieldAccessorTable = new