fixed 多选题

master
zhangjinli 3 years ago
parent cc3e240e65
commit b5e566f72f

BIN
.DS_Store vendored

Binary file not shown.

@ -60,9 +60,10 @@ public class UtilController {
}
public static void main(String[] args) {
String code = "eyJNc2dJZCI6InlEUnNwVVVneWcxN3Y0bWFVeGVuMTVWQndnM25nMExYIiwiTXNnVHlwZSI6IkZsb3dTdGF0dXNDaGFuZ2UiLCJNc2dEYXRhIjp7IkFwcGxpY2F0aW9uSWQiOiJ5RFI0eFVVZ3lnMXFlenBhVXk4bHNTN3dlT1hyU2VMNyIsIlByb3h5T3JnYW5pemF0aW9uT3BlbklkIjoiZGRkZGRkIiwiQ3VzdG9tZXJEYXRhIjoiIiwiRmxvd0lkIjoieURSc2tVVWd5ZzE5bWZ1YlV4dXN4amR3U1RFSkpxcDEiLCJGbG93TmFtZSI6IuS6keS6kemXrui9puS6jOaJi+i9puaUtui0reWQiOWQjCIsIkZsb3dUeXBlIjoi5ZCI5ZCMIiwiRmxvd1N0YXR1cyI6IlBBUlQiLCJGbG93TWVzc2FnZSI6IiIsIkNyZWF0ZU9uIjoxNjY4NDE0ODcwLCJEZWFkbGluZSI6MTY5OTk1MDg3MCwiRmxvd0FwcHJvdmVySW5mbyI6W3siUHJveHlPcmdhbml6YXRpb25PcGVuSWQiOiJkZGRkZGQiLCJQcm94eU9wZXJhdG9yT3BlbklkIjoieURSR2lVVXFiOHZxa1V5ZTdTeTR5bzlvV2VvRmtLMjEiLCJyZWNpcGllbnRJZCI6InlEUjRSVVVneWcxMWdwbHBVRXlaY2NFRWYzMHJkN3B1IiwiUGhvbmVOdW1iZXIiOiIxMzU4ODc4NDIwNCIsIlByb3h5T3JnYW5pemF0aW9uTmFtZSI6IuS6keS6kemXrui9puaxvei9puenkeaKgO+8iOWugeazou+8ieaciemZkOWFrOWPuCIsIlNpZ25PcmRlciI6MSwiQXBwcm92ZU5hbWUiOiLlvKDph5HmnY4iLCJBcHByb3ZlU3RhdHVzIjoiQUNDRVBUIiwiQXBwcm92ZU1lc3NhZ2UiOiIiLCJBcHByb3ZlVGltZSI6MTY2ODQxNDg3MiwiQ2FTaWduIjoiIn0seyJQcm94eU9yZ2FuaXphdGlvbk9wZW5JZCI6IiIsIlByb3h5T3BlcmF0b3JPcGVuSWQiOiIiLCJyZWNpcGllbnRJZCI6InlEUjR2VVVneWcxdHVuNHRVeE5PRmhmdklxbm1nSVFKIiwiUGhvbmVOdW1iZXIiOiIxMzU4ODc4NDIwNCIsIlByb3h5T3JnYW5pemF0aW9uTmFtZSI6IiIsIlNpZ25PcmRlciI6MiwiQXBwcm92ZU5hbWUiOiLlvKDph5HmnY4iLCJBcHByb3ZlU3RhdHVzIjoiUEVORElORyIsIkFwcHJvdmVNZXNzYWdlIjoiIiwiQXBwcm92ZVRpbWUiOjAsIkNhU2lnbiI6IiJ9XSwiT2NjdXJUaW1lIjoxNjY4NDE0ODcyfX0=";
byte[] decodeBytes = java.util.Base64.getDecoder().decode(code);
System.out.println(decodeBytes);
String[] arr = {"a"};
String join = String.join(",", arr);
System.out.println(join);
String[] split = join.split(",");
System.out.println(split[0]);
}
}

