package com.controller;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import com.entity.ChengjiEntity;
import com.entity.KaochangEntity;
import com.entity.LaoshiEntity;
import com.service.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.utils.StringUtil;
import java.lang.reflect.InvocationTargetException;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.KaoshiEntity;
import com.entity.view.KaoshiView;
import com.utils.PageUtils;
import com.utils.R;
/**
* 考试
* 后端接口
* @author
* @email
* @date 2021-03-23
*/
@RestController
@Controller
@RequestMapping("/kaoshi")
public class KaoshiController {
private static final Logger logger = LoggerFactory.getLogger(KaoshiController.class);
@Autowired
private KaoshiService kaoshiService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
@Autowired
private LaoshiService laoshiService;
@Autowired
private KaochangService kaochangService;
@Autowired
private ChengjiService chengjiService;
//级联表service
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(StringUtil.isNotEmpty(role) && "用户".equals(role)){
params.put("yonghuId",request.getSession().getAttribute("userId"));
}
PageUtils page = kaoshiService.queryPage(params);
//字典表数据转换
List<KaoshiView> list =(List<KaoshiView>)page.getList();
for(KaoshiView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
KaoshiEntity kaoshi = kaoshiService.selectById(id);
if(kaoshi !=null){
//entity转view
KaoshiView view = new KaoshiView();
BeanUtils.copyProperties( kaoshi , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 保存考试并且默认添加两个考场
*/
@RequestMapping("/save")
public R save(@RequestBody KaoshiEntity kaoshi, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,kaoshi:{}",this.getClass().getName(),kaoshi.toString());
Wrapper<KaoshiEntity> queryWrapper = new EntityWrapper<KaoshiEntity>()
.eq("kaoshi_name", kaoshi.getKaoshiName())
.eq("kaoshi_types", kaoshi.getKaoshiTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
KaoshiEntity kaoshiEntity = kaoshiService.selectOne(queryWrapper);
if(kaoshiEntity==null){
if((kaoshi.getEndTime().getTime()-kaoshi.getStartTime().getTime())<=0){
return R.error("考试结束时间不能小于开始时间");
}
Date date = new Date();
kaoshi.setCreateTime(date);
kaoshiService.insert(kaoshi);
List<LaoshiEntity> laoshiEntities = laoshiService.selectList(new EntityWrapper<LaoshiEntity>());
if(laoshiEntities.size()>1){
Integer laoshiIndex1;
Integer laoshiIndex2;
if(laoshiEntities.size()==2){
laoshiIndex1=1;
laoshiIndex2=2;
}else{
Random random = new Random();
laoshiIndex1 = random.nextInt(laoshiEntities.size()-1);
laoshiIndex2 = random.nextInt(laoshiEntities.size()-1);
boolean flag=true;
while (flag){
if(laoshiIndex1.intValue() == laoshiIndex2.intValue()){
laoshiIndex2 = random.nextInt(laoshiEntities.size()-1);
}else{
flag =false;
}
}
}
//默认添加考场
List<KaochangEntity> kaochangEntityList = new ArrayList<>();
KaochangEntity kaochang1 = new KaochangEntity();
kaochang1.setCreateTime(date);
kaochang1.setKaochangAddress("长椿路第一考场");
kaochang1.setKaochangName(kaoshi.getKaoshiName()+"的第一考场");
kaochang1.setKaoshiId(kaoshi.getId());
kaochang1.setKaoshiNumber(0);
kaochang1.setLaoshiId(laoshiEntities.get(laoshiIndex1).getId());
kaochangEntityList.add(kaochang1);
KaochangEntity kaochang2 = new KaochangEntity();
kaochang2.setCreateTime(date);
kaochang2.setKaochangAddress("长椿路第二考场");
kaochang2.setKaochangName(kaoshi.getKaoshiName()+"的第二考场");
kaochang2.setKaoshiId(kaoshi.getId());
kaochang2.setKaoshiNumber(0);
kaochang2.setLaoshiId(laoshiEntities.get(laoshiIndex2).getId());
kaochangEntityList.add(kaochang2);
kaochangService.insertBatch(kaochangEntityList);
return R.ok();
}else{
return R.error("老师数量过少,生成不出两个考场");
}
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody KaoshiEntity kaoshi, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,kaoshi:{}",this.getClass().getName(),kaoshi.toString());
//根据字段查询是否有相同数据
Wrapper<KaoshiEntity> queryWrapper = new EntityWrapper<KaoshiEntity>()
.notIn("id",kaoshi.getId())
.andNew()
.eq("kaoshi_name", kaoshi.getKaoshiName())
.eq("kaoshi_types", kaoshi.getKaoshiTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
KaoshiEntity kaoshiEntity = kaoshiService.selectOne(queryWrapper);
kaoshi.setStartTime(new Date());
kaoshi.setEndTime(new Date());
if(kaoshiEntity==null){
if((kaoshi.getEndTime().getTime()-kaoshi.getStartTime().getTime())<0){
return R.error("考试结束时间不能小于开始时间");
}
kaoshiService.updateById(kaoshi);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 报名
*/
@RequestMapping("/baoming")
public R baoming(@RequestParam Integer kaoshiId, HttpServletRequest request){
logger.debug("baoming方法:,,Controller:{},,kaoshiId:{}",this.getClass().getName(),kaoshiId);
String role = String.valueOf(req
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
在互联网高度发达的今天,其理论与技术均已成熟,并深入渗透到社会各个领域。借助网络传播信息,并结合信息管理工具,能更好地服务大众。当前四六级报名信息管理存在诸多弊端,如混乱无序、差错频出、安全性低、劳动强度大且耗时费力,四六级报名与成绩查询系统应运而生,为解决这些问题提供了有效方案,让信息管理更趋科学规范。 该系统基于 Eclipse 开发环境,运用 Java 语言编写代码,通过 Mysql 构建数据表存储数据。其功能丰富,管理员可对考试与考场信息、学生及教师资料、成绩等进行全面管理;教师能够查询考试和考场详情,管理学生成绩以及查看公告;学生则可便捷地完成四六级考试报名,查询考场安排与考试成绩。 总之,四六级报名与成绩查询系统实现了信息的集中管理,具备保密性强、效率高、存储量大、成本低等显著优势,不仅降低了信息管理成本,还推动了信息管理的计算机化进程,为四六级考试相关的信息处理提供了高效、稳定且安全的平台,有力地提升了四六级考试组织与管理的整体水平,具有重要的实用价值和广阔的应用前景。
资源推荐
资源详情
资源评论






























收起资源包目录





































































































共 869 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论


2401_85761762
- 粉丝: 3456
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- vcos_components_configs-智能车资源
- 中职计算机教学中存在的问题及对策探思.docx
- 数字图像处理实验指导说明书zqd.doc
- lanqiao-蓝桥杯资源
- 汇编语言-汇编语言资源
- 通信工程中多网融合技术的探析.docx
- 基于华为云计算技术的多课程教学平台的构建.docx
- cotParam-C语言资源
- klogging-C++资源
- VC数据挖掘在客户关系管理中的实际应用.doc
- (源码)基于Pytorch的CenterNet目标检测模型实现.zip
- 完成Java面向对象程序设计方案实验课的心得体会.doc
- 中职计算机蓝领人才培养的思考与探索.docx
- 海外工程项目管理面临的挑战与对策.docx
- 基于智慧城市的快递寄件系统研究.docx
- 人工智能改善生活.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
