docker 文件

sale
tianea 3 years ago
parent 1fbf694f7f
commit 5c86fdc0b8

@ -4,7 +4,7 @@
天择金融模拟交易平台版权所有 备案号87654321 天择金融模拟交易平台版权所有 备案号87654321
</div> </div>
<div class="tz-ma"> <div class="tz-ma">
<b-img class="d-block" src="/static/image/ma.jpg" /> <b-img class="d-block" src="/static/image/ma.png" />
</div> </div>
</div> </div>
</template> </template>
@ -27,4 +27,8 @@
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
.tz-ma>img{
width: 5rem;
height: 5rem;
}
</style> </style>

@ -50,7 +50,6 @@ export default router
router.beforeEach((to,from,next) =>{ router.beforeEach((to,from,next) =>{
let userInfo = getInfo() let userInfo = getInfo()
if(!!userInfo){ if(!!userInfo){
if((!userInfo.complete)&&to.path!='/member'){ if((!userInfo.complete)&&to.path!='/member'){
alert("请完善个人信息!") alert("请完善个人信息!")
next('/member') next('/member')

@ -20,7 +20,7 @@
<div class="tz-sub-tab"> <div class="tz-sub-tab">
<div :class=" rankingId ==1? 'ranking-selected':''" @click="rankingId =1"> <div :class=" rankingId ==1? 'ranking-selected':''" @click="rankingId =1">
<b-img src="/static/image/icon_ranking_1.png"/> <b-img src="/static/image/icon_ranking_1.png"/>
排行榜 排行榜
</div> </div>
<div :class=" rankingId ==2? 'ranking-selected':''" @click="rankingId =2"> <div :class=" rankingId ==2? 'ranking-selected':''" @click="rankingId =2">
<b-img src="/static/image/icon_ranking_2.png"/> <b-img src="/static/image/icon_ranking_2.png"/>
@ -40,7 +40,7 @@
</div> </div>
<div class="tz-table-container"> <div class="tz-table-container">
<div class="tz-table-filter"> <div class="tz-table-filter">
<span>日期</span><b-datepicker /><span>检索</span><b-input class="tz-filter-input" placeholder="用户名/所属院校" /> <b-button class="tz-table-button">查询</b-button><b-button class="tz-table-button"></b-button> <span>检索</span><b-input class="tz-filter-input" placeholder="用户名/所属院校" /> <b-button class="tz-table-button">查询</b-button><b-button class="tz-table-button"></b-button>
</div> </div>
<div class="table-header"> <div class="table-header">
<div> <div>

@ -86,7 +86,7 @@
</div> </div>
</div> </div>
</b-col> </b-col>
<b-col sm> <b-col v-if="competition.type == 1" sm>
<div class="tz-panel"> <div class="tz-panel">
<div> <div>
<div> <div>
@ -115,7 +115,7 @@
</div> </div>
</div> </div>
</b-col> </b-col>
<b-col sm> <b-col v-if="competition.type == 1" sm>
<div class="tz-panel"> <div class="tz-panel">
<div> <div>
<div class="tz-bg-yellow"> <div class="tz-bg-yellow">
@ -203,6 +203,8 @@ import * as echarts from 'echarts'
import * as competitionApi from '@/api/competition' import * as competitionApi from '@/api/competition'
import { getInfo } from '@/utils/auth' import { getInfo } from '@/utils/auth'
import * as memberApi from '@/api/member' import * as memberApi from '@/api/member'
import * as rankingApi from '@/api/ranking'
export default { export default {
data(){ data(){
return { return {
@ -230,7 +232,7 @@ export default {
this.compId = this.$route.query.id this.compId = this.$route.query.id
} }
this.userInfo = getInfo() this.userInfo = getInfo()
}, },
watch:{ watch:{
competition:function(nv){ competition:function(nv){
@ -243,10 +245,7 @@ export default {
this.stageId = this.competition.stageList[0].id this.stageId = this.competition.stageList[0].id
this.loadData() this.loadData()
} }
this.draw("personalRatio")
this.draw("teamRatio")
this.drawRanking("personalRanking")
this.drawRanking("teamRanking")
}, },
methods:{ methods:{
listPosition(){ listPosition(){
@ -256,6 +255,14 @@ export default {
this.positionList = res.data this.positionList = res.data
} }
}) })
rankingApi.listAll(this.compId,this.stageId ).then(res=>{
if(res.code == 200){
this.draw("personalRatio",res.data.list)
this.draw("teamRatio",res.data.list)
this.drawRanking("personalRanking",res.data.list)
this.drawRanking("teamRanking",res.data.list)
}
})
}, },
getMemberInfo(){ getMemberInfo(){
memberApi.getMemberInfo(this.compId,this.stageId).then(res=>{ memberApi.getMemberInfo(this.compId,this.stageId).then(res=>{
@ -273,6 +280,7 @@ export default {
this.getCurrentStage(id) this.getCurrentStage(id)
this.loadData() this.loadData()
}, },
numberFixed(num){ numberFixed(num){
if(typeof num == 'number'){ if(typeof num == 'number'){
return num.toFixed(3) return num.toFixed(3)
@ -288,18 +296,24 @@ export default {
this.currentStage = stage this.currentStage = stage
} }
}, },
draw(id){ draw(id,rankList){
let base = +new Date(1968, 9, 3); let title = ''
let oneDay = 24 * 3600 * 1000; if(id == 'personalRatio'){
title = "个人收益率";
}else{
title = '团队收益率';
}
let date = []; let date = [];
let data = [Math.random() * 300]; let data = [Math.random() * 300];
let data2 = [Math.random() * 300] let data2 = [Math.random() * 300]
for (let i = 1; i < 20000; i++) { for (let i = 0; i < rankList.length; i++) {
var now = new Date((base += oneDay)); let tmp = rankList[i]
var now = new Date(tmp.updateTime);
date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/')); date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'));
data.push(Math.round((Math.random() - 0.5) * 20 + data[i - 1])); data.push(tmp.pnlRatio);
data2.push(Math.round((Math.random() - 0.5) * 20 + data2[i - 1])); data2.push(tmp.baseRatio);
} }
console.log(date,data,data2)
let option = { let option = {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -332,7 +346,7 @@ export default {
], ],
series: [ series: [
{ {
name: '个人收益率', name: title,
type: 'line', type: 'line',
symbol: 'none', symbol: 'none',
sampling: 'lttb', sampling: 'lttb',
@ -388,21 +402,32 @@ export default {
} }
this.teamCharts.setOption(option) this.teamCharts.setOption(option)
} }
}, },
drawRanking(id){ drawRanking(id,rankList){
let xData = []
let yData = []
for(var i = 0;i<rankList.length;i++){
let tmp = rankList[i]
xData.push(tmp.updateTime)
if(id == 'personalRanking'){
yData.push(tmp.personalRank)
}else{
yData.push(tmp.teamRank)
}
}
let option = { let option = {
xAxis: { xAxis: {
type: 'category', type: 'category',
data: ['2015', '2016', '2017', '2018', '2019', '2020', '2021'] data: xData
}, },
yAxis: { yAxis: {
type: 'value' type: 'value'
}, },
series: [ series: [
{ {
data: [150, 230, 224, 218, 135, 147, 260], data: yData,
type: 'line', type: 'line',
color: '#faa7c1' color: '#faa7c1'
} }

@ -18,8 +18,8 @@ export default {
data(){ data(){
return { return {
user: { user: {
username:'2020096911', username:'',
password:'abc123ddd' password:''
}, },
msg: '' msg: ''
} }
@ -54,12 +54,14 @@ export default {
background-image: url('/static/image/login_bg.jpg'); background-image: url('/static/image/login_bg.jpg');
background-size: cover; background-size: cover;
min-height: 1080px; min-height: 1080px;
} }
.tz-login-container{ .tz-login-container{
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;
height: 100%;
width: 100%;
} }
.tz-login-box{ .tz-login-box{
box-shadow: 0 0 0 5px #7dbffb; box-shadow: 0 0 0 5px #7dbffb;

@ -154,7 +154,7 @@ export default {
saveInfo(){ saveInfo(){
memberApi.saveInfo(this.userInfo).then(res => { memberApi.saveInfo(this.userInfo).then(res => {
if(res.data){ if(res.data){
this.userInfo.compele = true this.userInfo.complete = true
setInfo(this.userInfo) setInfo(this.userInfo)
alert("操作成功") alert("操作成功")
}else{ }else{

@ -247,7 +247,8 @@ export default {
console.log(res) console.log(res)
if(res.code == 200){ if(res.code == 200){
alert("考试得分"+res.data.score) alert("考试得分"+res.data.score)
}else{
alert(res.msg)
} }
}) })
}, },

@ -450,13 +450,7 @@ export default {
}) })
} }
}, },
mounted(){
this.$nextTick(function(){
this.drawRanking()
})
},
updated(){ updated(){
console.log(this.tabId)
if(this.tabId == 0 ){ if(this.tabId == 0 ){
this.$nextTick(()=>{ this.$nextTick(()=>{
this.drawRanking() this.drawRanking()

@ -23,7 +23,7 @@
</springProfile> </springProfile>
<!-- 生产环境 --> <!-- 生产环境 -->
<springProfile name="prod"> <springProfile name="pro">
<appender name="PROD_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="PROD_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${FILE_PATH}/warn</file> <file>${FILE_PATH}/warn</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

@ -1,3 +1,3 @@
pic_path=/Volumes/Lexar/www/pic/ pic_path=/users/root/www/pic/
pic_recourse_url=/pic/ pic_recourse_url=/pic/
initPwd=tz2022 initPwd=tz2022

@ -23,10 +23,10 @@
</dependency> </dependency>
<!-- sentinel --> <!-- sentinel -->
<dependency> <!-- <dependency>-->
<groupId>com.alibaba.cloud</groupId> <!-- <groupId>com.alibaba.cloud</groupId>-->
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> <!-- <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>-->
</dependency> <!-- </dependency>-->
<dependency> <dependency>

@ -0,0 +1,8 @@
FROM daocloud.io/library/java:8-jre-alpine
MAINTAINER tianze
ARG JAVA_OPTS="-Xmx128M"
ENV JAVA_OPTS=$JAVA_OPTS
ARG RUN_ARGS="--spring.profiles.active=dev"
ENV RUN_ARGS=$RUN_ARGS
ADD target/tianze-competition.jar /competition-service.jar
ENTRYPOINT ["sh","-c","java $JAVA_OPTS -jar /competition-service.jar $RUN_ARGS"]

@ -1,10 +1,29 @@
package com.tz.platform.competitiion.api; package com.tz.platform.competitiion.api;
import com.tz.platform.common.core.base.BaseController;
import com.tz.platform.common.core.base.Result;
import com.tz.platform.competitiion.api.biz.ApiRankingBiz;
import com.tz.platform.competitiion.api.dto.ListRankingDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping(value = "/api/competition/ranking") @RequestMapping(value = "/api/competition/ranking")
public class ApiCompetitionRankingController { public class ApiCompetitionRankingController extends BaseController {
@Autowired
private ApiRankingBiz rankingBiz;
@GetMapping(value = "list")
public Result<ListRankingDTO> listRank(@RequestParam("compId") Long cmpId, @RequestParam("stageId") Integer stageId,@RequestParam("orderBy") String sort,@RequestParam("direct") Integer direct,String date){
return rankingBiz.list(cmpId,stageId,sort,direct,date);
}
@GetMapping(value = "listAll")
public Result<ListRankingDTO> listAll(@RequestParam("compId") Long cmpId, @RequestParam("stageId") Integer stageId){
return rankingBiz.listAll(cmpId,stageId,getUserNo());
}
} }

@ -0,0 +1,99 @@
package com.tz.platform.competitiion.api.biz;
import com.tz.platform.common.core.base.Result;
import com.tz.platform.common.core.tools.BeanUtils;
import com.tz.platform.competitiion.api.dto.ListRankingDTO;
import com.tz.platform.competitiion.api.dto.RankingDTO;
import com.tz.platform.entity.Competition;
import com.tz.platform.entity.Ranking;
import com.tz.platform.repository.CompetitionDao;
import com.tz.platform.repository.RankingDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Component
public class ApiRankingBiz
{
@Autowired
private RedisTemplate<String,Object> template;
@Autowired
private CompetitionDao competitionDao;
@Autowired
private RankingDao rankingDao;
public Result<ListRankingDTO> list(Long compId,Integer stageId,String sort,Integer direct,String date){
Competition competition = competitionDao.getById(compId);
String key = "rankList_"+compId+"_"+stageId+"_"+date;
Object rankList = template.opsForValue().get(key);
List<Ranking> rankingList = null;
if(rankList == null){
if(StringUtils.isEmpty(date)){
rankingList = rankingDao.findAllByCompIdAndStageIdAndUpdateTime(compId,stageId,competition.getUpdateRankDate());
}else{
rankingList = rankingDao.findAllByCompIdAndStageIdAndUpdateTime(compId,stageId,date);
}
if(rankingList!=null){
template.opsForValue().set(key,rankingList,30, TimeUnit.MINUTES);
}
}else{
rankingList = (List<Ranking>) rankList;
}
Collections.sort(rankingList, (o1, o2) -> {
if(StringUtils.isEmpty(sort)){
Integer r1 = o1.getPersonalRank();
Integer r2 = o2.getPersonalRank();
if(r1 == null){
r1 = 0;
}
if(r2 == null){
r2 = 0;
}
if(direct == 0){
return r1 - r2;
}else{
return r2 - r1;
}
}
return 0;
});
ListRankingDTO dto = new ListRankingDTO();
List<RankingDTO> rankingDTOList = BeanUtils.copyProperties(rankingList,RankingDTO.class);
dto.setTotal(rankingDTOList.size());
dto.setList(rankingDTOList);
return Result.success(dto);
}
public Result<ListRankingDTO> listAll(Long compId,Integer stageId,Long userNo){
String key = "rankList_"+compId+"_"+stageId+"_"+userNo;
Object rankList = template.opsForValue().get(key);
List<Ranking> rankingList = null;
if(rankList == null){
rankingList = rankingDao.findAllByCompIdAndStageIdAndUserNo(compId,stageId,userNo);
if(rankingList!=null&&rankingList.size()>0){
template.opsForValue().set(key,rankingList,30, TimeUnit.MINUTES);
}
}else{
rankingList = (List<Ranking>) rankList;
}
ListRankingDTO dto = new ListRankingDTO();
List<RankingDTO> rankingDTOList = BeanUtils.copyProperties(rankingList,RankingDTO.class);
dto.setTotal(rankingDTOList.size());
dto.setList(rankingDTOList);
return Result.success(dto);
}
}

@ -2,7 +2,133 @@ package com.tz.platform.competitiion.api.dto;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
@Data @Data
public class RankingDTO { public class RankingDTO implements Serializable {
private String id;
private String accountId;
/**
*
*/
private Double nav;
/**
*
*/
private Double available;
/**
*
*/
private Double marketValue;
/**
*
*/
private Double profitLoss;
/**
*
*/
private Double cumCommission;
/**
*
*/
private Double fpnl;
/**
*
*/
private Double pnlRatio;
/**
*
*/
private Double baseRatio;
/**
*
*/
private Double teamRatio;
/**
*
*/
private Integer personalRank;
/**
*
*/
private Integer teamRank;
/**
*
*/
private Double maxDrawdown;
/**
*
*/
private Double calmarRatio;
/**
*
*/
private Double sharpRatio;
/**
*
*/
private Integer openCount;
/**
*
*/
private Integer closeCount;
/**
*
*/
private Double pnlRatioAnnual;
/**
*
*/
private Double winRatio;
private Long userNo;
private Long compId;
private Integer stageId;
private Integer teamId;
private String name;
private String teamName;
private String school;
private Integer levelId;
private Integer regionId;
/**
*
*/
private Double combineScore;
/**
*
*/
private Double teamCombineScore;
/**
*
*/
private Double financeScore;
/**
*
*/
private String updateTime;
} }

@ -57,8 +57,8 @@ public class CompetitionJob {
/** /**
* 2 * 2
*/ */
@Scheduled(cron = "0 0 2 1 * ?") // @Scheduled(cron = "0 0 2 1 * ?")
// @Scheduled(cron = "10 * * * * ?") @Scheduled(cron = "5 * * * * ?")
public void fetchRanking(){ public void fetchRanking(){
String jobName = "rankingJob"; String jobName = "rankingJob";
boolean lock = lock(jobName,ms); boolean lock = lock(jobName,ms);

@ -103,6 +103,10 @@ public class CompetitionJobBiz {
competition.setCurrentStageName(current.getName()); competition.setCurrentStageName(current.getName());
competition.setStatus(1); competition.setStatus(1);
competitionDao.updateStatus(competition.getId(),1,current.getName(),current.getId()); competitionDao.updateStatus(competition.getId(),1,current.getName(),current.getId());
}else{
if(competition.getEndTime().getTime()<now){
competitionDao.updateStatus(competition.getId(),2,"无赛段",0);
}
} }
} }

@ -1,5 +1,6 @@
package com.tz.platform.competitiion.job.biz; package com.tz.platform.competitiion.job.biz;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.tz.platform.common.core.tools.DateUtil; import com.tz.platform.common.core.tools.DateUtil;
@ -42,6 +43,8 @@ public class RankingBiz {
List<Competition> competitionList = competitionDao.findAllByStatus(1); List<Competition> competitionList = competitionDao.findAllByStatus(1);
String endTime = DateUtil.format(new Date()); String endTime = DateUtil.format(new Date());
String now = DateUtil.format(new Date()); String now = DateUtil.format(new Date());
Map<String,Integer> reportMap = listReport(jueJinApi);
competitionList.forEach(competition -> { competitionList.forEach(competition -> {
try { try {
CompetitionTask currentTask = taskDao.getByCompetitionIdAndStageId(competition.getId(), competition.getCurrentStage()); CompetitionTask currentTask = taskDao.getByCompetitionIdAndStageId(competition.getId(), competition.getCurrentStage());
@ -51,49 +54,44 @@ public class RankingBiz {
List<Ranking> rankingList = new ArrayList<>(); List<Ranking> rankingList = new ArrayList<>();
memberList.forEach(member -> { memberList.forEach(member -> {
if (StringUtils.hasText(member.getAccountId())) { if (StringUtils.hasText(member.getAccountId())) {
String jsonStr = jueJinApi.createReport(member.getAccountId(), endTime); if(reportMap.containsKey(member.getAccountId())){
if(StringUtils.isEmpty(jsonStr)){ Integer reportId =reportMap.get(member.getAccountId());
return;
}
JSONObject jsonObject = JSONUtil.parseObj(jsonStr);
if(jsonObject.containsKey("report_id")){
Integer reportId =jsonObject.getInt("report_id");
// memberDao.updateReportId(member.getUserId(),currentTask.getStageId(),currentTask.getCompetitionId(),reportId); // memberDao.updateReportId(member.getUserId(),currentTask.getStageId(),currentTask.getCompetitionId(),reportId);
member.setReportId(reportId); member.setReportId(reportId);
String contentStr = jueJinApi.getReport(reportId.toString()); String contentStr = jueJinApi.getReport(reportId.toString());
JSONObject rankingObj = JSONUtil.parseObj(contentStr); JSONObject rankingObj = JSONUtil.parseObj(contentStr);
if(rankingObj.containsKey("data")){ if(rankingObj.containsKey("data")){
JSONObject dataObj = (JSONObject)rankingObj.getJSONArray("data").get(0); JSONObject dataObj = (JSONObject)rankingObj.getJSONArray("data").get(0);
JSONObject cashObj =dataObj.getJSONObject("cash"); JSONObject cashObj =dataObj.getJSONObject("cash");
if(cashObj.size() == 0 ) {return;}
//可用资金 //可用资金
Double available = cashObj.getDouble("available"); Double available = getOV(cashObj,"available",member.getAvailableFounds()); // cashObj.getDouble("available");
//累计手续费 //累计手续费
Double cumCommission = cashObj.getDouble("cum_commission"); Double cumCommission = getOV(cashObj,"cum_commission",member.getCommission()); //cashObj.getDouble("cum_commission");
//浮动盈亏 //浮动盈亏
Double fpnl = cashObj.getDouble("fpnl"); Double fpnl = getOV(cashObj,"fpnl",0D);//cashObj.getDouble("fpnl");
//收益 //收益
Double pnl = cashObj.getDouble("pnl"); Double pnl =getOV(cashObj,"pnl",0D); // cashObj.getDouble("pnl");
//总资产 //总资产
Double nav = cashObj.getDouble("nav"); Double nav =getOV(cashObj,"nav",member.getTotalFounds()) ;// cashObj.getDouble("nav");
JSONObject indicatorObj = dataObj.getJSONObject("indicator"); JSONObject indicatorObj = dataObj.getJSONObject("indicator");
//累计收益率 //累计收益率
Double pnlRatio = indicatorObj.getDouble("pnl_ratio"); Double pnlRatio = getOV(indicatorObj,"pnl_ratio",0D); //indicatorObj.getDouble("pnl_ratio");
//年化收益率 //年化收益率
Double pnlRatioAnnual = indicatorObj.getDouble("pnl_ratio_annual"); Double pnlRatioAnnual = getOV(indicatorObj,"pnl_ratio_annual",0D); //indicatorObj.getDouble("pnl_ratio_annual");
//夏普比例 //夏普比例
Double sharpRatio = indicatorObj.getDouble("sharp_ratio"); Double sharpRatio =getOV(indicatorObj,"sharp_ratio",0D); //indicatorObj.getDouble("sharp_ratio");
//卡玛比例 //卡玛比例
Double calmarRatio = indicatorObj.getDouble("calmar_ratio"); Double calmarRatio =getOV(indicatorObj,"calmar_ratio",0D); //indicatorObj.getDouble("calmar_ratio");
//最大回测 //最大回测
Double maxDrawdown = indicatorObj.getDouble("max_drawdown"); Double maxDrawdown = getOV(indicatorObj,"max_drawdown",0D); //indicatorObj.getDouble("max_drawdown");
//开仓次数 //开仓次数
Integer openCount = indicatorObj.getInt("open_count"); Integer openCount = getOV(indicatorObj,"open_count",member.getOpenCount()); //indicatorObj.getInt("open_count");
//平仓次数 //平仓次数
Integer closeCount = indicatorObj.getInt("close_count"); Integer closeCount = getOV(indicatorObj,"close_count",member.getCloseCount()); //indicatorObj.getInt("close_count");
//胜率 //胜率
Double winRatio = indicatorObj.getDouble("win_ratio"); Double winRatio = getOV(indicatorObj,"win_ratio",0D); //indicatorObj.getDouble("win_ratio");
if(member.getHighestRatio() == null){ if(member.getHighestRatio() == null){
member.setHighestRatio(pnlRatio); member.setHighestRatio(pnlRatio);
} }
@ -103,7 +101,7 @@ public class RankingBiz {
member.setHighestRatio(maxRatio); member.setHighestRatio(maxRatio);
} }
Ranking ranking = new Ranking(); Ranking ranking = new Ranking();
ranking.setUserNo(member.getId().longValue()); ranking.setUserNo(member.getUserId());
ranking.setCompId(competition.getId()); ranking.setCompId(competition.getId());
ranking.setName(member.getName()); ranking.setName(member.getName());
ranking.setSchool(member.getSchool()); ranking.setSchool(member.getSchool());
@ -168,13 +166,44 @@ public class RankingBiz {
}); });
} }
public Map<String,Integer> listReport(JueJinApi jueJinApi){
Map<String,Integer> reportMap = new HashMap<>();
for(int i = 1;i<10000; i++){
String content = jueJinApi.listReport(i,100);
JSONObject resObj = JSONUtil.parseObj(content);
if(resObj.containsKey("data")){
JSONArray jsonArray = resObj.getJSONArray("data");
jsonArray.forEach(jObj ->{
JSONObject reportObj = (JSONObject) jObj;
String key = reportObj.getStr("account_id");
Integer value = reportObj.getJSONObject("report").getInt("report_id");
reportMap.put(key,value);
});
}else{
break;
}
}
return reportMap;
}
private <T> T getOV(JSONObject jsonObject,String key,T dv){
if(jsonObject.containsKey(key)){
Object v = jsonObject.get(key);
T rs = (T)v;
return rs;
}
return dv;
}
/** /**
* *
* @param rankingList * @param rankingList
* @param task * @param task
*/ */
private void computeRanking(List<Ranking> rankingList ,CompetitionTask task){ private void computeRanking(List<Ranking> rankingList ,CompetitionTask task){
Map<Integer,List<Ranking>> map = rankingList.stream().collect(Collectors.groupingBy(Ranking::getTeamId)); Map<Integer,List<Ranking>> map = rankingList.stream().collect(Collectors.groupingBy(Ranking::getTeamId));
map.forEach((k,v)->{ map.forEach((k,v)->{
Double teamRatio = v.stream().mapToDouble((r)-> { Double teamRatio = v.stream().mapToDouble((r)-> {
Double t = r.getProfitLoss(); Double t = r.getProfitLoss();
@ -195,16 +224,22 @@ public class RankingBiz {
v.forEach(ranking -> { v.forEach(ranking -> {
ranking.setTeamRatio(teamRatio); ranking.setTeamRatio(teamRatio);
ranking.setTeamCombineScore(teamCombineScore); ranking.setTeamCombineScore(teamCombineScore);
}); });
}); });
rankingList.sort(Comparator.comparing(Ranking::getFinanceScore)); rankingList.sort(Comparator.comparing(Ranking::getFinanceScore));
for(int i = 0;i<rankingList.size();i++){ for(int i = 0;i<rankingList.size();i++){
rankingList.get(i).setPersonalRank(i+1); int rank = i + 1;
Ranking ranking = rankingList.get(i);
ranking.setPersonalRank(rank);
memberDao.updatePersonalRank(ranking.getUserNo(),ranking.getStageId(),ranking.getCompId(),rank);
} }
rankingList.sort(Comparator.comparing(Ranking::getTeamCombineScore)); rankingList.sort(Comparator.comparing(Ranking::getTeamCombineScore));
for(int i =0;i<rankingList.size();i++){ for(int i =0;i<rankingList.size();i++){
rankingList.get(i).setTeamRank(i+1); int rank = i + 1;
Ranking ranking = rankingList.get(i);
ranking.setTeamRank(rank);
memberDao.updateTeamRank(ranking.getUserNo(),ranking.getStageId(),ranking.getCompId(),rank);
} }
rankingDao.saveAll(rankingList); rankingDao.saveAll(rankingList);
} }
@ -233,5 +268,4 @@ public class RankingBiz {
double score = task.getFinanceBasePower() +(userRatio - baseRatio) /(maxUserRatio -baseRatio)* task.getFinanceProfitPower(); double score = task.getFinanceBasePower() +(userRatio - baseRatio) /(maxUserRatio -baseRatio)* task.getFinanceProfitPower();
return score; return score;
} }
} }

@ -44,4 +44,9 @@ public class CompetitionController {
return biz.get(vo); return biz.get(vo);
} }
@PostMapping(value = "send")
public Result<String> changeStatus(@RequestBody CompetitionVO vo){
return biz.send(vo);
}
} }

@ -97,10 +97,28 @@ public class PCCompetitionBiz {
return Result.success(dto); return Result.success(dto);
} }
public Result<CompetitionDTO> get(@RequestBody CompetitionVO vo){ public Result<CompetitionDTO> get(CompetitionVO vo){
Competition competition = competitionDao.getById(vo.getId()); Competition competition = competitionDao.getById(vo.getId());
CompetitionDTO dto = new CompetitionDTO(); CompetitionDTO dto = new CompetitionDTO();
BeanUtils.copyProperties(competition,dto); BeanUtils.copyProperties(competition,dto);
return Result.success(dto); return Result.success(dto);
} }
public Result<String> send(CompetitionVO vo){
Competition competition = competitionDao.getById(vo.getId());
if(competition == null){
return Result.error("大赛不存在");
}
if(competition.getStatus() == -1){
int rs = competitionDao.updateStatus(vo.getId(),0);
if(rs>0){
return Result.success("发布成功");
}
}else{
return Result.error("大赛已发布");
}
return Result.error("操作失败");
}
} }

@ -31,13 +31,9 @@ public class Competition {
private Integer teamCount; private Integer teamCount;
private String updateRankDate; private String updateRankDate;
private boolean enableSignup; private boolean enableSignup;
@Column(columnDefinition = "TIMESTAMP")
private Date startTime; private Date startTime;
@Column(columnDefinition = "TIMESTAMP")
private Date endTime; private Date endTime;
@Column(columnDefinition = "TIMESTAMP")
private Date signupStartTime; private Date signupStartTime;
@Column(columnDefinition = "TIMESTAMP")
private Date signupEndTime; private Date signupEndTime;
@Type(type = "json") @Type(type = "json")
@ -45,7 +41,6 @@ public class Competition {
private List<Stage> stageList; private List<Stage> stageList;
private Integer currentStage; private Integer currentStage;
private String currentStageName; private String currentStageName;
@Column(columnDefinition = "TIMESTAMP")
private Date createTime; private Date createTime;
@Type(type = "json") @Type(type = "json")
@Column(columnDefinition = "json") @Column(columnDefinition = "json")

@ -98,6 +98,12 @@ public class JueJinApi {
return content; return content;
} }
public String listReport(Integer pageNo,Integer pageSize){
String url = baseUrl +"/api/v1/reports?page="+pageNo+"&size="+pageSize;
String content = HttpUtil.get(url,headers);
return content;
}
/** /**
* *
* @return * @return
@ -190,7 +196,6 @@ public class JueJinApi {
public static void main(String[] args) { public static void main(String[] args) {
JueJinApi api = new JueJinApi(); JueJinApi api = new JueJinApi();
String accountId = "2e41a913-9dc1-11ec-89b3-00163e0e6ad0"; String accountId = "2e41a913-9dc1-11ec-89b3-00163e0e6ad0";
String zhangSan1Qihuo = "0cfc7894-9f4e-11ec-bf20-00163e0e6ad0"; String zhangSan1Qihuo = "0cfc7894-9f4e-11ec-bf20-00163e0e6ad0";
String zhangSan1GuPiao = ""; String zhangSan1GuPiao = "";
String start = "2022-03-07"; String start = "2022-03-07";
@ -201,9 +206,9 @@ public class JueJinApi {
// 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.getCashInfo(accountId); // api.getCashInfo(accountId);
api.getReport("2794345"); api.getReport("14892159");
// api.getStockInfo("SHSE.600547,SHSE.603160"); // api.getStockInfo("SHSE.600547,SHSE.603160");
// api.getProfit("2022-03-11","2022-03-15"); // api.getProfit("2022-03-11","2022-03-15");
// api.getHeavy(accountId,start,end); // api.getHeavy(accountId,start,end);

@ -53,4 +53,13 @@ public interface CompetitionMemberDao extends JpaRepository<CompetitionMember,In
@Query(value = "update competition_member set highest_ratio=:ratio where user_id=:userNo and stage_id=:stageId and competition_id=:compId",nativeQuery = true) @Query(value = "update competition_member set highest_ratio=:ratio where user_id=:userNo and stage_id=:stageId and competition_id=:compId",nativeQuery = true)
int updateHighestRatio(@Param("userNo") Long userNo,@Param("stageId") Integer stageId,@Param("compId") Long comId, @Param("ratio") Double ratio); int updateHighestRatio(@Param("userNo") Long userNo,@Param("stageId") Integer stageId,@Param("compId") Long comId, @Param("ratio") Double ratio);
@Modifying
@Query(value = "update competition_member set personal_rank=:rank where user_id=:userNo and stage_id=:stageId and competition_id=:compId",nativeQuery = true)
int updatePersonalRank(@Param("userNo") Long userNo,@Param("stageId") Integer stageId,@Param("compId") Long comId, @Param("rank") Integer rank);
@Modifying
@Query(value = "update competition_member set team_rank=:rank where user_id=:userNo and stage_id=:stageId and competition_id=:compId",nativeQuery = true)
int updateTeamRank(@Param("userNo") Long userNo,@Param("stageId") Integer stageId,@Param("compId") Long comId, @Param("rank") Integer rank);
} }

@ -9,4 +9,5 @@ import java.util.List;
@Repository @Repository
public interface RankingDao extends JpaRepository<Ranking,String> { public interface RankingDao extends JpaRepository<Ranking,String> {
List<Ranking> findAllByCompIdAndStageIdAndUpdateTime(Long compId,Integer stageId,String updateTime); List<Ranking> findAllByCompIdAndStageIdAndUpdateTime(Long compId,Integer stageId,String updateTime);
List<Ranking> findAllByCompIdAndStageIdAndUserNo(Long compId,Integer stageId,Long userNo);
} }

@ -10,7 +10,7 @@ spring:
active: dev active: dev
cloud: cloud:
nacos: nacos:
server-addr: 127.0.0.1:8848 server-addr: 172.19.255.105:8848
username: nacos username: nacos
password: nacos password: nacos
config: config:

@ -14,7 +14,15 @@
<modules> <modules>
<module>competition-service</module> <module>competition-service</module>
</modules> </modules>
<build>
<finalName>tianze-competition</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

@ -0,0 +1,96 @@
version: "3.0"
services:
tianze-upload:
build:
context: ./upload/upload-service
args:
JAVA_OPTS: '-Xmn256M -Xmx1024M'
RUN_ARGS: '--spring.profiles.active=pro --spring.cloud.nacos.server-addr=172.19.255.105:8848'
image: alient/tianze:upload
container_name: upload
restart: always
volumes:
- /tmp/logs/upload:/root/tianze/logs/upload
- /root/tianze/www/pic/:/users/root/www/pic/
networks:
- tianze
ports:
- "50015:50015"
tianze-user:
build:
context: ./user/user-service
args:
JAVA_OPTS: '-Xmn256M -Xmx1024M'
RUN_ARGS: '--spring.profiles.active=pro --spring.cloud.nacos.server-addr=172.19.255.105:8848'
image: alient/tianze:user
container_name: user
restart: always
volumes:
- /tmp/logs/user:/root/tianze/logs/user
networks:
- tianze
ports:
- "50011:50011"
tianze-system:
build:
context: ./system/system-service
args:
JAVA_OPTS: '-Xmn256M -Xmx1024M'
RUN_ARGS: '--spring.profiles.active=pro --spring.cloud.nacos.server-addr=172.19.255.105:8848'
image: alient/tianze:system
container_name: system
restart: always
volumes:
- /tmp/logs/system:/root/tianze/logs/system
networks:
- tianze
ports:
- "50014:50014"
tianze-gateway:
build:
context: ./gateway
args:
JAVA_OPTS: '-Xmn256M -Xmx1024M'
RUN_ARGS: '--spring.profiles.active=pro --spring.cloud.nacos.server-addr=172.19.255.105:8848'
image: alient/tianze:gateway
container_name: gateway
restart: always
volumes:
- /tmp/logs/gateway:/root/tianze/logs/gateway
networks:
- tianze
ports:
- "50010:50010"
tianze-exam:
build:
context: ./exam/exam-service
args:
JAVA_OPTS: '-Xmn256M -Xmx1024M'
RUN_ARGS: '--spring.profiles.active=pro --spring.cloud.nacos.server-addr=172.19.255.105:8848'
image: alient/tianze:exam
container_name: exam
restart: always
volumes:
- /tmp/logs/exam:/root/tianze/logs/exam
networks:
- tianze
ports:
- "50013:50013"
tianze-competition:
build:
context: ./competition/competition-service
args:
JAVA_OPTS: '-Xmn256M -Xmx1024M'
RUN_ARGS: '--spring.profiles.active=pro --spring.cloud.nacos.server-addr=172.19.255.105:8848'
image: alient/tianze:competition
container_name: competition
restart: always
volumes:
- /tmp/logs/competition:/root/tianze/logs/competition
networks:
- tianze
ports:
- "50012:50012"
networks:
tianze:
driver: bridge

@ -0,0 +1,8 @@
FROM daocloud.io/library/java:8-jre-alpine
MAINTAINER tianze
ARG JAVA_OPTS="-Xmx128M"
ENV JAVA_OPTS=$JAVA_OPTS
ARG RUN_ARGS="--spring.profiles.active=dev"
ENV RUN_ARGS=$RUN_ARGS
ADD target/tianze-exam.jar /exam-service.jar
ENTRYPOINT ["sh","-c","java $JAVA_OPTS -jar /exam-service.jar $RUN_ARGS"]

@ -45,4 +45,14 @@
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<finalName>tianze-exam</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> </project>

@ -23,11 +23,6 @@ spring:
redis: redis:
repositories: repositories:
enabled: false enabled: false
devtools:
restart:
enabled: true
livereload:
port: 35736
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
logging: logging:

@ -0,0 +1,8 @@
FROM daocloud.io/library/java:8-jre-alpine
MAINTAINER tianze
ARG JAVA_OPTS="-Xmn256M -Xmx1024M"
ENV JAVA_OPTS=$JAVA_OPTS
ARG RUN_ARGS="--spring.profiles.active=pro --spring.cloud.nacos.server-addr=172.19.255.105:8848"
ENV RUN_ARGS=$RUN_ARGS
ADD target/tianze-gateway.jar /gateway-service.jar
ENTRYPOINT ["sh","-c","java $JAVA_OPTS -jar /gateway-service.jar $RUN_ARGS"]

@ -29,10 +29,10 @@
</dependency> </dependency>
<!-- sentinel --> <!-- sentinel -->
<dependency> <!-- <dependency>-->
<groupId>com.alibaba.cloud</groupId> <!-- <groupId>com.alibaba.cloud</groupId>-->
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> <!-- <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>-->
</dependency> <!-- </dependency>-->
<dependency> <dependency>
<groupId>com.alibaba.csp</groupId> <groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-spring-cloud-gateway-adapter</artifactId> <artifactId>sentinel-spring-cloud-gateway-adapter</artifactId>
@ -64,18 +64,12 @@
</dependencies> </dependencies>
<build> <build>
<finalName>app-gateway</finalName> <finalName>tianze-gateway</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> </plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

@ -124,15 +124,11 @@
<!-- </plugin>--> <!-- </plugin>-->
<!-- https://github.com/spotify/dockerfile-maven --> <!-- https://github.com/spotify/dockerfile-maven -->
<!-- <plugin>--> <plugin>
<!-- <groupId>com.spotify</groupId>--> <groupId>com.spotify</groupId>
<!-- <artifactId>dockerfile-maven-plugin</artifactId>--> <artifactId>dockerfile-maven-plugin</artifactId>
<!-- <version>1.4.13</version>--> <version>1.4.13</version>
<!-- <configuration>--> </plugin>
<!-- <repository>harbor.roncoo.com/library/${project.artifactId}</repository>-->
<!-- <tag>${project.version}</tag>-->
<!-- </configuration>-->
<!-- </plugin>-->
</plugins> </plugins>
</pluginManagement> </pluginManagement>
</build> </build>

@ -0,0 +1,8 @@
FROM daocloud.io/library/java:8-jre-alpine
MAINTAINER tianze
ARG JAVA_OPTS="-Xmx128M"
ENV JAVA_OPTS=$JAVA_OPTS
ARG RUN_ARGS="--spring.profiles.active=dev"
ENV RUN_ARGS=$RUN_ARGS
ADD target/tianze-system.jar /system-service.jar
ENTRYPOINT ["sh","-c","java $JAVA_OPTS -jar /system-service.jar $RUN_ARGS"]

@ -39,4 +39,13 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<finalName>tianze-system</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> </project>

@ -0,0 +1,17 @@
package com.tz.platform.system.api;
import com.tz.platform.common.core.base.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/system")
public class SystemController {
@GetMapping(value = "init")
public Result<String> init(){
return Result.success("success");
}
}

@ -0,0 +1,18 @@
package com.tz.platform.system.api.biz;
import com.tz.platform.common.core.base.Result;
import com.tz.platform.feign.user.IFeignUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class SystemBiz {
@Autowired
private IFeignUser feignUser;
public Result<String> initSystem(){
return Result.success("success");
}
}

@ -0,0 +1,8 @@
FROM daocloud.io/library/java:8-jre-alpine
MAINTAINER tianze
ARG JAVA_OPTS="-Xmx128M"
ENV JAVA_OPTS=$JAVA_OPTS
ARG RUN_ARGS="--spring.profiles.active=dev"
ENV RUN_ARGS=$RUN_ARGS
ADD target/tianze-upload.jar /upload-service.jar
ENTRYPOINT ["sh","-c","java $JAVA_OPTS -jar /upload-service.jar $RUN_ARGS"]

@ -22,4 +22,15 @@
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<finalName>tianze-upload</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> </project>

@ -0,0 +1,8 @@
FROM daocloud.io/library/java:8-jre-alpine
MAINTAINER tianze
ARG JAVA_OPTS="-Xmx128M"
ENV JAVA_OPTS=$JAVA_OPTS
ARG RUN_ARGS="--spring.profiles.active=pro --spring.cloud.nacos.server-addr=172.19.255.105:8848"
ENV RUN_ARGS=$RUN_ARGS
ADD target/tianze-user.jar /user-service.jar
ENTRYPOINT ["sh","-c","java $JAVA_OPTS -jar /user-service.jar $RUN_ARGS"]

@ -38,4 +38,14 @@
</dependencies> </dependencies>
<build>
<finalName>tianze-user</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> </project>

@ -2,9 +2,12 @@ package com.tz.platform.user.api;
import com.tz.platform.common.core.base.BaseController; import com.tz.platform.common.core.base.BaseController;
import com.tz.platform.common.core.base.Result; import com.tz.platform.common.core.base.Result;
import com.tz.platform.feign.user.vo.UserVo;
import com.tz.platform.user.api.biz.ApiUserLoginBiz; import com.tz.platform.user.api.biz.ApiUserLoginBiz;
import com.tz.platform.user.api.bo.UserLoginPasswordBO; import com.tz.platform.user.api.bo.UserLoginPasswordBO;
import com.tz.platform.user.api.dto.UserLoginDTO; import com.tz.platform.user.api.dto.UserLoginDTO;
import com.tz.platform.user.pc.biz.PcUserInfoBiz;
import com.tz.platform.user.pc.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -15,6 +18,7 @@ public class UserLoginController extends BaseController {
@Autowired @Autowired
private ApiUserLoginBiz apiUserLoginBiz; private ApiUserLoginBiz apiUserLoginBiz;
@PostMapping(path = "password") @PostMapping(path = "password")
public Result<UserLoginDTO> loginPassword(@RequestBody UserLoginPasswordBO userLoginPasswordBO){ public Result<UserLoginDTO> loginPassword(@RequestBody UserLoginPasswordBO userLoginPasswordBO){
return apiUserLoginBiz.loginPassword(userLoginPasswordBO); return apiUserLoginBiz.loginPassword(userLoginPasswordBO);
@ -24,4 +28,9 @@ public class UserLoginController extends BaseController {
public Result<String> loginOut(){ public Result<String> loginOut(){
return apiUserLoginBiz.loginOut(getUserNo()); return apiUserLoginBiz.loginOut(getUserNo());
} }
@GetMapping(path = "default")
public Result<String> addDefaultUser(){
return apiUserLoginBiz.addDefaultAdmin();
}
} }

@ -2,9 +2,12 @@ package com.tz.platform.user.api.biz;
import cn.hutool.crypto.digest.DigestUtil; import cn.hutool.crypto.digest.DigestUtil;
import com.tz.platform.common.core.base.Result; import com.tz.platform.common.core.base.Result;
import com.tz.platform.common.core.config.SystemUtil;
import com.tz.platform.common.core.enmus.LoginStatusEnum; import com.tz.platform.common.core.enmus.LoginStatusEnum;
import com.tz.platform.common.core.enmus.UserTypeEnum;
import com.tz.platform.common.core.tools.DateUtil; import com.tz.platform.common.core.tools.DateUtil;
import com.tz.platform.common.core.tools.JWTUtil; import com.tz.platform.common.core.tools.JWTUtil;
import com.tz.platform.common.core.tools.StrUtil;
import com.tz.platform.entity.LoginLog; import com.tz.platform.entity.LoginLog;
import com.tz.platform.entity.User; import com.tz.platform.entity.User;
import com.tz.platform.repository.LoginLogDao; import com.tz.platform.repository.LoginLogDao;
@ -112,4 +115,19 @@ public class ApiUserLoginBiz {
loginLogDao.updateLoginOut(userNo); loginLogDao.updateLoginOut(userNo);
return Result.success("success"); return Result.success("success");
} }
public Result<String> addDefaultAdmin(){
User user = new User();
user.setId(1L);
user.setName("管理员");
user.setUsername("admin");
user.setGmtCreate(new Date());
user.setMobileSalt(StrUtil.get32UUID());
user.setMobilePsw(DigestUtil.sha1Hex(user.getMobileSalt() +SystemUtil.INIT_PASSWORD));
user.setGmtModified(new Date());
user.setUserType(UserTypeEnum.ADMIN.getCode());
userDao.save(user);
return Result.success("success");
}
} }

@ -30,9 +30,9 @@ public class AuthUserInfoBiz {
} }
public Result<Boolean> complete(EditUserVO vo){ public Result<Boolean> complete(EditUserVO vo){
if(StringUtils.isEmpty(vo.getEmail())){ // if(StringUtils.isEmpty(vo.getEmail())){
return Result.error("邮箱不能为空"); // return Result.error("邮箱不能为空");
} // }
if(StringUtils.isEmpty(vo.getMobile())){ if(StringUtils.isEmpty(vo.getMobile())){
return Result.error("手机不能为空"); return Result.error("手机不能为空");
} }

@ -1,7 +1,12 @@
package com.tz.platform.user.chunzhen; package com.tz.platform.user.chunzhen;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.nio.MappedByteBuffer; import java.nio.MappedByteBuffer;
@ -10,8 +15,9 @@ import java.util.ArrayList;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List; import java.util.List;
@Slf4j
public class IPSeeker { public class IPSeeker {
private static final String IP_FILE = IPSeeker.class.getResource("/QQWry.DAT").toString().substring(5);
// 一些固定常量,比如记录长度等等 // 一些固定常量,比如记录长度等等
private static final int IP_RECORD_LENGTH = 7; private static final int IP_RECORD_LENGTH = 7;
@ -43,14 +49,17 @@ public class IPSeeker {
buf = new byte[100]; buf = new byte[100];
b4 = new byte[4]; b4 = new byte[4];
b3 = new byte[3]; b3 = new byte[3];
String IP_FILE = "";
try { try {
ipFile = new RandomAccessFile(IP_FILE, "r"); ClassPathResource resource = new ClassPathResource("QQWry.DAT");
IP_FILE = resource.getPath();
ipFile = new RandomAccessFile(resource.getFile(), "r");
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
System.out.println(IPSeeker.class.getResource("/QQWry.DAT").toString()); log.error("chunzheng file read err:{}",IP_FILE);
System.out.println(IP_FILE);
System.out.println("IP地址信息文件没有找到IP显示功能将无法使用");
ipFile = null; ipFile = null;
} catch (IOException e) {
e.printStackTrace();
} }
// 如果打开文件成功,读取文件头信息 // 如果打开文件成功,读取文件头信息
if(ipFile != null) { if(ipFile != null) {
@ -67,6 +76,14 @@ public class IPSeeker {
} }
} }
} }
private String streamToString(InputStream inputHtml) throws IOException {
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = inputHtml.read(b)) != -1;) {
out.append(new String(b, 0, n));
}
return out.toString();
}
/** *//** /** *//**
* @return * @return

@ -46,4 +46,9 @@ public class PcUserInfoController extends BaseController {
public Result<Long> addUser(@RequestBody UserVO vo){ public Result<Long> addUser(@RequestBody UserVO vo){
return pcUserInfoBiz.saveUser(vo); return pcUserInfoBiz.saveUser(vo);
} }
@PostMapping(value = "addAdmin")
public Result<Long> addAdmin(@RequestBody UserVO vo){
return pcUserInfoBiz.addAdmin(vo);
}
} }

@ -6,6 +6,7 @@ import com.tz.platform.common.core.config.SystemUtil;
import com.tz.platform.common.core.enmus.UserTypeEnum; import com.tz.platform.common.core.enmus.UserTypeEnum;
import com.tz.platform.common.core.tools.StrUtil; import com.tz.platform.common.core.tools.StrUtil;
import com.tz.platform.entity.User; import com.tz.platform.entity.User;
import com.tz.platform.feign.user.vo.UserVo;
import com.tz.platform.repository.UserDao; import com.tz.platform.repository.UserDao;
import com.tz.platform.user.pc.bo.UserPageBO; import com.tz.platform.user.pc.bo.UserPageBO;
import com.tz.platform.user.pc.dto.UserDTO; import com.tz.platform.user.pc.dto.UserDTO;
@ -146,6 +147,38 @@ public class PcUserInfoBiz {
return Result.success(user.getId()); return Result.success(user.getId());
} }
public Result<Long> addAdmin(UserVO vo){
if(StringUtils.isEmpty(vo.getUsername())){
return Result.error("用户名不能为空");
}
User creator = userDao.getById(vo.getUserNo());
User user =userDao.getById(vo.getId());
if(vo.getId()== null||user == null){
user = new User();
user.setUsername(vo.getUsername());
user.setGmtCreate(new Date());
}
if(StringUtils.hasText(vo.getPassword())){
user.setMobileSalt(StrUtil.get32UUID());
user.setMobilePsw(DigestUtil.sha1Hex(user.getMobileSalt() +vo.getPassword()));
}else{
user.setMobileSalt(StrUtil.get32UUID());
user.setMobilePsw(DigestUtil.sha1Hex(user.getMobileSalt() + SystemUtil.INIT_PASSWORD));
}
user.setName(vo.getName());
user.setMobile(vo.getMobile());
user.setGmtModified(new Date());
user.setUserType(UserTypeEnum.ADMIN.getCode());
if(user.getUserType().equals(UserTypeEnum.ADMIN.getCode())&&creator.getUserType()!=3){
return Result.error("无权添加用户");
}
user = userDao.save(user);
return Result.success(user.getId());
}
public Result<String> deleteUser(UserVO vo){ public Result<String> deleteUser(UserVO vo){
if(vo.getId()==null){ if(vo.getId()==null){
return Result.error("无该用户信息"); return Result.error("无该用户信息");

@ -8,6 +8,7 @@ public class UserVO {
private Long id; private Long id;
private String studentNo; private String studentNo;
private String password; private String password;
private String username;
private String name; private String name;
private String school; private String school;
private String mobile; private String mobile;

@ -7,7 +7,7 @@ spring:
active: dev active: dev
cloud: cloud:
nacos: nacos:
server-addr: 127.0.0.1:8848 server-addr: 172.19.255.105:8848
username: nacos username: nacos
password: nacos password: nacos
config: config:

Loading…
Cancel
Save