@ -111,6 +111,7 @@ public class CompanyQnAnswerController {
private String answerOpt;
private String answerCont;
private HashMap<String, List<Integer>> answerPartnerChoice;
private String[] answerMultiOpt;
}
@Operation(summary = "答题结果")
@ -145,6 +146,8 @@ public class CompanyQnAnswerController {
private String answerChoice;
@Schema(title = "互选题回答结果")
private HashMap<String, int[]> answerPartnerChoice;
@Schema(title = "多选题回答结果")
private String[] answerMultiChoice;
@JsonIgnore(value = false)
private Answerer userInfo;
}

@ -115,8 +115,8 @@ public class QnTitleController {
private String tag;
@Schema(title = "题型")
@NotNull(message = "题型不能为空")
@Min(value = 1, message = "类型范围为1 2 3")
@Max(value = 3, message = "类型范围为1 2 3")
@Min(value = 1, message = "题型范围为1填空2选择3互选4多选")
@Max(value = 4, message = "题型范围为1填空2选择3互选4多选")
private Integer kind;
@Schema(title = "选项")
private String[] options;
@ -141,8 +141,8 @@ public class QnTitleController {
@Schema(title = "标签")
private String tag;
@Schema(title = "题型")
@Min(value = 1, message = "类型范围为1 2 3")
@Max(value = 3, message = "类型范围为1 2 3")
@Min(value = 1, message = "题型范围为1填空2选择3互选4多选")
@Max(value = 4, message = "题型范围为1填空2选择3互选4多选")
private Integer kind;
@Schema(title = "选项")
private String[] options;

@ -77,6 +77,8 @@ public class CompanyQnTitle extends Model {
public static int CompanyQnTitleKindChoice = 2;
/** 互选题 */
public static int CompanyQnTitleKindPartnerChoice = 3;
/** 多选题 */
public static int CompanyQnTitleKindMultiChoice = 4;
/** 基础题目 */
public static int ManageQnTitleBase = 1;
@ -94,6 +96,8 @@ public class CompanyQnTitle extends Model {
return "选择题";
case 3:
return "互选题";
case 4:
return "多选题";
default:
return "未知";
}

@ -70,6 +70,15 @@ public class QnTitle extends Model {
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
/** 填空题 */
public static int QnTitleKindFill = 1;
/** 选择题 */
public static int QnTitleKindChoice = 2;
/** 互选题 */
public static int QnTitleKindPartnerChoice = 3;
/** 多选题 */
public static int QnTitleKindMultiChoice = 4;
public static String getKindName(int kind) {
switch (kind) {
case 1:
@ -78,10 +87,13 @@ public class QnTitle extends Model {
return "选择题";
case 3:
return "互选题";
case 4:
return "多选题";
default:
return "未知";
}
}
public static String getStatusName(int status) {
switch (status) {
case 0:

@ -87,6 +87,9 @@ public class CompanyQnAnswerServiceImpl extends ServiceImpl<CompanyQnAnswerMappe
r.setAnswerOpt(null);
r.setAnswerCont(null);
}
if (kind == CompanyQnTitle.CompanyQnTitleKindMultiChoice){
r.setAnswerMultiOpt(i.getAnswerOpt().split(","));
}
}
result.add(r);
}
@ -147,7 +150,7 @@ public class CompanyQnAnswerServiceImpl extends ServiceImpl<CompanyQnAnswerMappe
String answerOpt = null;
String answerCont = null;
JSONObject options = null;
if (Common.isContain(new int[]{CompanyQnTitle.CompanyQnTitleKindChoice, CompanyQnTitle.CompanyQnTitleKindPartnerChoice}, companyQnTitle.getKind())) {
if (Common.isContain(new int[]{CompanyQnTitle.CompanyQnTitleKindChoice, CompanyQnTitle.CompanyQnTitleKindPartnerChoice, CompanyQnTitle.CompanyQnTitleKindMultiChoice}, companyQnTitle.getKind())) {
try {
options = JSONObject.parseObject((String) companyQnTitle.getOptions());
} catch (Exception e) {
@ -198,6 +201,19 @@ public class CompanyQnAnswerServiceImpl extends ServiceImpl<CompanyQnAnswerMappe
}
super.saveBatch(list);
break;
case 4: // 多选题
String[] answerOpts = params.getAnswerMultiChoice();
if(answerOpts==null||answerOpts.length <=0){
return Result.err("回答为空");
}
for (String opt : answerOpts) {
answerCont = (String) options.get(opt);
if (null == opt || null == answerCont) {
return Result.err("选项不符");
}
}
super.saveOrUpdate(companyQnAnswer.setAnswerOpt(String.join(",",answerOpts)), up);
break;
default:
return Result.err("未知题型");
}
@ -230,13 +246,13 @@ public class CompanyQnAnswerServiceImpl extends ServiceImpl<CompanyQnAnswerMappe
if (null == qn) {
return Result.err("未知问卷");
}
QueryWrapper<CompanyQnAnswerer> qw = new QueryWrapper<>();
qw.select("answerer_id").eq("qn_id", qnId);
IPage iPage = companyQnAnswererService.page(page, qw);
List<CompanyQnAnswerer> answererIds = iPage.getRecords();
QueryWrapper<CompanyQnAnswer> qw = new QueryWrapper<>();
qw.select("answerer_id").eq("qn_id", qnId).groupBy("answerer_id");
IPage iPage = super.page(page, qw);
List<CompanyQnAnswer> answererIds = iPage.getRecords();
Collection ids = new ArrayList<>();
if (answererIds.size() > 0) {
for (CompanyQnAnswerer i : answererIds) {
for (CompanyQnAnswer i : answererIds) {
ids.add(i.getAnswererId());
}
}
@ -263,8 +279,10 @@ public class CompanyQnAnswerServiceImpl extends ServiceImpl<CompanyQnAnswerMappe
List<CompanyQnController.ResultPartnerChoice> list = partnerChoiceResultData(qnId, isManage ? false : (qn.getIsSecret() == 1), null);
for (CompanyQnController.ResultPartnerChoice resultPartnerChoice : list) {
Map map = new LinkedHashMap();
map.put("SourceId", resultPartnerChoice.getAnswererName());
map.put("TargetId", resultPartnerChoice.getQnTowardsName());
map.put("SourceId", resultPartnerChoice.getAnswererId());
map.put("SourceName", resultPartnerChoice.getAnswererName());
map.put("TargetId", resultPartnerChoice.getQnTowardsId());
map.put("TargetName", resultPartnerChoice.getQnTowardsName());
for (CompanyQnController.ResultAnswerPartnerChoice resultAnswerPartnerChoice : resultPartnerChoice.getAnswerPartnerChoice()) {
String title = "题目编号" + resultAnswerPartnerChoice.getTitleId().toString();
if (null != qnTitleMap.get(resultAnswerPartnerChoice.getTitleId())) {

@ -77,7 +77,7 @@ public class CompanyQnTitleServiceImpl extends ServiceImpl<CompanyQnTitleMapper,
.setGroupId(i.getGroupId());
{
String[] options = i.getOptions();
if (Common.isContain(new int[]{CompanyQnTitle.CompanyQnTitleKindChoice, CompanyQnTitle.CompanyQnTitleKindPartnerChoice}, i.getKind())) {
if (Common.isContain(new int[]{CompanyQnTitle.CompanyQnTitleKindChoice, CompanyQnTitle.CompanyQnTitleKindPartnerChoice,CompanyQnTitle.CompanyQnTitleKindMultiChoice}, i.getKind())) {
FuncRes funcRes = QnTitle.optionsToObj(options);
if (!funcRes.isSuccess()) {
return Result.err(funcRes.getMsg());
@ -153,7 +153,7 @@ public class CompanyQnTitleServiceImpl extends ServiceImpl<CompanyQnTitleMapper,
.set(StringUtils.isNotBlank(params.getTitle()), "title", params.getTitle());
{
String[] options = params.getOptions();
if (Common.isContain(new int[]{CompanyQnTitle.CompanyQnTitleKindChoice, CompanyQnTitle.CompanyQnTitleKindPartnerChoice}, r.getKind())) {
if (Common.isContain(new int[]{CompanyQnTitle.CompanyQnTitleKindChoice, CompanyQnTitle.CompanyQnTitleKindPartnerChoice,CompanyQnTitle.CompanyQnTitleKindMultiChoice}, r.getKind())) {
FuncRes funcRes = QnTitle.optionsToObj(options);
if (!funcRes.isSuccess()) {
return Result.err(funcRes.getMsg());

@ -87,7 +87,7 @@ public class QnTitleServiceImpl extends ServiceImpl<QnTitleMapper, QnTitle> impl
.setStatus(1);
{
String[] options = params.getOptions();
if (Common.isContain(new int[]{CompanyQnTitle.CompanyQnTitleKindChoice, CompanyQnTitle.CompanyQnTitleKindPartnerChoice}, params.getKind())) {
if (Common.isContain(new int[]{QnTitle.QnTitleKindChoice, QnTitle.QnTitleKindPartnerChoice,QnTitle.QnTitleKindMultiChoice}, params.getKind())) {
FuncRes funcRes = QnTitle.optionsToObj(options);
if (!funcRes.isSuccess()) {
return Result.err(funcRes.getMsg());
@ -112,7 +112,7 @@ public class QnTitleServiceImpl extends ServiceImpl<QnTitleMapper, QnTitle> impl
}
{
String[] options = params.getOptions();
if (Common.isContain(new int[]{CompanyQnTitle.CompanyQnTitleKindChoice, CompanyQnTitle.CompanyQnTitleKindPartnerChoice}, params.getKind())) {
if (Common.isContain(new int[]{QnTitle.QnTitleKindChoice, QnTitle.QnTitleKindPartnerChoice,QnTitle.QnTitleKindMultiChoice}, params.getKind())) {
FuncRes funcRes = QnTitle.optionsToObj(options);
if (!funcRes.isSuccess()) {
return Result.err(funcRes.getMsg());

@ -13,6 +13,7 @@ import java.util.regex.Pattern;
public class Common {
// 获取随机数
public static String getRandomString(int length, String string) {
String str = (string.length() > 0) ? string : "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
@ -37,10 +38,12 @@ public class Common {
return false;
}
// md5
public static String md5(String str) {
return DigestUtils.md5DigestAsHex(str.getBytes(StandardCharsets.UTF_8));
}
// 是否大于0判断
public static Boolean higherZero(Integer i) {
if (null == i) {
return false;
@ -48,6 +51,7 @@ public class Common {
return i.compareTo(0) == 1 ? true : false;
}
// 获取obj元素值
public static Object ObjectFieldValue(Object obj, String fieldName) {
Class<?> resultClz = obj.getClass();
Field[] fieldInfo = resultClz.getDeclaredFields();
@ -64,6 +68,7 @@ public class Common {
return null;
}
// 修改obj元素
public static Object changObjectValue(Object obj, String fieldName, Object value) {
Class<?> resultClz = obj.getClass();
Field[] fieldInfo = resultClz.getDeclaredFields(); //获取class里的所有字段 父类字段获取不到 注:如果出现加密解密失败 请先查看idno是否在父类中
@ -79,6 +84,7 @@ public class Common {
return obj;
}
// obj转map
public static Map<String, Object> objectToMap(Object obj) throws Exception {
Map<String, Object> map = new HashMap<>();
if (obj == null) {
@ -93,6 +99,7 @@ public class Common {
return map;
}
// arr是否包含int
public static Boolean isContain(int[] arr, int v) {
if (arr == null || arr.length == 0) {
return false;
@ -105,6 +112,7 @@ public class Common {
return false;
}
// arr是否包含String
public static Boolean isContain(String[] arr, String v) {
if (arr == null || arr.length == 0) {
return false;
@ -117,3 +125,4 @@ public class Common {
return false;
}
}

@ -0,0 +1,109 @@
server:
port: 8080
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://118.31.114.112:3306/linac_qn_helper?serverTimezone=Asia/Shanghai
# url: jdbc:mysql://121.41.171.43:3306/lingnuo?serverTimezone=GMT
username: linac_qn_helper
password: L5h8Akes3MXGZ2zY
hikari:
max-lifetime: 500000
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: Asia/Shanghai
resources:
static-locations: classpath:templates/,classpath:static/
mvc:
view:
prefix: /
suffix: .html
servlet:
multipart:
max-file-size: 10MB
max-request-size: 100MB
mail:
host: smtp.exmail.qq.com
username: center-ona@linac.net
password: 8[B@cqcGJpLA4)6
protocol: smtp
default-encoding: UTF-8
port: 465
properties:
mail:
smtp:
ssl:
enable: true
socketFactory:
port: 465
class: javax.net.ssl.SSLSocketFactory
mailAddr: center-ona@linac.net
pagehelper:
reasonable: false # 禁用合理化时如果pageNum<1或pageNum>pages会返回空数据
support-methods-arguments: true
params: count=countSql
row-bounds-with-count: true
helper-dialect: mysql
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
auto-mapping-behavior: full
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath*:mapper/**/*Mapper.xml
global-config:
# 逻辑删除配置
db-config:
# 删除前
logic-not-delete-value: 1
# 删除后
logic-delete-value: 0
aliyun:
sms:
accessKeyId: LTAI5tRBUQJ2x1H1cgYcX282
accessKeySecret: zqvQfEtR7r5lVazmU9CGeHCmEpyZr5
region: cn-hangzhou
endpoint: dysmsapi.aliyuncs.com
signName: 领诺CenteRONA
templateCode: SMS_255286086
#springdoc:
# swagger-ui:
# # 修改Swagger UI路径
# path: /swagger-ui.html
# # 开启Swagger UI界面
# enabled: true
# api-docs:
# # 修改api-docs路径
# path: /v3/api-docs
# # 开启api-docs
# enabled: true
# # 配置需要生成接口文档的扫描包
# packages-to-scan: com.zh.project0512.controller
# # 配置需要生成接口文档的接口路径
# paths-to-match: /manage/**,/wxApp/**
web:
webUrl: https://www.linac.net
apiPath: com.zh.lingnuo.controller
# mac图片地址
# uploadPath: /Users/apple/Pictures
# 线上图片上传位置
uploadPath: /static/sws/upload/
# 图片压缩尺寸界限(200*1024)
picSizeLimit: 204800
# cdn: http://cdn.sws010.com
#showSql
logging:
level:
com:
example:
mapper: debug

@ -1,13 +1,13 @@
server:
port: 8080
port: 8081
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://118.31.114.112:3306/linac_qn_helper?serverTimezone=Asia/Shanghai
url: jdbc:mysql://118.31.114.112:3306/linac_qn_helper1?serverTimezone=Asia/Shanghai
# url: jdbc:mysql://121.41.171.43:3306/lingnuo?serverTimezone=GMT
username: linac_qn_helper
password: L5h8Akes3MXGZ2zY
username: linac_qn_helper1
password: 6y3XYPDAa7nrmnxT
hikari:
max-lifetime: 500000
jackson:

Loading…
Cancel
Save