提交 1c1c4ab7 编写于 作者: minghao.wu's avatar minghao.wu

Merge branch 'dev_phase3' into release

......@@ -12,7 +12,7 @@
<groupId>com.pica.cloud.online.exam</groupId>
<artifactId>pica-cloud-analysis-common</artifactId>
<name>pica-cloud-analysis-common</name>
<version>1.0.2</version>
<version>1.0.8</version>
<packaging>jar</packaging>
<properties>
......
......@@ -42,6 +42,11 @@ public class CHCAnalysisDto {
*/
private String rule;
/**
* 是否在范围内 控制显示我的赞 0: 不能解析 1: 我的赞
*/
private Integer isJoinIn;
private List<AnalysisRoundDto> roundList;
public Integer getId() {
......@@ -139,4 +144,12 @@ public class CHCAnalysisDto {
public void setRule(String rule) {
this.rule = rule;
}
public Integer getIsJoinIn() {
return isJoinIn;
}
public void setIsJoinIn(Integer isJoinIn) {
this.isJoinIn = isJoinIn;
}
}
package com.pica.cloud.online.exam.analysis.common.dto;
/**
* @author wuminghao
* @date 2018/9/4 9:19
*/
public class DoctorDto {
private Integer id;
private String name;
private String hospital;
private String title;
private String avatarImageUrl;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getHospital() {
return hospital;
}
public void setHospital(String hospital) {
this.hospital = hospital;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAvatarImageUrl() {
return avatarImageUrl;
}
public void setAvatarImageUrl(String avatarImageUrl) {
this.avatarImageUrl = avatarImageUrl;
}
}
package com.pica.cloud.online.exam.analysis.common.dto;
import java.util.List;
/**
* @author wuminghao
* @date 2018/9/4 9:14
*/
public class MyStarDto {
/**
* 剩余时间
*/
String remainingTime;
/**
* 当前轮的开始时间
*/
String startTime;
/**
* 当前轮的结束时间
*/
String endTime;
/**
* 我的集赞数
*/
Integer myStarCount;
/**
* 活动状态 0: 集赞未结束 1: 集赞已结束
*/
Integer isFinished;
/**
* 当选状态: 0: 未当选 1: 已当选
*/
Integer isElected;
/**
* 医生信息
*/
private DoctorDto doctor;
/**
* 轮列表
*/
private List<AnalysisRoundDto> roundList;
/**
* 解析信息
*/
private List<UserExamTitleDto> myExamTitleList;
public String getRemainingTime() {
return remainingTime;
}
public void setRemainingTime(String remainingTime) {
this.remainingTime = remainingTime;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public Integer getMyStarCount() {
return myStarCount;
}
public void setMyStarCount(Integer myStarCount) {
this.myStarCount = myStarCount;
}
public Integer getIsFinished() {
return isFinished;
}
public void setIsFinished(Integer isFinished) {
this.isFinished = isFinished;
}
public Integer getIsElected() {
return isElected;
}
public void setIsElected(Integer isElected) {
this.isElected = isElected;
}
public DoctorDto getDoctor() {
return doctor;
}
public void setDoctor(DoctorDto doctor) {
this.doctor = doctor;
}
public List<AnalysisRoundDto> getRoundList() {
return roundList;
}
public void setRoundList(List<AnalysisRoundDto> roundList) {
this.roundList = roundList;
}
public List<UserExamTitleDto> getMyExamTitleList() {
return myExamTitleList;
}
public void setMyExamTitleList(List<UserExamTitleDto> myExamTitleList) {
this.myExamTitleList = myExamTitleList;
}
}
package com.pica.cloud.online.exam.analysis.common.dto;
import java.util.List;
/**
* @author wuminghao
* @date 2018/9/4 10:11
*/
public class RoundExamTitleV2Dto {
private Integer analysisId;
private Integer roundId;
private String remainingTime;
private String startTime;
private String endTime;
private Integer totalCount;
private Integer published;
/**
* 本轮是否已结束
*/
private Integer isFinished;
/**
* 当选人的点赞数
*/
private Integer electedStarCount;
/**
* 当选的医生
*/
private DoctorDto electedDoctor;
private List<AnalysisRoundDto> roundList;
private List<ExamTitleDto> examTitleList;
public Integer getAnalysisId() {
return analysisId;
}
public void setAnalysisId(Integer analysisId) {
this.analysisId = analysisId;
}
public Integer getRoundId() {
return roundId;
}
public void setRoundId(Integer roundId) {
this.roundId = roundId;
}
public String getRemainingTime() {
return remainingTime;
}
public void setRemainingTime(String remainingTime) {
this.remainingTime = remainingTime;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public Integer getTotalCount() {
return totalCount;
}
public void setTotalCount(Integer totalCount) {
this.totalCount = totalCount;
}
public Integer getPublished() {
return published;
}
public void setPublished(Integer published) {
this.published = published;
}
public Integer getIsFinished() {
return isFinished;
}
public void setIsFinished(Integer isFinished) {
this.isFinished = isFinished;
}
public Integer getElectedStarCount() {
return electedStarCount;
}
public void setElectedStarCount(Integer electedStarCount) {
this.electedStarCount = electedStarCount;
}
public DoctorDto getElectedDoctor() {
return electedDoctor;
}
public void setElectedDoctor(DoctorDto electedDoctor) {
this.electedDoctor = electedDoctor;
}
public List<AnalysisRoundDto> getRoundList() {
return roundList;
}
public void setRoundList(List<AnalysisRoundDto> roundList) {
this.roundList = roundList;
}
public List<ExamTitleDto> getExamTitleList() {
return examTitleList;
}
public void setExamTitleList(List<ExamTitleDto> examTitleList) {
this.examTitleList = examTitleList;
}
}
package com.pica.cloud.online.exam.analysis.common.dto;
import java.net.Inet4Address;
/**
* @author wuminghao
* @date 2018/9/4 9:30
*/
public class UserExamTitleDto {
/**
* 题目id
*/
Integer examTitleId;
/**
* 题目序号
*/
Integer seqNo;
/**
* 我是否解析: 0: 未解析 1: 已解析
*/
Integer isReplied;
/**
* 获赞数
*/
Integer starCount;
public Integer getExamTitleId() {
return examTitleId;
}
public void setExamTitleId(Integer examTitleId) {
this.examTitleId = examTitleId;
}
public Integer getSeqNo() {
return seqNo;
}
public void setSeqNo(Integer seqNo) {
this.seqNo = seqNo;
}
public Integer getIsReplied() {
return isReplied;
}
public void setIsReplied(Integer isReplied) {
this.isReplied = isReplied;
}
public Integer getStarCount() {
return starCount;
}
public void setStarCount(Integer starCount) {
this.starCount = starCount;
}
}
......@@ -138,7 +138,7 @@
<dependency>
<groupId>com.pica.cloud.online.exam</groupId>
<artifactId>pica-cloud-analysis-common</artifactId>
<version>1.0.2</version>
<version>1.0.8</version>
<scope>compile</scope>
</dependency>
......
package com.pica.cloud.online.exam.analysis.server.controller;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.redis.RedisClient;
import com.pica.cloud.foundation.utils.entity.PICAUser;
import com.pica.cloud.online.exam.analysis.common.CommonUtils;
import com.pica.cloud.online.exam.analysis.common.util.ReturnUtil;
import com.pica.cloud.online.exam.analysis.server.service.AntiSpamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author wuminghao
* @date 2018/9/3 9:35
*/
@RestController
@RequestMapping("/antispam")
@Api(value = "内容甄别解析", description = "检测文本、图片内容")
public class AntiSpamController {
@Autowired
private RedisClient redisClient;
@Autowired
AntiSpamService antiSpamService;
@ApiOperation(value = "回复", response = PicaResponse.class)
@RequestMapping(value = "/", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
public PicaResponse process(@RequestBody String content,
@RequestHeader String sysCode,
@RequestHeader String token) {
if (token == null) {
PicaResponse picaResponse = ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_NO_TOKEN);
picaResponse.setData("");
return picaResponse;
}
PICAUser user = CommonUtils.getUserByToken(redisClient, token);
if (user == null || user.getId().intValue() == 0) {
PicaResponse picaResponse = ReturnUtil.getPicaResponse(PicaResultCode.LOGIN_FAILE);
picaResponse.setData("");
return picaResponse;
}
try {
JSONObject jsonObject = JSONObject.parseObject(content);
content = jsonObject.get("content").toString();
} catch (Exception e) {
System.out.println("parse error: " + content);
return ReturnUtil.getPicaResponse(PicaResultCode.PARAM_IS_INVALID);
}
return antiSpamService.processString(user != null ? user.getId() : 0, sysCode, content);
}
}
package com.pica.cloud.online.exam.analysis.server.entity;
import java.util.Date;
public class AntiSpamRecord {
private Integer id;
private String sysCode;
private String content;
private String result;
private Byte action;
private String label;
private String hint;
private Integer createdId;
private Date createdTime;
private Integer modifiedId;
private Date modifiedTime;
private Boolean isDeleted;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSysCode() {
return sysCode;
}
public void setSysCode(String sysCode) {
this.sysCode = sysCode == null ? null : sysCode.trim();
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content == null ? null : content.trim();
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result == null ? null : result.trim();
}
public Byte getAction() {
return action;
}
public void setAction(Byte action) {
this.action = action;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label == null ? null : label.trim();
}
public String getHint() {
return hint;
}
public void setHint(String hint) {
this.hint = hint == null ? null : hint.trim();
}
public Integer getCreatedId() {
return createdId;
}
public void setCreatedId(Integer createdId) {
this.createdId = createdId;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Integer getModifiedId() {
return modifiedId;
}
public void setModifiedId(Integer modifiedId) {
this.modifiedId = modifiedId;
}
public Date getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
public Boolean getIsDeleted() {
return isDeleted;
}
public void setIsDeleted(Boolean isDeleted) {
this.isDeleted = isDeleted;
}
}
\ No newline at end of file
......@@ -20,4 +20,6 @@ public interface AnalysisRoundMapper {
List<AnalysisRound> selectRoundListById(Integer id);
List<AnalysisRound> selectPSARoundListById(Integer id);
List<AnalysisRound> selectHistoryRoundListById(Integer id);
}
\ No newline at end of file
package com.pica.cloud.online.exam.analysis.server.mapper;
import com.pica.cloud.online.exam.analysis.server.entity.AntiSpamRecord;
public interface AntiSpamRecordMapper {
int deleteByPrimaryKey(Integer id);
int insert(AntiSpamRecord record);
int insertSelective(AntiSpamRecord record);
AntiSpamRecord selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(AntiSpamRecord record);
int updateByPrimaryKey(AntiSpamRecord record);
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.pica.cloud.online.exam.analysis.server.mapper;
import com.pica.cloud.online.exam.analysis.server.entity.Reply;
import java.util.List;
import java.util.Map;
public interface ReplyMapper {
int deleteByPrimaryKey(Integer id);
......@@ -38,4 +39,32 @@ public interface ReplyMapper {
* @return
*/
List<Reply> selectFiveHottestReplyList(Integer analysisRoundExamTitleId);
/**
* 根据话题id获取当选的票数
* @param examTitleIds
* @return
*/
Integer selectElectedStarCountByExamTitleIdList(List<Integer> examTitleIds);
/**
* 根据话题id获取当选的医生id
* @param examTitleIds
* @return
*/
Integer selectElectedDoctorIdByExamTitleIdList(List<Integer> examTitleIds);
/**
* 获取某人某轮的获赞数
* @param param
* @return
*/
Integer selectStarCountByParam(Map param);
/**
* 获取某人某轮的获赞记录
* @param param
* @return
*/
List<Reply> selectStarRecordByParam(Map param);
}
\ No newline at end of file
......@@ -7,9 +7,11 @@ import com.pica.cloud.foundation.entity.PicaResponse;
* @date 2018/8/27 14:38
*/
public interface AntiSpamService {
PicaResponse processString(String content);
PicaResponse processString(Integer userId, String sysCode, String content);
boolean processImageContent(String content);
boolean processImageContent(Integer userId, String sysCode, String content);
boolean processImage(String url);
boolean processImage(Integer userId, String sysCode, String url);
int insertRecord(Integer userId, String sysCode, String content, String result, Byte action, int label, String hint);
}
package com.pica.cloud.online.exam.analysis.server.service;
import com.pica.cloud.online.exam.analysis.common.dto.*;
import com.pica.cloud.online.exam.analysis.server.entity.AnalysisRound;
import com.pica.cloud.online.exam.analysis.server.entity.AnalysisRoundExamTitle;
import com.pica.cloud.online.exam.analysis.server.entity.CHCAnalysis;
import com.pica.cloud.online.exam.analysis.server.entity.Reply;
import org.omg.CORBA.INTERNAL;
import java.util.List;
......@@ -45,7 +47,14 @@ public interface CHCAnalysisService {
* @param roundId
* @return
*/
RoundExamTitleDto getRoundById(Integer roundId);
RoundExamTitleDto getRoundExamTitleDtoById(Integer roundId);
/**
* 根据轮的id获取信息
* @param roundId
* @return
*/
AnalysisRound getRoundInfoById(Integer roundId);
/**
* 根据轮的id获取题目信息
......@@ -156,4 +165,40 @@ public interface CHCAnalysisService {
* @return
*/
List<Reply> getReplyList(Integer examTitleId);
/**
* 获取所有的历史轮详情
* @return
*/
List<AnalysisRoundDto> getCHCHistoryRound();
/**
* 获取某一轮的最多得票数
* @param roundId
* @return
*/
Integer getElectedStarCountByRoundId(Integer roundId);
/**
* 获取被选中的医生id
* @param roundId
* @return
*/
Integer getElectedDoctorIdByRoundId(Integer roundId);
/**
* 根据医生id和轮id获取得赞数
* @param roundId
* @param doctorId
* @return
*/
Integer getStarCountByRoundIdAndDoctorId(Integer roundId, Integer doctorId);
/**
* 根据医生id和轮id获取得赞记录
* @param roundId
* @param doctorId
* @return
*/
List<UserExamTitleDto> getMyStarRecordByRoundIdAndDoctorId(Integer roundId, Integer doctorId);
}
package com.pica.cloud.online.exam.analysis.server.service;
import com.pica.cloud.online.exam.analysis.common.dto.DoctorDto;
import com.pica.cloud.online.exam.analysis.server.entity.Doctor;
/**
......@@ -14,6 +15,12 @@ public interface DoctorService {
*/
Doctor getDoctorById(Integer doctorId);
/**
* 根据医生id获取医生dtp
* @return
*/
DoctorDto getDoctorDtoById(Integer doctorId);
/**
* 根据医生的id获取医生的权限
* @param doctorId
......
......@@ -8,6 +8,8 @@ import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.online.exam.analysis.common.util.ReturnUtil;
import com.pica.cloud.online.exam.analysis.server.configuration.PropertiesConfiguration;
import com.pica.cloud.online.exam.analysis.server.entity.AntiSpamRecord;
import com.pica.cloud.online.exam.analysis.server.mapper.AntiSpamRecordMapper;
import com.pica.cloud.online.exam.analysis.server.service.AntiSpamService;
import com.pica.cloud.online.exam.analysis.server.utils.HttpClient4Utils;
import com.pica.cloud.online.exam.analysis.server.utils.SignatureUtils;
......@@ -29,15 +31,18 @@ public class AntiSpamServiceImpl implements AntiSpamService {
@Autowired
private PropertiesConfiguration properties;
@Autowired
private AntiSpamRecordMapper antiSpamRecordMapper;
private static HttpClient httpClient = HttpClient4Utils.createHttpClient(100, 20, 2000, 2000, 2000);
private static HttpClient httpClientImage = HttpClient4Utils.createHttpClient(100, 20, 10000, 2000, 2000);
@Override
public PicaResponse processString(String content) {
public PicaResponse processString(Integer userId, String sysCode, String content) {
/**
* 过滤图片
*/
if (!processImageContent(content)) {
return ReturnUtil.getPicaResponse("400002", "图片包含违禁内容,请修改后重新输入");
if (!processImageContent(userId, sysCode, content)) {
return ReturnUtil.getPicaResponse("400002", "图片包含违禁内容,请修改后重新输入", "");
}
Map<String, String> params = new HashMap<String, String>();
......@@ -100,7 +105,7 @@ public class AntiSpamServiceImpl implements AntiSpamService {
* action: 2 不通过
*/
if (action == 0) {
insertRecord(userId, sysCode, content, response, (byte)action, 0, "");
} else {
for (JsonElement labelElement : labelArray) {
JsonObject lObject = labelElement.getAsJsonObject();
......@@ -116,7 +121,8 @@ public class AntiSpamServiceImpl implements AntiSpamService {
else if (label == 600) msg = "输入内容包含谩骂词汇,请修改后重新输入";
else if (label == 700) msg = "输入内容包含灌水词汇,请修改后重新输入";
return ReturnUtil.getPicaResponse("400002", msg);
insertRecord(userId, sysCode, content, response, (byte)action, label, detailsObject.getAsString());
return ReturnUtil.getPicaResponse("400002", msg, "");
}
}
......@@ -129,7 +135,7 @@ public class AntiSpamServiceImpl implements AntiSpamService {
}
@Override
public boolean processImageContent(String content) {
public boolean processImageContent(Integer userId, String sysCode, String content) {
List<String> imageUrlList = new ArrayList<>();
/**
......@@ -150,7 +156,7 @@ public class AntiSpamServiceImpl implements AntiSpamService {
/**
* 检测出某张图片失败 则返回
*/
if (!processImage(url)) {
if (!processImage(userId, sysCode, url)) {
return false;
}
}
......@@ -158,7 +164,7 @@ public class AntiSpamServiceImpl implements AntiSpamService {
}
@Override
public boolean processImage(String url) {
public boolean processImage(Integer userId, String sysCode, String url) {
Map<String, String> params = new HashMap<String, String>();
/**
......@@ -226,6 +232,7 @@ public class AntiSpamServiceImpl implements AntiSpamService {
*/
int maxLevel = -1;
double maxRate = 0.0;
int maxLable = 0;
// 产品需根据自身需求,自行解析处理,本示例只是简单判断分类级别
for (JsonElement labelElement : labelArray) {
JsonObject lObject = labelElement.getAsJsonObject();
......@@ -234,18 +241,49 @@ public class AntiSpamServiceImpl implements AntiSpamService {
double rate = lObject.get("rate").getAsDouble();
if (label == 100 || label == 110 || label == 210) {
System.out.println(String.format("label:%s, level=%s, rate=%s", label, level, rate));
maxLevel = level > maxLevel ? level : maxLevel;
if (level > maxLevel) {
maxLevel = level;
maxLable = label;
}
maxRate = rate > maxRate ? rate : maxRate;
}
}
if (maxLevel == 2) {
insertRecord(userId, sysCode, url, response, (byte)maxLevel, maxLable, "");
return false;
}
}
} else {
System.out.println(String.format("ERROR: code=%s, msg=%s", code, msg));
}
/**
* 成功
*/
insertRecord(userId, sysCode, url, response, (byte)0,0, "");
return true;
}
@Override
public int insertRecord(Integer userId, String sysCode, String content, String result, Byte action, int label, String hint) {
AntiSpamRecord antiSpamRecord = new AntiSpamRecord();
antiSpamRecord.setSysCode(sysCode);
antiSpamRecord.setContent(content);
antiSpamRecord.setResult(result);
antiSpamRecord.setAction(action);
StringBuilder sb = new StringBuilder();
sb.append(label);
antiSpamRecord.setLabel(sb.toString());
antiSpamRecord.setHint(hint);
antiSpamRecord.setCreatedId(userId);
antiSpamRecord.setCreatedTime(new Date());
antiSpamRecord.setModifiedId(userId);
antiSpamRecord.setModifiedTime(new Date());
antiSpamRecord.setIsDeleted(false);
return antiSpamRecordMapper.insert(antiSpamRecord);
}
}
......@@ -16,6 +16,10 @@ public class CHCRankingListServiceImpl implements CHCRankingListService {
@Override
public boolean isRankingInTop200(Integer doctorId) {
if (doctorId == 0) {
return false;
}
return rankingListMapper.selectRecordExistTop200(doctorId) > 0;
}
}
package com.pica.cloud.online.exam.analysis.server.service.impl;
import com.pica.cloud.online.exam.analysis.common.dto.DoctorDto;
import com.pica.cloud.online.exam.analysis.server.configuration.PropertiesConfiguration;
import com.pica.cloud.online.exam.analysis.server.entity.Doctor;
import com.pica.cloud.online.exam.analysis.server.mapper.DoctorMapper;
import com.pica.cloud.online.exam.analysis.server.service.DoctorService;
......@@ -15,11 +17,30 @@ public class DoctorServiceImpl implements DoctorService {
@Autowired
DoctorMapper doctorMapper;
@Autowired
private PropertiesConfiguration properties;
@Override
public Doctor getDoctorById(Integer doctorId) {
return doctorMapper.selectByPrimaryKey(doctorId);
}
@Override
public DoctorDto getDoctorDtoById(Integer doctorId) {
Doctor doctor = doctorMapper.selectByPrimaryKey(doctorId);
DoctorDto doctorDto = new DoctorDto();
doctorDto.setId(doctor.getId());
doctorDto.setName(doctor.getName());
doctorDto.setHospital(doctor.getHospital());
doctorDto.setTitle(doctor.getTitle());
doctorDto.setAvatarImageUrl(doctor.getAvatarImageUrl() != null
? properties.getFileUrl() + doctor.getAvatarImageUrl().trim()
: properties.getFileUrl() + "/File/doctor_default.png");
return doctorDto;
}
@Override
public boolean isAuth(Integer doctorId) {
return doctorMapper.selectAuthByDoctorId(doctorId) > 0 ||
......
package com.pica.cloud.online.exam.analysis.server.utils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @author wuminghao
* @date 2018/9/1 10:54
*/
public class DateUtils {
private static final long ONE_MINITE = 60;
private static final long ONE_HOUR = 3600;
private static final long ONE_DAY = 86400;
private static final long THREE_DAY = 259200;
public static Calendar calendar = Calendar.getInstance();
public static String fromNow(Date date) {
calendar.setTime(date);
long time = date.getTime() / 1000;
long now = (new Date()).getTime() / 1000;
long interval = now - time;
if (interval <= ONE_MINITE) {
return "刚刚发布";
} else if (interval <= ONE_HOUR) {
return interval / ONE_MINITE + "分钟前";
} else if (interval <= ONE_DAY) {
return interval / ONE_HOUR + "小时前";
} else if (interval < THREE_DAY) {
return interval / ONE_DAY + "天前";
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(date);
}
public static String remainingTime(Date date) {
long time = date.getTime() / 1000;
long now = (new Date()).getTime() / 1000;
long interval = time - now;
if (interval < 0)
return "";
if (interval <= ONE_MINITE) {
return "1分钟";
} else if (interval <= ONE_HOUR) {
return interval / ONE_MINITE + "分钟";
} else if (interval <= ONE_DAY) {
return interval / ONE_HOUR + "小时" + (interval % ONE_HOUR) / ONE_MINITE + "分钟";
} else {
return interval / ONE_DAY + "天" +
(interval % ONE_DAY) / ONE_HOUR + "小时" +
((interval % ONE_DAY) % ONE_HOUR) / ONE_MINITE + "分钟";
}
}
}
......@@ -44,8 +44,9 @@
<table tableName="pica_online_exam.p_analysis_round_exam_title" domainObjectName="AnalysisRoundExamTitle" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="pica_online_exam.p_reply" domainObjectName="Reply" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="pica_online_exam.p_reply_image" domainObjectName="ReplyImage" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
-->
<table tableName="pica_online_exam.p_star_record" domainObjectName="StarRecord" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
-->
<table tableName="pica_online_exam.p_anti_spam_record" domainObjectName="AntiSpamRecord" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
......
......@@ -33,7 +33,14 @@
from p_analysis_round
where analysis_id = #{id,jdbcType=INTEGER}
and is_deleted = 0
and seq_no >= (select seq_no from p_analysis_round where is_published = 1 and is_deleted = 0 limit 1)
and seq_no >=
(select
seq_no from p_analysis_round
where is_published = 1
and is_deleted = 0
order by seq_no desc
limit 1)
order by seq_no
limit 2
</select>
......@@ -47,6 +54,22 @@
limit 1
</select>
<select id="selectHistoryRoundListById" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from p_analysis_round
where analysis_id = #{id,jdbcType=INTEGER}
and is_deleted = 0
and seq_no &lt;=
(select
seq_no from p_analysis_round
where is_published = 1
and is_deleted = 0
order by seq_no desc
limit 1)
order by seq_no
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from p_analysis_round
where id = #{id,jdbcType=INTEGER}
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pica.cloud.online.exam.analysis.server.mapper.AntiSpamRecordMapper">
<resultMap id="BaseResultMap" type="com.pica.cloud.online.exam.analysis.server.entity.AntiSpamRecord">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="sys_code" jdbcType="VARCHAR" property="sysCode" />
<result column="content" jdbcType="VARCHAR" property="content" />
<result column="result" jdbcType="VARCHAR" property="result" />
<result column="action" jdbcType="TINYINT" property="action" />
<result column="label" jdbcType="VARCHAR" property="label" />
<result column="hint" jdbcType="VARCHAR" property="hint" />
<result column="created_id" jdbcType="INTEGER" property="createdId" />
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
<result column="modified_id" jdbcType="INTEGER" property="modifiedId" />
<result column="modified_time" jdbcType="TIMESTAMP" property="modifiedTime" />
<result column="is_deleted" jdbcType="BIT" property="isDeleted" />
</resultMap>
<sql id="Base_Column_List">
id, sys_code, content, result, action, label, hint, created_id, created_time, modified_id,
modified_time, is_deleted
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from p_anti_spam_record
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from p_anti_spam_record
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.pica.cloud.online.exam.analysis.server.entity.AntiSpamRecord">
insert into p_anti_spam_record (id, sys_code, content,
result, action, label,
hint, created_id, created_time,
modified_id, modified_time, is_deleted
)
values (#{id,jdbcType=INTEGER}, #{sysCode,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR},
#{result,jdbcType=VARCHAR}, #{action,jdbcType=TINYINT}, #{label,jdbcType=VARCHAR},
#{hint,jdbcType=VARCHAR}, #{createdId,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP},
#{modifiedId,jdbcType=INTEGER}, #{modifiedTime,jdbcType=TIMESTAMP}, #{isDeleted,jdbcType=BIT}
)
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.online.exam.analysis.server.entity.AntiSpamRecord">
insert into p_anti_spam_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="sysCode != null">
sys_code,
</if>
<if test="content != null">
content,
</if>
<if test="result != null">
result,
</if>
<if test="action != null">
action,
</if>
<if test="label != null">
label,
</if>
<if test="hint != null">
hint,
</if>
<if test="createdId != null">
created_id,
</if>
<if test="createdTime != null">
created_time,
</if>
<if test="modifiedId != null">
modified_id,
</if>
<if test="modifiedTime != null">
modified_time,
</if>
<if test="isDeleted != null">
is_deleted,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="sysCode != null">
#{sysCode,jdbcType=VARCHAR},
</if>
<if test="content != null">
#{content,jdbcType=VARCHAR},
</if>
<if test="result != null">
#{result,jdbcType=VARCHAR},
</if>
<if test="action != null">
#{action,jdbcType=TINYINT},
</if>
<if test="label != null">
#{label,jdbcType=VARCHAR},
</if>
<if test="hint != null">
#{hint,jdbcType=VARCHAR},
</if>
<if test="createdId != null">
#{createdId,jdbcType=INTEGER},
</if>
<if test="createdTime != null">
#{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null">
#{modifiedId,jdbcType=INTEGER},
</if>
<if test="modifiedTime != null">
#{modifiedTime,jdbcType=TIMESTAMP},
</if>
<if test="isDeleted != null">
#{isDeleted,jdbcType=BIT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.online.exam.analysis.server.entity.AntiSpamRecord">
update p_anti_spam_record
<set>
<if test="sysCode != null">
sys_code = #{sysCode,jdbcType=VARCHAR},
</if>
<if test="content != null">
content = #{content,jdbcType=VARCHAR},
</if>
<if test="result != null">
result = #{result,jdbcType=VARCHAR},
</if>
<if test="action != null">
action = #{action,jdbcType=TINYINT},
</if>
<if test="label != null">
label = #{label,jdbcType=VARCHAR},
</if>
<if test="hint != null">
hint = #{hint,jdbcType=VARCHAR},
</if>
<if test="createdId != null">
created_id = #{createdId,jdbcType=INTEGER},
</if>
<if test="createdTime != null">
created_time = #{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null">
modified_id = #{modifiedId,jdbcType=INTEGER},
</if>
<if test="modifiedTime != null">
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
</if>
<if test="isDeleted != null">
is_deleted = #{isDeleted,jdbcType=BIT},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.online.exam.analysis.server.entity.AntiSpamRecord">
update p_anti_spam_record
set sys_code = #{sysCode,jdbcType=VARCHAR},
content = #{content,jdbcType=VARCHAR},
result = #{result,jdbcType=VARCHAR},
action = #{action,jdbcType=TINYINT},
label = #{label,jdbcType=VARCHAR},
hint = #{hint,jdbcType=VARCHAR},
created_id = #{createdId,jdbcType=INTEGER},
created_time = #{createdTime,jdbcType=TIMESTAMP},
modified_id = #{modifiedId,jdbcType=INTEGER},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
is_deleted = #{isDeleted,jdbcType=BIT}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
......@@ -82,6 +82,59 @@
limit 5
</select>
<select id="selectElectedStarCountByExamTitleIdList" resultType="java.lang.Integer">
select
sum(star_count) as star
from p_reply
where analysis_round_exam_title_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
and is_deleted = 0
group by user_id
order by star desc, created_time
limit 1
</select>
<select id="selectElectedDoctorIdByExamTitleIdList" resultType="java.lang.Integer">
select
ifnull(user_id,0)
from p_reply
where analysis_round_exam_title_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
and is_deleted = 0
group by user_id
order by sum(star_count) desc, created_time
limit 1
</select>
<select id="selectStarCountByParam" resultType="java.lang.Integer">
select
ifnull(sum(star_count),0)
from p_reply
where analysis_round_exam_title_id in
<foreach item="item" index="index" collection="examTitleList" open="(" separator="," close=")">
#{item}
</foreach>
and is_deleted = 0
and user_id = #{doctorId,jdbcType=INTEGER}
</select>
<select id="selectStarRecordByParam" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from p_reply
where analysis_round_exam_title_id in
<foreach item="item" index="index" collection="examTitleList" open="(" separator="," close=")">
#{item}
</foreach>
and is_deleted = 0
and user_id = #{doctorId,jdbcType=INTEGER}
order by analysis_round_exam_title_id
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from p_reply
where id = #{id,jdbcType=INTEGER}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册