Commit fb1fceca authored by liming's avatar liming

日常赛发布和删除

parent 78af6900
......@@ -7,10 +7,7 @@ import com.antai.sport.http.server.management.api.business.simplematch.service.S
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -29,4 +26,20 @@ public class SimpleMatchController {
public ResponseEntity<Result<SimpleMatchListResponseDTO>> getMatchList(@RequestBody SimpleMatchListRequestDTO param) {
return success(simpleMatchService.getMatchList(param));
}
@ApiOperation("删除")
@DeleteMapping("/{matchId}")
public ResponseEntity<Result> deleteMatch(@PathVariable("matchId") Long matchId) {
simpleMatchService.deleteMatch(matchId);
return success();
}
@ApiOperation("更改发布状态")
@PutMapping("/{matchId}")
public ResponseEntity<Result> publish(@PathVariable("matchId") Long matchId) {
simpleMatchService.publish(matchId);
return success();
}
}
......@@ -13,4 +13,5 @@ public class SimpleMatchListVO {
private String pathName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime startTime;
private Integer status;
}
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.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.vo.SimpleMatchListVO;
import com.antai.sport.http.server.management.api.business.simplematch.mapper.SimpleMatchBusinessMapper;
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;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -14,6 +18,8 @@ import javax.annotation.Resource;
@Service
public class SimpleMatchService {
@Resource
private SimpleMatchMapper simpleMatchMapper;
@Resource
private SimpleMatchBusinessMapper simpleMatchBusinessMapper;
......@@ -31,4 +37,24 @@ public class SimpleMatchService {
dto.setTotalCount(result.getTotal());
return dto;
}
public void deleteMatch(Long matchId) {
SimpleMatch simpleMatch = simpleMatchMapper.selectById(matchId);
if (simpleMatch.getStatus() != null && simpleMatch.getStatus().equals(20)) {
throw new BusinessException("已发布比赛不能删除");
}
simpleMatch.setDeleted(Integer.valueOf(DeleteStatus.DELETED));
simpleMatchMapper.updateById(simpleMatch);
}
public void publish(Long matchId) {
SimpleMatch simpleMatch = simpleMatchMapper.selectById(matchId);
if (simpleMatch.getStatus() == null || simpleMatch.getStatus().equals(10)) {
simpleMatch.setStatus(20);
} else {
simpleMatch.setStatus(10);
}
simpleMatchMapper.updateById(simpleMatch);
}
}
......@@ -79,6 +79,11 @@ public class SimpleMatch implements Serializable {
*/
private String description;
/**
* 状态 10:未发布 20:已发布
*/
private Integer status;
/**
* 显示顺序
*/
......
......@@ -16,6 +16,7 @@
) t2 on t1.id = t2.match_id
where t1.end_time &gt; #{now}
and t1.deleted = 0
and t1.status = 20
) t1
order by t1.registered desc, t1.show_order, t1.start_time
</select>
......@@ -25,6 +26,7 @@
from simple_match t1
where t1.end_time &gt; #{now}
and t1.deleted = 0
and t1.status = 20
order by t1.show_order, t1.start_time
</select>
......
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