forked from Big-Data-Lab/CET-cmd-2.0
代码优化
This commit is contained in:
parent
14ad6463ff
commit
2a68bc53ee
|
@ -10,11 +10,8 @@ import org.jeecg.modules.entity.Cet_6;
|
|||
import org.jeecg.modules.service.CenterService;
|
||||
import org.jeecg.modules.service.ICet_4Service;
|
||||
import org.jeecg.modules.service.ICet_6Service;
|
||||
import org.jeecg.modules.util.WrapMapper;
|
||||
import org.jeecg.modules.util.Wrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -128,46 +125,28 @@ public class CenterController {
|
|||
return cet4Service.getRateByMajor(webData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param getRateByMajorAndLastestBatchParam
|
||||
* @param bindingResult
|
||||
* @return {@link Wrapper }
|
||||
* @return {@link Result }<{@link JSONObject }>
|
||||
*/
|
||||
@PostMapping("/getRateByMajorAndLastestBatch")
|
||||
@ApiOperation(value = "根据专业获取每个年级最新批次的通过率")
|
||||
public Wrapper getRateByMajorAndLastestBatch(@Valid @RequestBody getRateByMajorAndLastestBatchDto getRateByMajorAndLastestBatchParam, BindingResult bindingResult) {
|
||||
public Result<JSONObject> getRateByMajorAndLastestBatch(@Valid @RequestBody getRateByMajorAndLastestBatchDto getRateByMajorAndLastestBatchParam) {
|
||||
log.info("根据专业获取最新批次的通过率入参:{}", JSONObject.toJSONString(getRateByMajorAndLastestBatchParam));
|
||||
try {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return WrapMapper.error(bindingResult.getFieldError().getDefaultMessage());
|
||||
}
|
||||
|
||||
return cet4Service.getRateByMajorAndLastestBatch(getRateByMajorAndLastestBatchParam);
|
||||
} catch (Exception e) {
|
||||
log.error("调用根据专业获取最新批次的通过率出现错误!" + e.getMessage());
|
||||
return WrapMapper.error("调用根据专业获取最新批次的通过率出现错误!" + e.getMessage());
|
||||
}
|
||||
return cet4Service.getRateByMajorAndLastestBatch(getRateByMajorAndLastestBatchParam);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param getRateByEntryDateParams
|
||||
* @param bindingResult
|
||||
* @return {@link Wrapper }
|
||||
* @return {@link Result }<{@link JSONObject }>
|
||||
*/
|
||||
@PostMapping( "/getRateByEntryDate")
|
||||
@ApiOperation(value = "根据学院/专业的每个年级的通过率")
|
||||
public Wrapper getRateByEntryDate(@RequestBody getRateByEntryDate getRateByEntryDateParams, BindingResult bindingResult) {
|
||||
public Result<JSONObject> getRateByEntryDate(@RequestBody getRateByEntryDate getRateByEntryDateParams) {
|
||||
log.info("根据学院/专业的每个年级的通过率: {}", JSONObject.toJSONString(getRateByEntryDateParams));
|
||||
try {
|
||||
if(bindingResult.hasErrors()) {
|
||||
return WrapMapper.error(bindingResult.getFieldError().getDefaultMessage());
|
||||
}
|
||||
return cet4Service.getRateByEntryDate(getRateByEntryDateParams);
|
||||
}catch (Exception e){
|
||||
log.error("调用根据学院/专业的每个年级的通过率!" + e.getMessage());
|
||||
return WrapMapper.error("调用根据学院/专业的每个年级的通过率!" + e.getMessage());
|
||||
}
|
||||
|
||||
return cet4Service.getRateByEntryDate(getRateByEntryDateParams);
|
||||
}
|
||||
@GetMapping("/getTest")
|
||||
public Result<JSONObject> getTest() {
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Param;
|
|||
import org.jeecg.modules.entity.Cet_4;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -13,5 +14,6 @@ import java.util.List;
|
|||
* @Version: V1.0
|
||||
*/
|
||||
public interface Cet_4Mapper extends BaseMapper<Cet_4> {
|
||||
Date lastestDate();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?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.mapper.Cet_4Mapper">
|
||||
<select id="lastestDate" resultType="java.util.Date">
|
||||
SELECT MAX(batch) AS latest_batch FROM cet_4;
|
||||
</select>
|
||||
</mapper>
|
|
@ -3,6 +3,8 @@ package org.jeecg.modules.service;
|
|||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.dto.getRateByEntryDate;
|
||||
import org.jeecg.modules.dto.getRateByMajorAndLastestBatchDto;
|
||||
import org.jeecg.modules.entity.Cet_4;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
|
@ -25,4 +27,8 @@ public interface ICet_4Service extends IService<Cet_4> {
|
|||
|
||||
Result<JSONObject> getDataByStudent(JSONObject jsonObject);
|
||||
boolean cleanData();
|
||||
|
||||
Result<JSONObject> getRateByMajorAndLastestBatch(getRateByMajorAndLastestBatchDto getRateByMajorAndLastestBatchParam);
|
||||
|
||||
Result<JSONObject> getRateByEntryDate(getRateByEntryDate getRateByEntryDateParams);
|
||||
}
|
||||
|
|
|
@ -17,16 +17,14 @@ import org.jeecg.modules.mapper.Cet_4Mapper;
|
|||
import org.jeecg.modules.service.CenterService;
|
||||
import org.jeecg.modules.service.CetCleanService;
|
||||
import org.jeecg.modules.service.ICet_4Service;
|
||||
import org.jeecg.modules.util.Wrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import javax.xml.crypto.Data;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -558,12 +556,8 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
|
|||
return remove(cet4Wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param getRateByMajorAndLastestBatchParam
|
||||
* @return {@link Wrapper }
|
||||
*/
|
||||
@Override
|
||||
public Wrapper getRateByMajorAndLastestBatch(getRateByMajorAndLastestBatchDto getRateByMajorAndLastestBatchParam) {
|
||||
public Result<JSONObject> getRateByMajorAndLastestBatch(getRateByMajorAndLastestBatchDto getRateByMajorAndLastestBatchParam) {
|
||||
|
||||
LambdaQueryWrapper<Cet_4> cet4Wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
@ -616,11 +610,11 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
|
|||
JSONObject result = new JSONObject();
|
||||
result.put("data", ansArray);
|
||||
|
||||
return new Wrapper<>(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, result);
|
||||
return Result.ok(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Wrapper getRateByEntryDate(getRateByEntryDate getRateByEntryDateParams) {
|
||||
public Result<JSONObject> getRateByEntryDate(getRateByEntryDate getRateByEntryDateParams) {
|
||||
LambdaQueryWrapper<Cet_4> cet4Wrapper = new LambdaQueryWrapper<>();
|
||||
cet4Wrapper.eq(Cet_4::getCollege, getRateByEntryDateParams.getCollege());
|
||||
//根据前端数据是否传major 判断是否添加 sql 条件
|
||||
|
@ -676,7 +670,7 @@ public class Cet_4ServiceImpl extends ServiceImpl<Cet_4Mapper, Cet_4> implements
|
|||
}
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("data", ansArray);
|
||||
return new Wrapper<>(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, result);
|
||||
return Result.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue