Merge branch 'refs/heads/dev-czt-11'

# Conflicts:
#	src/main/java/com/example/catchTheLetters/service/LevelService.java
#	src/main/java/com/example/catchTheLetters/service/impl/LevelServiceImpl.java
This commit is contained in:
石皮幼鸟 2024-04-12 09:26:09 +08:00
commit 792493119f
4 changed files with 178 additions and 2 deletions

View File

@ -34,6 +34,8 @@ public class Level implements Serializable {
* 限时可选毫秒数 * 限时可选毫秒数
*/ */
private Long timeLimit; private Long timeLimit;
/** /**
* 目标分数type=1时有效 * 目标分数type=1时有效
*/ */
@ -42,4 +44,83 @@ public class Level implements Serializable {
* 单词列表 * 单词列表
*/ */
private List<String> words; private List<String> words;
public Level(String id,Integer order,String name,Integer type,Long timeLimit,Integer targetScore, List<String> words){
this.id=id;
this.order=order;
this.name=name;
this.type=type;
this.timeLimit=timeLimit;
this.targetScore=targetScore;
this.words=words;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Long getTimeLimit() {
return timeLimit;
}
public void setTimeLimit(Long timeLimit) {
this.timeLimit = timeLimit;
}
public Integer getTargetScore() {
return targetScore;
}
public void setTargetScore(Integer targetScore) {
this.targetScore = targetScore;
}
public List<String> getWords() {
return words;
}
public void setWords(List<String> words) {
this.words = words;
}
@Override
public String toString(){
return "Level{" +
"id=" + id +
", order= '"+ order +'\''+
", name= '"+ name +'\''+
", type= '"+ type +'\''+
", timeLimit= '"+ timeLimit +'\''+
", targetScore= '"+ targetScore +'\''+
", words= '"+ words +'\''+'}';
}
} }

View File

@ -31,4 +31,53 @@ public class ScoreInfo implements Serializable {
* 时间UNIX时间戳 * 时间UNIX时间戳
*/ */
private Long time; private Long time;
public ScoreInfo(Long userId,Long levelId,String username,Integer score, Long time){
this.userId=userId;
this.levelId=levelId;
this.username=username;
this.score=score;
this.time=time;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getLevelId() {
return levelId;
}
public void setLevelId(Long levelId) {
this.levelId = levelId;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Integer getScore() {
return score;
}
public void setScore(Integer score) {
this.score = score;
}
public Long getTime() {
return time;
}
public void setTime(Long time) {
this.time = time;
}
} }

View File

@ -3,7 +3,6 @@ package com.example.catchTheLetters.service;
import com.example.catchTheLetters.entity.Level; import com.example.catchTheLetters.entity.Level;
import com.example.catchTheLetters.entity.ScoreInfo; import com.example.catchTheLetters.entity.ScoreInfo;
import com.example.catchTheLetters.utils.R; import com.example.catchTheLetters.utils.R;
import java.util.List; import java.util.List;
/** /**
@ -13,10 +12,34 @@ import java.util.List;
* @description * @description
*/ */
public interface LevelService { public interface LevelService {
/**
*
* @param id
* @return token
*/
R<Level> levelDetail(Long id); R<Level> levelDetail(Long id);
/**
*
* @return token
*/
R<List<Level>> list(); R<List<Level>> list();
R<ScoreInfo> settle(ScoreInfo scoreInfo, String token); R<ScoreInfo> settle(ScoreInfo scoreInfo, String token);
/**
* @param levelId
* @return 关卡排行信息
*/
Integer getRankInfo(String levelId);
/**
*
* @param level
* @return 关卡创建是否成功
*/
boolean LevelCreate(Level level);
} }

View File

@ -6,7 +6,6 @@ import com.example.catchTheLetters.service.LevelService;
import com.example.catchTheLetters.utils.JwtUtil; import com.example.catchTheLetters.utils.JwtUtil;
import com.example.catchTheLetters.utils.R; import com.example.catchTheLetters.utils.R;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.data.annotation.QueryAnnotation;
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;
@ -59,4 +58,28 @@ public class LevelServiceImpl implements LevelService {
} }
return R.fail("添加失败,请重试"); return R.fail("添加失败,请重试");
} }
@Override
public Integer getRankInfo(String levelId) {
ScoreInfo sc=mongoTemplate.findById(2,ScoreInfo.class);
Integer infor = null;
if(sc!=null) {
infor = sc.getScore();
}
return infor;
}
@Override
public boolean LevelCreate(Level level) {
String s=level.toString();
if (s != null) {
mongoTemplate.insert(s);
return true;
}
return false;
}
} }