Merge branch 'refs/heads/dev-01'
# Conflicts: # src/main/java/com/example/catchTheLetters/controller/LevelController.java # src/main/java/com/example/catchTheLetters/service/LevelService.java # src/main/java/com/example/catchTheLetters/service/impl/LevelServiceImpl.java
This commit is contained in:
commit
baa889f73b
|
@ -24,7 +24,6 @@ import java.util.List;
|
|||
@Api(tags = "关卡API")
|
||||
@RequestMapping("/level")
|
||||
public class LevelController {
|
||||
|
||||
@Resource
|
||||
private LevelService levelService;
|
||||
|
||||
|
@ -49,14 +48,15 @@ public class LevelController {
|
|||
|
||||
@ApiOperation(value = "关卡修改(web前端管理员提交)")
|
||||
@PostMapping("/update")
|
||||
public R update(@RequestBody Level level) {
|
||||
return null;
|
||||
public R update(@RequestBody Level level)
|
||||
{
|
||||
return levelService.update(level) ? R.ok() : R.fail();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "关卡删除(web前端管理员提交)")
|
||||
@PostMapping("/delete")
|
||||
public R delete(String id) {
|
||||
return null;
|
||||
return levelService.delete(id) ? R.ok() : R.fail();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取某个关卡排行榜数据")
|
||||
|
|
|
@ -55,4 +55,19 @@ public interface LevelService {
|
|||
*/
|
||||
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.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -90,4 +91,18 @@ public class LevelServiceImpl implements LevelService {
|
|||
var insert = mongoTemplate.insert(level);
|
||||
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