Compare commits
4 Commits
6c2cb2b197
...
289fe1c009
Author | SHA1 | Date |
---|---|---|
石皮幼鸟 | 289fe1c009 | |
石皮幼鸟 | baa889f73b | |
石皮幼鸟 | 4af5dae371 | |
Ch3nGO | a7442babbe |
|
@ -24,7 +24,6 @@ import java.util.List;
|
||||||
@Api(tags = "关卡API")
|
@Api(tags = "关卡API")
|
||||||
@RequestMapping("/level")
|
@RequestMapping("/level")
|
||||||
public class LevelController {
|
public class LevelController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private LevelService levelService;
|
private LevelService levelService;
|
||||||
|
|
||||||
|
@ -49,14 +48,15 @@ public class LevelController {
|
||||||
|
|
||||||
@ApiOperation(value = "关卡修改(web前端管理员提交)")
|
@ApiOperation(value = "关卡修改(web前端管理员提交)")
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public R update(@RequestBody Level level) {
|
public R update(@RequestBody Level level)
|
||||||
return null;
|
{
|
||||||
|
return levelService.update(level) ? R.ok() : R.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "关卡删除(web前端管理员提交)")
|
@ApiOperation(value = "关卡删除(web前端管理员提交)")
|
||||||
@PostMapping("/delete")
|
@PostMapping("/delete")
|
||||||
public R delete(String id) {
|
public R delete(String id) {
|
||||||
return null;
|
return levelService.delete(id) ? R.ok() : R.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取某个关卡排行榜数据")
|
@ApiOperation(value = "获取某个关卡排行榜数据")
|
||||||
|
|
|
@ -55,4 +55,19 @@ public interface LevelService {
|
||||||
*/
|
*/
|
||||||
boolean levelCreate(Level level);
|
boolean levelCreate(Level level);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除关卡
|
||||||
|
* @param id 关卡id
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean delete(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新关卡
|
||||||
|
* @param level 关卡
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean update(Level level);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import jakarta.annotation.Resource;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
import org.springframework.data.mongodb.core.query.Criteria;
|
import org.springframework.data.mongodb.core.query.Criteria;
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
|
import com.mongodb.client.result.DeleteResult;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -53,7 +54,7 @@ public class LevelServiceImpl implements LevelService {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return R.fail("token解析失败");
|
return R.fail("token解析失败");
|
||||||
}
|
}
|
||||||
if (id.equals(scoreInfo.getUserId().toString())){
|
if (id.equals(scoreInfo.getUserId())) {
|
||||||
ScoreInfo insert = mongoTemplate.insert(scoreInfo);
|
ScoreInfo insert = mongoTemplate.insert(scoreInfo);
|
||||||
return R.ok(insert);
|
return R.ok(insert);
|
||||||
}
|
}
|
||||||
|
@ -90,4 +91,18 @@ public class LevelServiceImpl implements LevelService {
|
||||||
var insert = mongoTemplate.insert(level);
|
var insert = mongoTemplate.insert(level);
|
||||||
return insert.getId() != null;
|
return insert.getId() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delete(String id) {
|
||||||
|
Level level = new Level();
|
||||||
|
level.setId(id);
|
||||||
|
DeleteResult deleteRequest = mongoTemplate.remove(level);
|
||||||
|
return deleteRequest.getDeletedCount() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(Level level) {
|
||||||
|
var save = mongoTemplate.save(level);
|
||||||
|
return save.getId() != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue