排行页面

sale
tianea 3 years ago
parent b43c855735
commit 71556f3135

@ -17,8 +17,12 @@ export default {
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
text-align: center; text-align: center;
color: #2c3e50; color: #2c3e50;
max-width: 1920px; max-width: 120rem;
margin: auto; margin: auto;
background-color: #f5f5f5; background-color: #f5f5f5;
} }
html,body{
width: 100%;
height: 100%;
}
</style> </style>

@ -1,9 +1,8 @@
import request from '@/utils/request' import request from '@/utils/request'
let baseUrl = '/api/competition/' let baseUrl = '/api/competition/'
export function getList(query) { export function getList(pageNO,type) {
return request({ return request({
url: baseUrl+'list', url: baseUrl+'list'+"/"+type+"/"+pageNO,
method: 'post', method: 'get'
data: query
}) })
} }

@ -330,6 +330,9 @@ import Footer from '@/components/footer.vue'
export default { export default {
components:{ components:{
"tz-footer": Footer "tz-footer": Footer
},
mounted(){
}, },
methods:{ methods:{
goCompetition(id){ goCompetition(id){

@ -4,6 +4,7 @@ import Index from '@/components/index'
import CompetitionIndex from '@/views/competition/index' import CompetitionIndex from '@/views/competition/index'
import Login from '@/views/login/index' import Login from '@/views/login/index'
import Exam from '@/views/system/exam' import Exam from '@/views/system/exam'
import Member from '@/views/member/index'
Vue.use(Router) Vue.use(Router)
@ -29,6 +30,11 @@ export default new Router({
path: '/exam', path: '/exam',
name: 'Exam', name: 'Exam',
component: Exam component: Exam
},
{
path: '/member',
name: 'Member',
component: Member
} }
] ]
}) })

