自动生成配置文件和mapper xml
parent
2c6a529e1b
commit
b70f8c70c1
@ -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<List<SysCourse>> getIndexCourse(@RequestParam String schoolId) {
|
||||
SysCourseExample sysCourseExample = new SysCourseExample();
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(schoolId);
|
||||
list.add(Constant.BUILT_IN_SCHOOL_ID);
|
||||
sysCourseExample.createCriteria().andSchoolIdIn(list);
|
||||
List<SysCourse> sysCourses = sysCourseMapper.selectByExample(sysCourseExample);
|
||||
return new ResultEntity<>(sysCourses);
|
||||
}
|
||||
|
||||
|
||||
@AnonymousAccess
|
||||
@ApiOperation("理论考试数据,按顺序依次为单选,多选,判断")
|
||||
@PostMapping("getIndexTheoryTest")
|
||||
public ResultEntity<List<Integer>> getIndexTheoryTest(@RequestParam String schoolId) {
|
||||
return new ResultEntity<List<Integer>>(sysObjectiveQuestionMapper.getIndexTheoryTest(schoolId));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
@ApiOperation("实战考核数据")
|
||||
@PostMapping("getTrainingTest")
|
||||
public ResultEntity<Map<String, String>> getTrainingTest(@RequestParam String userId) {
|
||||
StuStudentExamExample example = new StuStudentExamExample();
|
||||
example.createCriteria().andUseridEqualTo(userId);
|
||||
List<StuStudentExamWithBLOBs> stuStudentExamWithBLOBs = studentExamMapper.selectByExampleWithBLOBs(example);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (stuStudentExamWithBLOBs.isEmpty()) {
|
||||
return new ResultEntity<>(map);
|
||||
}
|
||||
List<String> 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<Map<String, Integer>> getIndexResourceCenter(@RequestParam String schoolId) {
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
SysResourceDataExample example = new SysResourceDataExample();
|
||||
List<String> idlist = new ArrayList<>();
|
||||
idlist.add(schoolId);
|
||||
idlist.add(Constant.BUILT_IN_SCHOOL_ID);
|
||||
example.createCriteria().andSchoolIdIn(idlist);
|
||||
List<SysResourceData> 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<StuUserDto> getPersonalCenterInfo(@RequestParam String userId) {
|
||||
StuUser stuUser = stuUserMapper.selectByPrimaryKey(userId);
|
||||
SysLoginLogExample sysLoginLogExample = new SysLoginLogExample();
|
||||
sysLoginLogExample.createCriteria().andUseridEqualTo(stuUser.getUserid());
|
||||
List<SysLoginLog> 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>(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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue