Commit 4d866872 authored by liming's avatar liming

文本编辑器和文件上传

parent c6aec543
......@@ -3,6 +3,8 @@ package com.antai.sport.http.server.management.api.business.simplematch.controll
import com.antai.sport.http.server.common.base.Result;
import com.antai.sport.http.server.management.api.business.simplematch.dto.SimpleMatchListRequestDTO;
import com.antai.sport.http.server.management.api.business.simplematch.dto.SimpleMatchListResponseDTO;
import com.antai.sport.http.server.management.api.business.simplematch.dto.SimpleMatchResponseDTO;
import com.antai.sport.http.server.management.api.business.simplematch.dto.vo.SimpleMatchVO;
import com.antai.sport.http.server.management.api.business.simplematch.service.SimpleMatchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -41,5 +43,18 @@ public class SimpleMatchController {
return success();
}
@ApiOperation("获取用户数据")
@GetMapping("/{matchId}")
public ResponseEntity<Result<SimpleMatchResponseDTO>> getSimpleMatch(@PathVariable("matchId") Long matchId) {
return success(simpleMatchService.getSimpleMatch(matchId));
}
@ApiOperation("创建日常赛")
@PostMapping("")
public ResponseEntity<Result> save(@RequestBody SimpleMatchVO simpleMatchVO) {
simpleMatchService.save(simpleMatchVO);
return success();
}
}
package com.antai.sport.http.server.management.api.business.simplematch.converter;
import com.antai.sport.http.server.management.api.business.simplematch.dto.vo.SimpleMatchVO;
import com.antai.sport.http.server.repository.simplematch.entity.SimpleMatch;
import org.mapstruct.Mapper;
@Mapper(componentModel = "spring")
public interface SimpleMatchConverter {
SimpleMatchVO toSimpleMatchVO(SimpleMatch source);
SimpleMatch toSimpleMatch(SimpleMatchVO source);
}
package com.antai.sport.http.server.management.api.business.simplematch.dto;
import com.antai.sport.http.server.management.api.business.simplematch.dto.vo.MapPathVO;
import com.antai.sport.http.server.management.api.business.simplematch.dto.vo.SimpleMatchVO;
import lombok.Data;
import java.util.List;
@Data
public class SimpleMatchResponseDTO {
private SimpleMatchVO simpleMatch;
private List<MapPathVO> mapList;
}
package com.antai.sport.http.server.management.api.business.simplematch.dto.vo;
import lombok.Data;
import java.util.List;
@Data
public class MapPathVO {
private Integer id;
private String key;
private String name;
List<MapPathVO> pathList;
}
package com.antai.sport.http.server.management.api.business.simplematch.dto.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
public class SimpleMatchVO {
private Long id;
private String name;
private String logo;
private String map;
private String path;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime entryTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime endTime;
private BigDecimal distance;
private BigDecimal climbDistance;
private String description;
private Integer status;
}
......@@ -2,10 +2,18 @@ package com.antai.sport.http.server.management.api.business.simplematch.service;
import com.antai.sport.http.server.common.exception.BusinessException;
import com.antai.sport.http.server.constants.DeleteStatus;
import com.antai.sport.http.server.management.api.business.simplematch.converter.SimpleMatchConverter;
import com.antai.sport.http.server.management.api.business.simplematch.dto.SimpleMatchListRequestDTO;
import com.antai.sport.http.server.management.api.business.simplematch.dto.SimpleMatchListResponseDTO;
import com.antai.sport.http.server.management.api.business.simplematch.dto.SimpleMatchResponseDTO;
import com.antai.sport.http.server.management.api.business.simplematch.dto.vo.MapPathVO;
import com.antai.sport.http.server.management.api.business.simplematch.dto.vo.SimpleMatchListVO;
import com.antai.sport.http.server.management.api.business.simplematch.dto.vo.SimpleMatchVO;
import com.antai.sport.http.server.management.api.business.simplematch.mapper.SimpleMatchBusinessMapper;
import com.antai.sport.http.server.repository.map.entity.Map;
import com.antai.sport.http.server.repository.map.entity.MapPath;
import com.antai.sport.http.server.repository.map.mapper.MapMapper;
import com.antai.sport.http.server.repository.map.mapper.MapPathMapper;
import com.antai.sport.http.server.repository.simplematch.entity.SimpleMatch;
import com.antai.sport.http.server.repository.simplematch.mapper.SimpleMatchMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -15,6 +23,9 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Service
public class SimpleMatchService {
......@@ -22,6 +33,12 @@ public class SimpleMatchService {
private SimpleMatchMapper simpleMatchMapper;
@Resource
private SimpleMatchBusinessMapper simpleMatchBusinessMapper;
@Resource
private MapMapper mapMapper;
@Resource
private MapPathMapper mapPathMapper;
@Resource
private SimpleMatchConverter simpleMatchConverter;
public SimpleMatchListResponseDTO getMatchList(SimpleMatchListRequestDTO param) {
Page<SimpleMatchListVO> pageParam = new Page<>(param.getPageNo(), param.getPageSize());
......@@ -57,4 +74,53 @@ public class SimpleMatchService {
simpleMatchMapper.updateById(simpleMatch);
}
public SimpleMatchResponseDTO getSimpleMatch(Long matchId) {
SimpleMatchResponseDTO result = new SimpleMatchResponseDTO();
SimpleMatch simpleMatch;
if (matchId == null || matchId == 0) {
simpleMatch = new SimpleMatch();
simpleMatch.setStatus(10);
} else {
simpleMatch = simpleMatchMapper.selectById(matchId);
if (simpleMatch == null) {
throw new BusinessException("您查询的比赛不存在");
}
}
SimpleMatchVO simpleMatchVO = simpleMatchConverter.toSimpleMatchVO(simpleMatch);
result.setSimpleMatch(simpleMatchVO);
List<Map> mapList = mapMapper.selectList(null);
List<MapPath> mapPathList = mapPathMapper.selectList(null);
HashMap<String, MapPathVO> mapPathVOHashMap = new HashMap<>();
List<MapPathVO> mapPathVOList = new ArrayList<>(mapList.size());
mapList.forEach(item -> {
MapPathVO mapVO = new MapPathVO();
mapVO.setId(item.getId());
mapVO.setKey(item.getMapKey());
mapVO.setName(item.getMapName());
mapVO.setPathList(new ArrayList<>());
mapPathVOList.add(mapVO);
mapPathVOHashMap.put(item.getMapKey(), mapVO);
});
mapPathList.forEach(item -> {
MapPathVO mapPathVO = new MapPathVO();
mapPathVO.setId(item.getId());
mapPathVO.setKey(item.getPathKey());
mapPathVO.setName(item.getPathName());
if (mapPathVOHashMap.containsKey(item.getMapKey())) {
mapPathVOHashMap.get(item.getMapKey()).getPathList().add(mapPathVO);
}
});
result.setMapList(mapPathVOList);
return result;
}
public void save(SimpleMatchVO simpleMatchVO) {
SimpleMatch simpleMatch = simpleMatchConverter.toSimpleMatch(simpleMatchVO);
if (simpleMatch.getId() != null && simpleMatch.getId() > 0) {
simpleMatchMapper.updateById(simpleMatch);
} else {
simpleMatchMapper.insert(simpleMatch);
}
}
}
package com.antai.sport.http.server.repository.map.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author liming
* @since 2022-04-21
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class Map implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String mapKey;
private String mapName;
}
package com.antai.sport.http.server.repository.map.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author liming
* @since 2022-04-21
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class MapPath implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String mapKey;
private String pathKey;
private String pathName;
}
package com.antai.sport.http.server.repository.map.mapper;
import com.antai.sport.http.server.repository.map.entity.Map;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author liming
* @since 2022-04-21
*/
public interface MapMapper extends BaseMapper<Map> {
}
package com.antai.sport.http.server.repository.map.mapper;
import com.antai.sport.http.server.repository.map.entity.MapPath;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author liming
* @since 2022-04-21
*/
public interface MapPathMapper extends BaseMapper<MapPath> {
}
<?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="com.antai.sport.http.server.repository.map.mapper.MapMapper">
</mapper>
<?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="com.antai.sport.http.server.repository.map.mapper.MapPathMapper">
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment