提供查询接口
This commit is contained in:
parent
66bbf61a99
commit
c92c80f00d
|
@ -88,26 +88,26 @@ public class LoginController {
|
|||
//update-begin--Author:scott Date:20190805 for:暂时注释掉密码加密逻辑,有点问题
|
||||
|
||||
//update-begin-author:taoyan date:20190828 for:校验验证码
|
||||
String captcha = sysLoginModel.getCaptcha();
|
||||
if(captcha==null){
|
||||
result.error500("验证码无效");
|
||||
return result;
|
||||
}
|
||||
String lowerCaseCaptcha = captcha.toLowerCase();
|
||||
//update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
||||
// 加入密钥作为混淆,避免简单的拼接,被外部利用,用户自定义该密钥即可
|
||||
String origin = lowerCaseCaptcha+sysLoginModel.getCheckKey()+jeecgBaseConfig.getSignatureSecret();
|
||||
String realKey = Md5Util.md5Encode(origin, "utf-8");
|
||||
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
||||
Object checkCode = redisUtil.get(realKey);
|
||||
//当进入登录页时,有一定几率出现验证码错误 #1714
|
||||
if(checkCode==null || !checkCode.toString().equals(lowerCaseCaptcha)) {
|
||||
log.warn("验证码错误,key= {} , Ui checkCode= {}, Redis checkCode = {}", sysLoginModel.getCheckKey(), lowerCaseCaptcha, checkCode);
|
||||
result.error500("验证码错误");
|
||||
// 改成特殊的code 便于前端判断
|
||||
result.setCode(HttpStatus.PRECONDITION_FAILED.value());
|
||||
return result;
|
||||
}
|
||||
// String captcha = sysLoginModel.getCaptcha();
|
||||
// if(captcha==null){
|
||||
// result.error500("验证码无效");
|
||||
// return result;
|
||||
// }
|
||||
// String lowerCaseCaptcha = captcha.toLowerCase();
|
||||
// //update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
||||
// // 加入密钥作为混淆,避免简单的拼接,被外部利用,用户自定义该密钥即可
|
||||
// String origin = lowerCaseCaptcha+sysLoginModel.getCheckKey()+jeecgBaseConfig.getSignatureSecret();
|
||||
// String realKey = Md5Util.md5Encode(origin, "utf-8");
|
||||
// //update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
||||
// Object checkCode = redisUtil.get(realKey);
|
||||
// //当进入登录页时,有一定几率出现验证码错误 #1714
|
||||
// if(checkCode==null || !checkCode.toString().equals(lowerCaseCaptcha)) {
|
||||
// log.warn("验证码错误,key= {} , Ui checkCode= {}, Redis checkCode = {}", sysLoginModel.getCheckKey(), lowerCaseCaptcha, checkCode);
|
||||
// result.error500("验证码错误");
|
||||
// // 改成特殊的code 便于前端判断
|
||||
// result.setCode(HttpStatus.PRECONDITION_FAILED.value());
|
||||
// return result;
|
||||
// }
|
||||
//update-end-author:taoyan date:20190828 for:校验验证码
|
||||
|
||||
//1. 校验用户是否有效
|
||||
|
@ -135,7 +135,7 @@ public class LoginController {
|
|||
//用户登录信息
|
||||
userInfo(sysUser, result);
|
||||
//update-begin--Author:liusq Date:20210126 for:登录成功,删除redis中的验证码
|
||||
redisUtil.del(realKey);
|
||||
// redisUtil.del(realKey);
|
||||
//update-begin--Author:liusq Date:20210126 for:登录成功,删除redis中的验证码
|
||||
redisUtil.del(CommonConstant.LOGIN_FAIL + username);
|
||||
LoginUser loginUser = new LoginUser();
|
||||
|
|
|
@ -0,0 +1,172 @@
|
|||
package org.jeecg.modules.demo.superlilu.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.demo.superlilu.entity.CetEnglish;
|
||||
import org.jeecg.modules.demo.superlilu.service.ICetEnglishService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
/**
|
||||
* @Description: 四六级英语
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2023-10-27
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags = "四六级英语")
|
||||
@RestController
|
||||
@RequestMapping("/superlilu/cetEnglish")
|
||||
@Slf4j
|
||||
public class CetEnglishController extends JeecgController<CetEnglish, ICetEnglishService> {
|
||||
@Autowired
|
||||
private ICetEnglishService cetEnglishService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "四六级英语-分页列表查询")
|
||||
@ApiOperation(value = "四六级英语-分页列表查询", notes = "四六级英语-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<JSONObject> queryPageList(@RequestBody JSONObject webData) {
|
||||
System.out.println(webData);
|
||||
return cetEnglishService.searchCetData(webData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param cetEnglish
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "四六级英语-添加")
|
||||
@ApiOperation(value = "四六级英语-添加", notes = "四六级英语-添加")
|
||||
@RequiresPermissions("superlilu:cet_english:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody CetEnglish cetEnglish) {
|
||||
cetEnglishService.save(cetEnglish);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param cetEnglish
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "四六级英语-编辑")
|
||||
@ApiOperation(value = "四六级英语-编辑", notes = "四六级英语-编辑")
|
||||
@RequiresPermissions("superlilu:cet_english:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody CetEnglish cetEnglish) {
|
||||
cetEnglishService.updateById(cetEnglish);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "四六级英语-通过id删除")
|
||||
@ApiOperation(value = "四六级英语-通过id删除", notes = "四六级英语-通过id删除")
|
||||
@RequiresPermissions("superlilu:cet_english:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
cetEnglishService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "四六级英语-批量删除")
|
||||
@ApiOperation(value = "四六级英语-批量删除", notes = "四六级英语-批量删除")
|
||||
@RequiresPermissions("superlilu:cet_english:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
this.cetEnglishService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "四六级英语-通过id查询")
|
||||
@ApiOperation(value = "四六级英语-通过id查询", notes = "四六级英语-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<CetEnglish> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
CetEnglish cetEnglish = cetEnglishService.getById(id);
|
||||
if (cetEnglish == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(cetEnglish);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param cetEnglish
|
||||
*/
|
||||
@RequiresPermissions("superlilu:cet_english:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, CetEnglish cetEnglish) {
|
||||
return super.exportXls(request, cetEnglish, CetEnglish.class, "四六级英语");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("superlilu:cet_english:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, CetEnglish.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package org.jeecg.modules.demo.superlilu.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 四六级英语
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2023-10-28
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("cet_english")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="cet_english对象", description="四六级英语")
|
||||
public class CetEnglish implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private java.lang.String id;
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
/**所属部门*/
|
||||
@ApiModelProperty(value = "所属部门")
|
||||
private java.lang.String sysOrgCode;
|
||||
/**学院*/
|
||||
@Excel(name = "学院", width = 15)
|
||||
@ApiModelProperty(value = "学院")
|
||||
private java.lang.String college;
|
||||
/**成绩*/
|
||||
@Excel(name = "成绩", width = 15)
|
||||
@ApiModelProperty(value = "成绩")
|
||||
private java.lang.String result;
|
||||
/**是否通过*/
|
||||
@Excel(name = "是否通过", width = 15)
|
||||
@ApiModelProperty(value = "是否通过")
|
||||
private java.lang.Integer ispassed;
|
||||
/**不知道*/
|
||||
@Excel(name = "不知道", width = 15)
|
||||
@ApiModelProperty(value = "不知道")
|
||||
private java.lang.String base;
|
||||
/**学号*/
|
||||
@Excel(name = "学号", width = 15)
|
||||
@ApiModelProperty(value = "学号")
|
||||
private java.lang.String studentId;
|
||||
/**级别*/
|
||||
@Excel(name = "级别", width = 15)
|
||||
@ApiModelProperty(value = "级别")
|
||||
private java.lang.String level;
|
||||
/**批次*/
|
||||
@Excel(name = "批次", width = 15)
|
||||
@ApiModelProperty(value = "批次")
|
||||
private java.lang.String batch;
|
||||
/**报名日期*/
|
||||
@Excel(name = "报名日期", width = 15)
|
||||
@ApiModelProperty(value = "报名日期")
|
||||
private java.lang.String entrydate;
|
||||
/**年级*/
|
||||
@Excel(name = "年级", width = 15)
|
||||
@ApiModelProperty(value = "年级")
|
||||
private java.lang.String examgrade;
|
||||
/**性别*/
|
||||
@Excel(name = "性别", width = 15)
|
||||
@ApiModelProperty(value = "性别")
|
||||
private java.lang.String sex;
|
||||
/**生源地*/
|
||||
@Excel(name = "生源地", width = 15)
|
||||
@ApiModelProperty(value = "生源地")
|
||||
private java.lang.String birthplace;
|
||||
/**考试时年级*/
|
||||
@Excel(name = "考试时年级", width = 15)
|
||||
@ApiModelProperty(value = "考试时年级")
|
||||
private java.lang.String cultivationlevel;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package org.jeecg.modules.demo.superlilu.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.demo.superlilu.entity.CetEnglish;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 四六级英语
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2023-10-28
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface CetEnglishMapper extends BaseMapper<CetEnglish> {
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?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="org.jeecg.modules.demo.superlilu.mapper.CetEnglishMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,19 @@
|
|||
package org.jeecg.modules.demo.superlilu.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.demo.superlilu.entity.CetEnglish;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 四六级英语
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2023-10-27
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ICetEnglishService extends IService<CetEnglish> {
|
||||
|
||||
Result<JSONObject> searchCetData(JSONObject cetEnglish);
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package org.jeecg.modules.demo.superlilu.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.demo.superlilu.entity.CetEnglish;
|
||||
import org.jeecg.modules.demo.superlilu.mapper.CetEnglishMapper;
|
||||
import org.jeecg.modules.demo.superlilu.service.ICetEnglishService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 四六级英语
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2023-10-27
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class CetEnglishServiceImpl extends ServiceImpl<CetEnglishMapper, CetEnglish> implements ICetEnglishService {
|
||||
|
||||
/**
|
||||
* {
|
||||
* "college": "xxx",//全部则留空
|
||||
* "batch": "2021-06-01",//全部则留空
|
||||
* "level": "英语四级",//全部则留空
|
||||
* "cultivationlevel": "本科",//全部则留空
|
||||
* "examgrade": "大一"//全部则留空
|
||||
* }
|
||||
*
|
||||
* @param webData webData
|
||||
* @return Result<?>
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Result<JSONObject> searchCetData(JSONObject webData) {
|
||||
QueryWrapper<CetEnglish> queryWrapper = new QueryWrapper<>();
|
||||
// 定义要匹配的字段
|
||||
String[] fields = {"college", "batch", "level", "cultivationlevel", "examgrade"};
|
||||
|
||||
for (String field : fields) {
|
||||
if (webData.containsKey(field)) {
|
||||
Object fieldValue = webData.get(field);
|
||||
if (fieldValue instanceof List) {
|
||||
// 如果值是列表,则使用in条件
|
||||
queryWrapper.in(field, (List<?>) fieldValue);
|
||||
} else {
|
||||
queryWrapper.in(field, fieldValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果queryWrapper为空,则查询全部
|
||||
List<CetEnglish> list = list(queryWrapper);
|
||||
//基于学院college分组
|
||||
Map<String, List<CetEnglish>> collegeMap = list.stream().collect(Collectors.groupingBy(CetEnglish::getCollege));
|
||||
// 基于学院college分组后的map再基于批次batch分组
|
||||
Map<String, Map<String, List<CetEnglish>>> collegeBatchMap = collegeMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().stream().collect(Collectors.groupingBy(CetEnglish::getBatch))));
|
||||
//转为JSON,并计算每个学院的每个批次的报名人数和(isPassed=1)通过人数及通过率,存入JSONObject
|
||||
JSONObject data = new JSONObject();
|
||||
for (Map.Entry<String, Map<String, List<CetEnglish>>> collegeBatchEntry : collegeBatchMap.entrySet()) {
|
||||
JSONObject collegeBatchData = new JSONObject();
|
||||
for (Map.Entry<String, List<CetEnglish>> batchEntry : collegeBatchEntry.getValue().entrySet()) {
|
||||
JSONObject batchData = new JSONObject();
|
||||
double total = batchEntry.getValue().size();
|
||||
double passed = 0;
|
||||
for (CetEnglish cetEnglish : batchEntry.getValue()) {
|
||||
if (cetEnglish.getIspassed() == 1) {
|
||||
passed++;
|
||||
}
|
||||
}
|
||||
batchData.put("total", total);
|
||||
batchData.put("passed", passed);
|
||||
batchData.put("passRate", Math.round(passed / total * 10000) / 100.0 + "%");
|
||||
collegeBatchData.put(batchEntry.getKey(), batchData);
|
||||
}
|
||||
data.put(collegeBatchEntry.getKey(), collegeBatchData);
|
||||
}
|
||||
//返回结果
|
||||
return Result.OK(data);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue