From b70f8c70c1f4ceafc96858ec59c7d9ac1dec2373 Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Tue, 16 Apr 2024 17:21:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E5=92=8Cmapper=20xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/stu/StuIndexController.java | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuIndexController.java diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuIndexController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuIndexController.java new file mode 100644 index 0000000..79373d8 --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuIndexController.java @@ -0,0 +1,157 @@ +package com.sztzjy.financial_bigdata.controller.stu; + +import com.sztzjy.financial_bigdata.annotation.AnonymousAccess; +import com.sztzjy.financial_bigdata.config.Constant; +import com.sztzjy.financial_bigdata.entity.*; +import com.sztzjy.financial_bigdata.entity.stu_dto.StuUserDto; +import com.sztzjy.financial_bigdata.mapper.*; +import com.sztzjy.financial_bigdata.util.ResultEntity; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.apache.commons.lang3.StringUtils; +import org.geolatte.geom.M; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author xcj + * @Date 2024/4/12 + */ +@RestController +@Api(tags = "学生端--首页") +@RequestMapping("api/stu/index") +public class StuIndexController { + @Autowired + private StuUserMapper stuUserMapper; + @Autowired + private SysLoginLogMapper sysLoginLogMapper; + @Autowired + private SysCourseMapper sysCourseMapper; + @Autowired + private SysObjectiveQuestionMapper sysObjectiveQuestionMapper; + @Autowired + private StuStudentExamMapper studentExamMapper; + @Autowired + private TeaExamManageMapper teaExamManageMapper; + @Autowired + private SysResourceDataMapper sysResourceDataMapper; + + @AnonymousAccess + @ApiOperation("课程数据展示") + @PostMapping("getIndexCourse") + public ResultEntity> getIndexCourse(@RequestParam String schoolId) { + SysCourseExample sysCourseExample = new SysCourseExample(); + List list = new ArrayList<>(); + list.add(schoolId); + list.add(Constant.BUILT_IN_SCHOOL_ID); + sysCourseExample.createCriteria().andSchoolIdIn(list); + List sysCourses = sysCourseMapper.selectByExample(sysCourseExample); + return new ResultEntity<>(sysCourses); + } + + + @AnonymousAccess + @ApiOperation("理论考试数据,按顺序依次为单选,多选,判断") + @PostMapping("getIndexTheoryTest") + public ResultEntity> getIndexTheoryTest(@RequestParam String schoolId) { + return new ResultEntity>(sysObjectiveQuestionMapper.getIndexTheoryTest(schoolId)); + } + + @AnonymousAccess + @ApiOperation("实战考核数据") + @PostMapping("getTrainingTest") + public ResultEntity> getTrainingTest(@RequestParam String userId) { + StuStudentExamExample example = new StuStudentExamExample(); + example.createCriteria().andUseridEqualTo(userId); + List stuStudentExamWithBLOBs = studentExamMapper.selectByExampleWithBLOBs(example); + Map map = new HashMap<>(); + if (stuStudentExamWithBLOBs.isEmpty()) { + return new ResultEntity<>(map); + } + List list = new ArrayList<>(); + for (StuStudentExamWithBLOBs stuStudentExamWithBLOB : stuStudentExamWithBLOBs) { + list.add(stuStudentExamWithBLOB.getExamManageId()); + } + for (String s : list) { + TeaExamManageWithBLOBs teaExamManageWithBLOBs = teaExamManageMapper.selectByPrimaryKey(s); + map.put(teaExamManageWithBLOBs.getExamManageId(), teaExamManageWithBLOBs.getExamName()); + } + return new ResultEntity<>(map); + } + + @AnonymousAccess + @ApiOperation("资源中心数据") + @PostMapping("getIndexResourceCenter") + public ResultEntity> getIndexResourceCenter(@RequestParam String schoolId) { + Map map = new HashMap<>(); + SysResourceDataExample example = new SysResourceDataExample(); + List idlist = new ArrayList<>(); + idlist.add(schoolId); + idlist.add(Constant.BUILT_IN_SCHOOL_ID); + example.createCriteria().andSchoolIdIn(idlist); + List sysResourceData = sysResourceDataMapper.selectByExample(example); + int size = sysResourceData.size(); + map.put("资源总量", size); + int videoNum = 0; + for (SysResourceData sysResourceDatum : sysResourceData) { + String resourceName = sysResourceDatum.getResourceName(); + if (resourceName.contains(".mp4") || resourceName.contains(".AVI") || resourceName.contains(".WMV")) { + videoNum++; + } + } + map.put("视频数量", videoNum); + map.put("课件数量", size - videoNum); + return new ResultEntity<>(map); + } + + + @AnonymousAccess + @ApiOperation("个人中心--展示") + @PostMapping("getPersonalCenterInfo") + public ResultEntity getPersonalCenterInfo(@RequestParam String userId) { + StuUser stuUser = stuUserMapper.selectByPrimaryKey(userId); + SysLoginLogExample sysLoginLogExample = new SysLoginLogExample(); + sysLoginLogExample.createCriteria().andUseridEqualTo(stuUser.getUserid()); + List sysLoginLogs = sysLoginLogMapper.selectByExample(sysLoginLogExample); + StuUserDto stuUserDto = new StuUserDto(); + BeanUtils.copyProperties(stuUser, stuUserDto); + stuUserDto.setIpPlace(sysLoginLogs.get(0).getIpAddress()); + stuUserDto.setLastIP(sysLoginLogs.get(0).getLoginIp()); + return new ResultEntity(stuUserDto); + } + + @AnonymousAccess + @ApiOperation("个人中心--编辑") + @PostMapping("updatePersonalCenterInfo") //技能不要了 + public ResultEntity updatePersonalCenterInfo(@RequestParam String userId, + @RequestParam(required = false) String phone, + @RequestParam(required = false) String email) { + if (StringUtils.isBlank(phone) && StringUtils.isBlank(email)) { + return new ResultEntity(HttpStatus.BAD_REQUEST, "请输入要编辑的内容"); + } + StuUser stuUser = stuUserMapper.selectByPrimaryKey(userId); + if (StringUtils.isNotBlank(phone)) { + stuUser.setPhone(phone); + } + if (StringUtils.isNotBlank(email)) { + stuUser.setEmail(email); + } + stuUserMapper.updateByPrimaryKey(stuUser); + return new ResultEntity(HttpStatus.OK, "编辑成功"); + } + + @AnonymousAccess + @ApiOperation("学习数据统计分析") + @PostMapping("learnDataCountAnalysis") + public ResultEntity learnDataCountAnalysis(@ApiParam @RequestBody(required = false) SysLoginLog loginDTO) { + return null; + } +}