@ -0,0 +1,139 @@
<template>
<div>
<div class="member_header">
<div>
<b-img class="logo" src="/static/image/logo_white.png" />
<b-img src="/static/image/title.png" />
</div>
<div class="tz-flex">
<div>
<b-img src="/static/image/icon_admin1_30x30.png" />
<span>首页</span>
</div>
<div>
<b-img src="/static/image/icon_admin2_30x30.png" />
<span>个人中心</span>
</div>
<div>
<b-img src="/static/image/icon_admin3_30x30.png" />
<span>退出</span>
</div>
</div>
</div>
<b-container class="member_info">
<b-row>
<b-col sm="3">
<div class="left_panel">
<div>
<b-img src="/static/image/icon_admin4_30x30.png" /> 个人中心
</div>
<div>
个人信息
</div>
</div>
</b-col>
<b-col>
<div>
<b-img src="/static/image/admin_tx.jpg" />
</div>
<div class="info">
<div>
下午好李女士
</div>
<div>
<b-img src="/static/image/icon_admin5_20x20.png" />
<span> 上次登录1天前</span>
</div>
<div>
<span> 上次登陆IP: 110.12.68.64</span>
<span> IP登陆地: 广东省深圳市宝安区</span>
</div>
</div>
</b-col>
</b-row>
</b-container>
<tz-footer />
</div>
</template>
<script>
import Footer from '@/components/footer'
export default {
components:{
"tz-footer": Footer
}
}
</script>
<style scoped>
.logo{
width: 2rem;
height: 2rem;
}
.member_header{
background-image: url('/static/image/member_bg.jpg');
background-size: cover;
min-height: 90px;
display: flex;
justify-content: space-around;
align-items: center;
}
.member_content{
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 1rem;
margin-top: 1rem;
}
.tz-flex{
display: flex;
color: white;
align-items: center;
}
.tz-flex div{
margin-right: 1rem;
font-weight: 500;
}
.left_panel{
background-color: white;
margin-right: 1rem;
}
.left_panel div{
padding: 0.5rem 3rem 0.5rem 3rem ;
}
.left_panel img{
margin-right: 1rem;
}
.left_panel div:nth-child(1){
background-color: #016fe7;
/* background-image: linear-gradient(to rigth ,#00a0f1, #0163e4); */
background-image: linear-gradient(to right, #00a1f1 , #0163e4);
color: white;
font-weight: bolder;
text-align: left;
}
.member_info{
padding: 1rem;
}
.info{
width: 100%;
}
.info div{
margin-top: .5rem;
text-align: left;
padding-left: 1rem;
}
.info div:nth-child(1){
font-weight: bold;
color: black;
}
.info div:nth-child(2) span{
display: inline-block;
background-color: #fe7e01;
border-radius: 10px;
color: white;
padding: 0 1rem 0 1rem;
}
.info div:nth-child(3) span{
margin-right: 1rem;
}
</style>

@ -12,20 +12,35 @@
<script> <script>
export default { export default {
created(){ created(){
this.cutDownManger = setInterval(tihs.cutDown,1000) this.startTime = new Date(this.start)
this.endTime = new Date(this.end)
},
mounted(){
let end = setInterval(() => {
}, 3000);
for(var i = 0;i<=end;i++){
clearInterval(i);
}
console.log("cutDown component mounted")
this.cutDownManger = setInterval(this.cutDown,1000)
}, },
props:{ props:{
startTime:{ start:{
type: Date, type: String,
default: null default: null
}, },
endTime:{ end:{
type: Date, type: String,
default: null default: null
} }
}, },
data(){ data(){
return { return {
startTime: null,
endTime: null,
hundred:9, hundred:9,
ten: 9, ten: 9,
bit: 9, bit: 9,
@ -36,17 +51,19 @@ export default {
}, },
methods:{ methods:{
cutDown(){ cutDown(){
if(this.endTime.getTime()<Date.getTime()&&this.startTime.getTime()>=Date.getTime()){ let now = new Date()
let remaind = Date.getTime() - this.endTime.getTime() console.log(this.cutDownManger)
if( this.endTime.getTime()>now.getTime()&&this.startTime.getTime()<=now.getTime()){
let remaind = this.endTime.getTime() - now.getTime()
let seconds = Math.floor(remaind/1000) let seconds = Math.floor(remaind/1000)
let sec = seconds%60 let sec = seconds%60
let minutes = (seconds - sec)%60 let minutes =Math.floor(seconds/60)
this.sec2 = sec%10 this.sec2 = sec%10
this.sec1 = sec - this.sec2 this.sec1 = (sec - this.sec2)%100/10
this.bit = minutes%10; this.bit = minutes%10;
this.then = (minutes - this.bit)%100 this.ten =Math.floor( minutes %100/10)
this.hundred = (minutes - this.then - this. bit)%1000 this.hundred =Math.floor( minutes %1000/100)
}else if(this.endTime.getTime()>=Date.getTime()) { }else if(this.endTime.getTime()<=now.getTime()) {
this.hundred = 0 this.hundred = 0
this.ten = 0 this.ten = 0
this.bit =0 this.bit =0
@ -63,16 +80,22 @@ export default {
</script> </script>
<style scoped> <style scoped>
.cutdown{ .cutdown{
display: inline-block;
position: relative; position: relative;
display: flex; max-width: 15rem;
} }
.cd-text{ .cd-text{
color: white; color: white;
font-weight: bolder;
} }
.cd-time{ .cd-time{
display: inline-block; display: inline-block;
background-color: white; background-color: white;
color: black; color: black;
padding: 3px;
border-radius: 5px;
font-weight: bold;
padding-left: .5rem;
padding-right: .5rem;
} }
</style> </style>

@ -7,10 +7,61 @@
<b-img src="/static/image/exam_title.png" /> <b-img src="/static/image/exam_title.png" />
</div> </div>
<div> <div>
<cut-down endTime="2022-3-9 00:00:00" startTime="2022-3-8 00:00:00" /> <cut-down start="2022-3-9 00:00:00" end="2022-3-9 03:00:00" />
</div>
</div>
<div class="exam-header-title">
<div>
2020年全国高职财经大数据分析大赛--金融实操赛项
</div>
<div>
<b-button class="exam-button">交卷</b-button>
</div> </div>
</div> </div>
</div> </div>
<div class="tz-exam-content">
<div class="tz-exam-left-panel">
<div class="tz-exam-box">
<div class="tz-exam-box-title2">产品研究部试用吴京和</div>
<div class="tz-exam-box-content">
<b-img src="/static/image/tx80x80.png" /> 考试日期 2022-10-10
</div>
</div>
<div class="tz-exam-box">
<div class="tz-exam-box-title">
<b-img src="/static/image/icon_answer2_25x25.png" />
单选题
</div>
<div class="tz-exam-box-content">
<span v-for="(item,$index) in singleQuestion" :key="$index" :class="getStatus(item.id)" > {{ item.id }} </span>
</div>
</div>
<div class="tz-exam-box">
<div class="tz-exam-box-title">
<b-img src="/static/image/icon_answer3_25x25.png" />
多选题
</div>
<div class="tz-exam-box-content">
<span v-for="(item,$index) in multiQuestion" :key="$index" :class="getStatus(item.id)"> {{ item.id }} </span>
</div>
</div>
<div class="tz-exam-box">
<div class="tz-exam-box-title">
<b-img src="/static/image/icon_answer4_25x25.png" />
判断题
</div>
<div class="tz-exam-box-content">
<span v-for="(item,$index) in judgeQuestion" :key="$index" :class="getStatus(item.id)"> {{ item.id }} </span>
</div>
</div>
<div class="tz-exam-box-tips">
<span class="done">已答</span><span class="notAnwser">未答</span><span class="sign">标记</span>
</div>
</div>
<div>
</div>
</div>
</div> </div>
</template> </template>
<script> <script>
@ -18,7 +69,42 @@ import CutDown from './cutdown.vue'
export default { export default {
data(){ data(){
return { return {
singleQuestion: [],
multiQuestion: [],
judgeQuestion: [],
doneList:[],
markList:[],
current: 20
}
},
methods:{
getStatus(id){
let c = "";
if(id == this.current){
c = "current"
}
if(this.markList.indexOf(id)>=0){
return c +" sign"
}
if(this.doneList.indexOf(id)>=0){
return c+ " done"
}
return c +"notAnwser";
}
},
created(){
this.doneList = [1,3,5,20,50,88]
this.markList = [2,6,9,10,80,100,120]
for(var i = 1;i<=60;i++){
this.singleQuestion.push({id:i,name: ''})
}
let startIndex =this.singleQuestion.length+1
for(var i = startIndex; i<=startIndex +40; i++){
this.multiQuestion.push({id:i,name: ''})
}
startIndex =this.singleQuestion.length+ this.multiQuestion.length +1
for(var i = startIndex; i<= startIndex +20;i++){
this.judgeQuestion.push({id:i,name: ''})
} }
}, },
components:{ components:{
@ -30,13 +116,138 @@ export default {
.tz-exam-header{ .tz-exam-header{
background-image: url('/static/image/answer_topbg_1990x140.jpg'); background-image: url('/static/image/answer_topbg_1990x140.jpg');
background-size: cover; background-size: cover;
min-height: 140px; display: flex;
justify-content: center;
flex-wrap: wrap;
min-height: 8.75rem;
} }
.tz-exam-header-line{ .tz-exam-header-line{
max-width: 1200px; min-width: 75rem;
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 1rem;
height: 20%;
} }
.tz-logo{ .tz-logo{
width: 2rem; width: 2rem;
margin-right: .5rem; margin-right: .5rem;
} }
.tz-exam-left-panel{
width: 30%;
}
.exam-header-title{
display: flex;
min-width: 75rem;
margin-top: 1rem;
justify-content: center;
align-items: center;
background-color: #0264d2;
color: white;
/* height: calc(80% - 2rem); */
border-top-left-radius: 1.5rem;
border-top-right-radius: 1.5rem;
font-weight: bold;
}
.exam-header-title div:nth-child(1){
width: 90%;
}
.exam-button{
background-color: #ff6600;
font-weight: bold;
color: white;
padding: 0.1rem 1rem 0.1rem 1rem;
}
.tz-exam-content{
display: flex;
max-width: 75rem;
margin:auto;
}
.tz-exam-box{
display: flex;
flex-wrap: wrap;
}
.tz-exam-box-title{
width: 60%;
margin:auto;
background-color: #0172e7;
margin-top:2rem;
color: white;
padding: .5rem;
border-radius: 10px 10px 0 0 ;
font-weight: bold;
}
.tz-exam-box-title img{
margin-right: 1rem;
}
.tz-exam-box-title::before{
background-image: url('/static/image/circle.png');
content: "";
width: 2rem;
height: 2rem;
position: absolute;
margin-left: -1.5rem;
background-size: cover;
}
.tz-exam-box-title2{
width: 60%;
margin:auto;
margin-top:2rem;
color: white;
padding: .5rem;
border-radius: 10px 10px 0 0 ;
font-weight: bold;
background-color: #ee4c50;
}
.tz-exam-box-title2::after{
background-image: url('/static/image/icon_answer1_27x27.png');
}
.tz-exam-box-content{
width: 100%;
border-radius: 10px;
background-color: white;
padding: 1rem 0 1rem 0;
border: 1px solid #e0e0e0;
display: flex;
flex-wrap: wrap;
padding: 1rem;
align-items: center;
justify-content: space-around;
}
.tz-exam-box-content span{
background-color: #eaedf6;
display: inline-block;
border-radius: 5px;
color: black;
padding: .5rem;
margin-top: 1rem;
margin-right: .5rem;
}
.tz-exam-box-tips{
text-align: left;
}
.tz-exam-box-tips span{
border-radius: 5px;
padding: .5rem;
display: inline-block;
margin-right: .5rem;
margin-top: 1rem;
}
.done {
background-color: #e1e4ec !important;
color: black !important;
}
.notAnwser{
background-color: #e64d50 !important;
color: white !important;
}
.sign{
background-color: #0260ca !important;
color: white !important;
}
.current{
border: 1px solid black;
}
</style> </style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

@ -12,9 +12,9 @@ public class CompetitionIndexControll {
@Autowired @Autowired
private CompetitionIndexBiz competitionIndexBiz; private CompetitionIndexBiz competitionIndexBiz;
@GetMapping(value = "list/{pageNo}")
public Result<IndexListCompetitionDTO> list(@PathVariable("pageNo") Integer pageNo){
return competitionIndexBiz.list(pageNo);
}
@GetMapping(value = "list/{type}/{pageNo}")
public Result<IndexListCompetitionDTO> list(@PathVariable("type") Integer type,@PathVariable("pageNo") Integer pageNo){
return competitionIndexBiz.list(pageNo,type);
}
} }

@ -1,17 +1,36 @@
package com.tz.platform.competitiion.api.biz; package com.tz.platform.competitiion.api.biz;
import com.tz.platform.common.core.base.Result; import com.tz.platform.common.core.base.Result;
import com.tz.platform.common.core.tools.BeanUtils;
import com.tz.platform.competitiion.api.dto.IndexCompetitionDTO;
import com.tz.platform.competitiion.api.dto.IndexListCompetitionDTO; import com.tz.platform.competitiion.api.dto.IndexListCompetitionDTO;
import com.tz.platform.entity.Competition;
import com.tz.platform.repository.CompetitionDao; import com.tz.platform.repository.CompetitionDao;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
@Component @Component
public class CompetitionIndexBiz { public class CompetitionIndexBiz {
@Autowired @Autowired
private CompetitionDao competitionDao; private CompetitionDao competitionDao;
public Result<IndexListCompetitionDTO> list(int pageNo){ public Result<IndexListCompetitionDTO> list(int pageNo,int type){
return Result.error(""); int pageSize = 20;
if(pageNo<0){
pageNo = 0;
}
pageNo =pageNo* pageSize;
Pageable pageable = PageRequest.of(pageNo,pageSize);
Page<Competition> competitionList = competitionDao.findAllByStatus(type,pageable);
System.out.println(competitionList.getContent());
IndexListCompetitionDTO dto = new IndexListCompetitionDTO();
List<IndexCompetitionDTO> competitionDTOList = BeanUtils.copyProperties(competitionList.getContent(),IndexCompetitionDTO.class);
dto.setList(competitionDTOList);
return Result.success(dto);
} }
} }

@ -1,17 +1,24 @@
package com.tz.platform.competitiion.api.dto; package com.tz.platform.competitiion.api.dto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
@Data @Data
@NoArgsConstructor
@AllArgsConstructor
public class IndexCompetitionDTO implements Serializable { public class IndexCompetitionDTO implements Serializable {
private Integer id; private Integer id;
private String name; private String name;
private String sponsor; private String sponsor;
private String supporter;
private String thumbnail;
private Date startTime; private Date startTime;
private Date endTime; private Date endTime;
private Date sinUpStartTime; private Date sinUpStartTime;
private Date sinUpEndTime; private Date sinUpEndTime;
private Boolean enableSignup;
} }

@ -8,5 +8,4 @@ import java.util.List;
@Data @Data
public class IndexListCompetitionDTO implements Serializable { public class IndexListCompetitionDTO implements Serializable {
private List<IndexCompetitionDTO> list; private List<IndexCompetitionDTO> list;
private Integer total;
} }

@ -3,42 +3,64 @@ package com.tz.platform.competitiion.job;
import com.tz.platform.competitiion.job.biz.CompetitionJobBiz; import com.tz.platform.competitiion.job.biz.CompetitionJobBiz;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisStringCommands;
import org.springframework.data.redis.core.RedisCallback; import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.types.Expiration;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.TimeUnit;
@Component @Component
@Slf4j @Slf4j
public class CompetitionJob { public class CompetitionJob {
@Autowired @Resource
private RedisTemplate<String,Boolean> redisTemplate; private RedisTemplate redisTemplate;
@Autowired @Autowired
private CompetitionJobBiz jobBiz; private CompetitionJobBiz jobBiz;
/**
*
*/
private long ms = 3600000;
/**
*
*/
@Scheduled(cron = "*/60 * * * * ?") @Scheduled(cron = "*/60 * * * * ?")
public void processCompetition(){ public void processCompetition(){
// String jobName = "competitionJob"; String jobName = "competitionJobLock";
// Boolean isWorking = redisTemplate.opsForValue().get(jobName); boolean lr = lock(jobName,ms);
// if(isWorking == null ||isWorking == false){ if(lr){
// redisTemplate.opsForValue().set(jobName,true,10*60, TimeUnit.SECONDS); try {
// System.out.println("competition Job"); jobBiz.updateCompetitionStatus();
// try { }catch (Exception ex){
// jobBiz.updateCompetitionStatus(); log.error("大赛状态更新任务失败: {}",ex.getMessage());
// }catch (Exception ex) { }finally {
// log.error(jobName,ex.getMessage()); unLock(jobName);
// }finally { }
// redisTemplate.opsForValue().set(jobName,false,10*60, TimeUnit.SECONDS); }
// } }
// }
/**
*
*/
// @Scheduled(cron = "*/5 * * * * ?")
public void preHeat(){
String jobName = "competitionPreHeat";
boolean lock = lock(jobName,ms);
if(lock){
try{
jobBiz.preHeat();
}catch (Exception ex){
}finally {
unLock(jobName);
}
}
} }
/** /**
@ -69,4 +91,10 @@ public class CompetitionJob {
return Boolean.FALSE; return Boolean.FALSE;
}); });
} }
public void unLock(String key){
redisTemplate.execute((RedisCallback) redisConnection -> {
redisConnection.del(key.getBytes());
return true;
});
}
} }

@ -1,13 +1,21 @@
package com.tz.platform.competitiion.job.biz; package com.tz.platform.competitiion.job.biz;
import com.tz.platform.common.core.bo.Stage;
import com.tz.platform.entity.Competition; import com.tz.platform.entity.Competition;
import com.tz.platform.entity.CompetitionMember;
import com.tz.platform.entity.CompetitionTask;
import com.tz.platform.feign.exam.IFeignExam;
import com.tz.platform.feign.exam.qo.CacheQuetionQO;
import com.tz.platform.feign.user.IFeignUser;
import com.tz.platform.repository.CompetitionDao; import com.tz.platform.repository.CompetitionDao;
import com.tz.platform.repository.CompetitionMemberDao; import com.tz.platform.repository.CompetitionMemberDao;
import com.tz.platform.repository.CompetitionTaskDao; import com.tz.platform.repository.CompetitionTaskDao;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Component @Component
public class CompetitionJobBiz { public class CompetitionJobBiz {
@ -21,18 +29,91 @@ public class CompetitionJobBiz {
@Autowired @Autowired
private CompetitionMemberDao memberDao; private CompetitionMemberDao memberDao;
@Autowired
private IFeignUser feignUser;
@Autowired
private IFeignExam feignExam;
/** /**
* *
*/ */
public void updateCompetitionStatus(){ public void updateCompetitionStatus(){
List<Competition> competitionList = competitionDao.findAllByStatus(0); List<Competition> competitionList = competitionDao.findAllByStatus(0);
competitionList.forEach(competition -> {
try {
updateCompetitionStatus(competition);
}catch (Exception ex){
}
});
List<Competition> competitionList1 = competitionDao.findAllByStatus(1);
competitionList1.forEach(competition -> {
try {
doneCompetitionStatus(competition);
}catch (Exception ex){
}
});
} }
/** /**
* *
*/ */
public void preHeat(){ public void preHeat(){
List<Competition> competitionList = competitionDao.findAllByStatus(0);
competitionList.forEach(competition -> {
try {
preHeatCompetition(competition);
}catch (Exception ex){
}
});
}
public void preHeatCompetition(Competition competition){
Long now = System.currentTimeMillis();
Stage current = competition.getStageList().stream().filter(stage -> stage.getStartTime().getTime() <= now && stage.getEndTime().getTime() > now).findFirst().orElse(null);
if(current!=null){
List<CompetitionMember> memberList = memberDao.findAllByCompetitionIdAndStageId(competition.getId(),current.getId());
List<Long> userIdList = memberList.stream().mapToLong(CompetitionMember::getUserId).boxed().collect(Collectors.toList());
boolean rs = feignUser.putToCache(userIdList);
CompetitionTask task = taskDao.getByCompetitionIdAndStageId(competition.getId(),current.getId());
List<Long> ids = new ArrayList<>();
task.getQuestionList().forEach(taskQuestion -> {
ids.addAll(taskQuestion.getQuestionIds());
});
long ms = (task.getExamEndTime().getTime() - now)+24*3600*1000;
CacheQuetionQO qo = new CacheQuetionQO();
qo.setIds(ids);
qo.setKey("exam_"+competition.getId()+"_"+current.getId());
qo.setMs(ms);
feignExam.putToCache(qo);
}
}
public void updateCompetitionStatus(Competition competition){
Long now = System.currentTimeMillis();
//进行中
Stage current = competition.getStageList().stream().filter(stage -> stage.getStartTime().getTime() <= now && stage.getEndTime().getTime() > now).findFirst().orElse(null);
if (current != null) {
competition.setCurrentStage(current.getId());
competition.setCurrentStageName(current.getName());
competition.setStatus(1);
competitionDao.updateStatus(competition.getId(),1,current.getName(),current.getId());
}
}
public void doneCompetitionStatus(Competition competition){
Long now = System.currentTimeMillis();
//已完成
long done = competition.getStageList().stream().filter(stage -> stage.getEndTime().getTime()<= now).count();
if(competition.getStageList().size() == done){
competition.setStatus(2);
competitionDao.updateStatus(competition.getId(),2);
}
} }
/** /**

@ -3,10 +3,11 @@ package com.tz.platform.entity;
import lombok.Data; import lombok.Data;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date;
@Entity @Entity
@Data @Data
@Table(indexes={@Index(columnList = "competitionId,stageId,teamId"),@Index(columnList = "studentNo"),@Index(columnList = "name")}) @Table(indexes={@Index(columnList = "competitionId,stageId,teamId"),@Index(columnList = "studentNo"),@Index(columnList = "name"),@Index(columnList = "school")})
public class CompetitionMember { public class CompetitionMember {
@Id @Id
@ -23,8 +24,11 @@ public class CompetitionMember {
private String accountId; private String accountId;
private String accountPwd; private String accountPwd;
private String teacher; private String teacher;
private Long examSore; private Long examScore;
private Long financeSore; private Long financeScore;
private Long combineScore;
private Date examStartTime;
private Date examEndTime;
private Long examCostTime; private Long examCostTime;
private Integer levelId; private Integer levelId;
} }

@ -13,7 +13,7 @@ import java.util.List;
@Entity @Entity
@TypeDef(name = "json", typeClass = JsonStringType.class) @TypeDef(name = "json", typeClass = JsonStringType.class)
@Table(indexes = {@Index(columnList = "userId,competitionId,stageId")}) @Table(indexes = {@Index(columnList = "userId,competitionId,stageId")})
public class ExamAnwser { public class ExamAnswer {
/** /**
* ID_ID_ID_ID_ID * ID_ID_ID_ID_ID
*/ */

@ -15,8 +15,7 @@ import java.util.List;
@TypeDef(name = "json", typeClass = JsonStringType.class) @TypeDef(name = "json", typeClass = JsonStringType.class)
public class ExamQuestion { public class ExamQuestion {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) private String id;
private Long id;
private Long competitionId; private Long competitionId;
private Integer stageId; private Integer stageId;
private Integer groupId; private Integer groupId;

@ -117,14 +117,14 @@ public class JueJinApi {
String zhangSan1GuPiao = ""; String zhangSan1GuPiao = "";
AccountInfo info = api.createAccount("张三1",1000000L,4); // AccountInfo info = api.createAccount("张三1",1000000L,4);
// System.out.println(info.getAccount_id()); // System.out.println(info.getAccount_id());
// api.deleteAccount("4811913f-9dba-11ec-89b3-00163e0e6ad0"); // api.deleteAccount("4811913f-9dba-11ec-89b3-00163e0e6ad0");
// api.getCashInfo("2e41a913-9dc1-11ec-89b3-00163e0e6ad0"); // api.getCashInfo("2e41a913-9dc1-11ec-89b3-00163e0e6ad0");
// api.test(); // api.test();
// api.createReport(accountId,"report"+ System.currentTimeMillis()); // api.createReport(accountId,"report"+ System.currentTimeMillis());
// api.getReport("5"); api.getReport("5");
api.getBaseRatio(); // api.getBaseRatio();
} }
} }

@ -1,6 +1,9 @@
package com.tz.platform.repository; package com.tz.platform.repository;
import com.tz.platform.competitiion.api.dto.IndexCompetitionDTO;
import com.tz.platform.entity.Competition; import com.tz.platform.entity.Competition;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@ -9,6 +12,8 @@ import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional;
@Repository @Repository
public interface CompetitionDao extends JpaRepository<Competition,Long> { public interface CompetitionDao extends JpaRepository<Competition,Long> {
@ -16,8 +21,20 @@ public interface CompetitionDao extends JpaRepository<Competition,Long> {
List<Competition> findAllByStatus(Integer status); List<Competition> findAllByStatus(Integer status);
Page<Competition> findAllByStatus(Integer status, Pageable pageable);
@Transactional @Transactional
@Modifying @Modifying
@Query(value = "update competition set people_count =:pcount,team_count=:tcount where id=:id",nativeQuery = true) @Query(value = "update competition set people_count =:pcount,team_count=:tcount where id=:id",nativeQuery = true)
int updatePeopleCount( @Param("pcount") Integer pcount ,@Param("tcount") Integer tcount , @Param("id") Long id); int updatePeopleCount( @Param("pcount") Integer pcount ,@Param("tcount") Integer tcount , @Param("id") Long id);
@Transactional
@Modifying
@Query(value = "upate cometition set status=:status where id=:compId",nativeQuery = true)
int updateStatus(@Param("compId") Long compId,@Param("status") Integer status);
@Transactional
@Modifying
@Query(value = "upate cometition set status=:status,stage_name=:stageName,stage_id=:stageId where id=:compId",nativeQuery = true)
int updateStatus(@Param("compId") Long compId,@Param("status") Integer status,@Param("stageName") String stageName,@Param("stageId") Integer stageId);
} }

@ -1,5 +1,6 @@
package com.tz.platform.feign.exam; package com.tz.platform.feign.exam;
import com.tz.platform.feign.exam.qo.CacheQuetionQO;
import com.tz.platform.feign.exam.vo.QuestionVo; import com.tz.platform.feign.exam.vo.QuestionVo;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -11,33 +12,8 @@ import java.util.List;
@FeignClient(value = "tz-exam-service") @FeignClient(value = "tz-exam-service")
public interface IFeignExam { public interface IFeignExam {
@GetMapping(value = "/feign/exam/question/{id}")
QuestionVo getQuestionById(@PathVariable(value = "id") Long id);
@GetMapping(value = "/feign/exam/question/list/{pageNo}") @PostMapping(value = "/feign/exam/question/putToCache")
List<QuestionVo> listQuestion(@PathVariable(value = "pageNo") Long pageNo); boolean putToCache(@RequestBody CacheQuetionQO qo);
@PostMapping(value = "/feign/exam/question/update")
int updateQuestion(@RequestBody QuestionVo questionVo);
@PostMapping(value = "/feign/exam/quest/save")
int saveQuestion(@RequestBody QuestionVo questionVo);
@GetMapping(value = "/feign/exam/question/delete/{id}")
int deleteQuestion(@PathVariable( value = "id") Long id);
@PostMapping(value = "/feign/exam/quest/batchInsert")
int batchQuestionInsert(@RequestBody List<QuestionVo> list);
@PostMapping(value = "/feign/exam/question/batchOff")
int batchQuestionOff(@RequestBody List<Integer> ids);
@PostMapping(value = "/feign/exam/question/batchUp")
int batchQuestionUp(@RequestBody List<Integer> ids);
@GetMapping(value = "/feign/exam/question/off/{id}")
int questionOff(@PathVariable(value = "id") Long id);
@GetMapping(value = "/feign/exam/question/up/{id}")
int questionUp(@PathVariable(value = "id") Long id);
} }

@ -32,6 +32,11 @@
<groupId>com.tz</groupId> <groupId>com.tz</groupId>
<artifactId>system-feign</artifactId> <artifactId>system-feign</artifactId>
</dependency> </dependency>
<!--rabbitmq-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!-- test --> <!-- test -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

@ -1,4 +1,17 @@
package com.tz.platform.api; package com.tz.platform.api;
public class ExamApiController { import com.tz.platform.api.dto.ListExamQuestionDTO;
import com.tz.platform.common.core.base.BaseController;
import com.tz.platform.common.core.base.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/api/exam")
public class ExamApiController extends BaseController {
public Result<ListExamQuestionDTO> listExam(){
return Result.error("failed");
}
} }

@ -1,4 +1,23 @@
package com.tz.platform.api.dto; package com.tz.platform.api.dto;
import com.tz.platform.common.core.bo.Answer;
import com.tz.platform.common.core.bo.SubQuestionVO;
import lombok.Data;
import java.util.List;
@Data
public class ExamQuestionDTO { public class ExamQuestionDTO {
private Long id;
private Integer levelId;
private String levelName;
private Integer questionType;
private Long score;
private Integer type;
private String stem;
private String content;
private String stemImg;
private Integer status;
List<Answer> answerList;
private List<SubQuestionVO> children;
} }

@ -1,4 +1,11 @@
package com.tz.platform.api.dto; package com.tz.platform.api.dto;
public class ListExamQuestionDTO { import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class ListExamQuestionDTO implements Serializable {
List<ExamQuestionDTO> list;
} }

@ -1,4 +1,41 @@
package com.tz.platform.config; package com.tz.platform.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class RedisConfig { public class RedisConfig {
@Bean(name = "template")
public RedisTemplate<String, Object> template(RedisConnectionFactory factory) {
// 创建RedisTemplate<String, Object>对象
RedisTemplate<String, Object> template = new RedisTemplate<>();
// 配置连接工厂
template.setConnectionFactory(factory);
// 定义Jackson2JsonRedisSerializer序列化对象
Jackson2JsonRedisSerializer<Object> jacksonSeial = new Jackson2JsonRedisSerializer<>(Object.class);
ObjectMapper om = new ObjectMapper();
// 指定要序列化的域field,get和set,以及修饰符范围ANY是都有包括private和public
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// 指定序列化输入的类型类必须是非final修饰的final修饰的类比如String,Integer等会报异常
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jacksonSeial.setObjectMapper(om);
StringRedisSerializer stringSerial = new StringRedisSerializer();
// redis key 序列化方式使用stringSerial
template.setKeySerializer(stringSerial);
// redis value 序列化方式使用jackson
template.setValueSerializer(jacksonSeial);
// redis hash key 序列化方式使用stringSerial
template.setHashKeySerializer(stringSerial);
// redis hash value 序列化方式使用jackson
template.setHashValueSerializer(jacksonSeial);
template.afterPropertiesSet();
return template;
}
} }

@ -1,4 +1,34 @@
package com.tz.platform.config; package com.tz.platform.config;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class TzRabbitConfig { public class TzRabbitConfig {
@Bean
public Queue examQueue(){
return new Queue("ExamQueue",true);
}
@Bean
DirectExchange examExchange(){
return new DirectExchange("ExamExchange",true,false);
}
@Bean
Binding bindingExam(){
return BindingBuilder.bind(examQueue()).to(examExchange()).with("ExamRouting");
}
@Bean
DirectExchange lonelyExchange(){
return new DirectExchange("lonelyDirectExchange");
}
} }

@ -3,6 +3,7 @@ package com.tz.platform.exam.feign;
import com.tz.platform.common.core.base.BaseController; import com.tz.platform.common.core.base.BaseController;
import com.tz.platform.exam.feign.biz.FeignExamBiz; import com.tz.platform.exam.feign.biz.FeignExamBiz;
import com.tz.platform.feign.exam.IFeignExam; import com.tz.platform.feign.exam.IFeignExam;
import com.tz.platform.feign.exam.qo.CacheQuetionQO;
import com.tz.platform.feign.exam.vo.QuestionVo; import com.tz.platform.feign.exam.vo.QuestionVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -14,53 +15,10 @@ public class FeignExamController extends BaseController implements IFeignExam {
@Autowired @Autowired
private FeignExamBiz feignExamBiz; private FeignExamBiz feignExamBiz;
@Override
public QuestionVo getQuestionById(Long id) {
return null;
}
@Override @Override
public List<QuestionVo> listQuestion(Long pageNo) { public boolean putToCache(CacheQuetionQO qo) {
return null; return feignExamBiz.putToCache(qo.getIds(),qo.getKey(),qo.getMs());
} }
@Override
public int updateQuestion(QuestionVo questionVo) {
return 0;
}
@Override
public int saveQuestion(QuestionVo questionVo) {
return 0;
}
@Override
public int deleteQuestion(Long id) {
return 0;
}
@Override
public int batchQuestionInsert(List<QuestionVo> list) {
return 0;
}
@Override
public int batchQuestionOff(List<Integer> ids) {
return 0;
}
@Override
public int batchQuestionUp(List<Integer> ids) {
return 0;
}
@Override
public int questionOff(Long id) {
return 0;
}
@Override
public int questionUp(Long id) {
return 0;
}
} }

@ -17,7 +17,7 @@ public class FeignExamBiz {
private QuestionDao questionDao; private QuestionDao questionDao;
@Autowired @Autowired
private RedisTemplate<String,List<Question>> redisTemplate; private RedisTemplate<String,Object> redisTemplate;
public boolean putToCache(List<Long> ids,String key,long seconds){ public boolean putToCache(List<Long> ids,String key,long seconds){
try { try {

Loading…
Cancel
Save