parent
1044fa0ff6
commit
3a7849163d
@ -0,0 +1,17 @@
|
||||
package com.kob.backend.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MybatisConfig {
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
return interceptor;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.kob.backend.controller.ranklist;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.kob.backend.service.ranklist.RankListService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
public class RankListController {
|
||||
@Autowired
|
||||
private RankListService rankListService;
|
||||
|
||||
@GetMapping("/ranklist/getlist")
|
||||
public JSONObject getList(@RequestParam Map<String,String> data){
|
||||
Integer page = Integer.parseInt(data.get("page"));
|
||||
return rankListService.getList(page);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.kob.backend.controller.record;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.kob.backend.service.record.GetRecordListService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
public class GetRecordListController {
|
||||
@Autowired
|
||||
private GetRecordListService getRecordListService;
|
||||
|
||||
@GetMapping("/record/getlist/")
|
||||
public JSONObject getList(@RequestParam Map<String,String> data){
|
||||
Integer page = Integer.parseInt(data.get("page"));
|
||||
return getRecordListService.getList(page);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.kob.backend.service.impl.ranklist;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.kob.backend.mapper.UserMapper;
|
||||
import com.kob.backend.pojo.User;
|
||||
import com.kob.backend.service.ranklist.RankListService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RankListServiceImpl implements RankListService {
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public JSONObject getList(Integer page) {
|
||||
IPage<User> userIPage = new Page<>(page,10);
|
||||
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("rating");
|
||||
List<User> users = userMapper.selectPage(userIPage,queryWrapper).getRecords();
|
||||
JSONObject resp = new JSONObject();
|
||||
for(User user:users){
|
||||
user.setPassword("");
|
||||
}
|
||||
resp.put("users",users);
|
||||
resp.put("users_count",userMapper.selectCount(null));
|
||||
return resp;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.kob.backend.service.impl.record;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.kob.backend.mapper.RecordMapper;
|
||||
import com.kob.backend.mapper.UserMapper;
|
||||
import com.kob.backend.pojo.Record;
|
||||
import com.kob.backend.pojo.User;
|
||||
import com.kob.backend.service.record.GetRecordListService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class GetRecordListServiceImpl implements GetRecordListService {
|
||||
@Autowired
|
||||
private RecordMapper recordMapper ;
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public JSONObject getList(Integer page) {
|
||||
IPage<Record> recordIPage = new Page<>(page,10);//API
|
||||
QueryWrapper<Record> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("id");//按照降序排列
|
||||
List<Record> records = recordMapper.selectPage(recordIPage,queryWrapper).getRecords();//一页
|
||||
JSONObject resp = new JSONObject();
|
||||
List<JSONObject> items = new ArrayList<>();
|
||||
for(Record record:records){
|
||||
User userA = userMapper.selectById(record.getAId());
|
||||
User userB = userMapper.selectById(record.getBId());
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("a_photo",userA.getPhoto());
|
||||
item.put("a_username",userA.getUsername());
|
||||
item.put("b_photo",userB.getPhoto());
|
||||
item.put("b_username",userB.getUsername());
|
||||
item.put("record",record);
|
||||
String result = "平局" ;
|
||||
if("A".equals(record.getLoser())){
|
||||
result = "B胜" ;
|
||||
} else if ("B".equals(record.getLoser())){
|
||||
result = "A胜" ;
|
||||
}
|
||||
item.put("result",result);
|
||||
items.add(item);
|
||||
}
|
||||
resp.put("records",items);
|
||||
resp.put("records_count",recordMapper.selectCount(null));
|
||||
return resp;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.kob.backend.service.ranklist;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public interface RankListService {
|
||||
public JSONObject getList(Integer page);
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
// import $ from "jquery"
|
||||
|
||||
export default {
|
||||
state: {
|
||||
is_record : false ,
|
||||
a_steps:"",
|
||||
b_steps:"",
|
||||
record_loser:"",
|
||||
},
|
||||
getters: {
|
||||
},
|
||||
mutations: {
|
||||
updateIsRecord(state,is_record){
|
||||
state.is_record = is_record;
|
||||
},
|
||||
updateSteps(state,data){
|
||||
state.a_steps = data.a_steps;
|
||||
state.b_steps = data.b_steps;
|
||||
},
|
||||
updateRecordLoser(state,loser){
|
||||
state.record_loser = loser ;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
},
|
||||
modules: {
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<PlayGround></PlayGround>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import PlayGround from "@/components/PlayGround"
|
||||
|
||||
export default {
|
||||
components:{
|
||||
PlayGround,
|
||||
},
|
||||
setup(){
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
Loading…
Reference in new issue