You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
157 lines
7.6 KiB
Java
157 lines
7.6 KiB
Java
|
1 year ago
|
package com.sztzjy.linkCommerce.controller.stu;
|
||
|
|
|
||
|
|
import com.sztzjy.linkCommerce.annotation.AnonymousAccess;
|
||
|
|
import com.sztzjy.linkCommerce.config.Constant;
|
||
|
1 year ago
|
import com.sztzjy.linkCommerce.entity.*;
|
||
|
1 year ago
|
import com.sztzjy.linkCommerce.entity.scoreDTO.StuModuleDTO;
|
||
|
1 year ago
|
import com.sztzjy.linkCommerce.mapper.StuCountMapper;
|
||
|
1 year ago
|
import com.sztzjy.linkCommerce.mapper.StuStudyTimeMapper;
|
||
|
|
import com.sztzjy.linkCommerce.mapper.UserinfoMapper;
|
||
|
|
import com.sztzjy.linkCommerce.util.ResultEntity;
|
||
|
|
import io.swagger.annotations.Api;
|
||
|
|
import io.swagger.annotations.ApiOperation;
|
||
|
|
import io.swagger.annotations.ApiParam;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.http.HttpStatus;
|
||
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
||
|
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.UUID;
|
||
|
|
|
||
|
1 year ago
|
@Api(tags = "学习时间、访问次数相关")
|
||
|
1 year ago
|
@RequestMapping("api/studyTime")
|
||
|
|
@RestController
|
||
|
1 year ago
|
public class StudyTimeAndCountController {
|
||
|
1 year ago
|
@Autowired
|
||
|
|
StuStudyTimeMapper stuStudyTimeMapper;
|
||
|
|
@Autowired
|
||
|
|
UserinfoMapper userinfoMapper;
|
||
|
1 year ago
|
@Autowired
|
||
|
|
StuCountMapper stuCountMapper;
|
||
|
1 year ago
|
|
||
|
|
@PostMapping("/updateStudyTime")
|
||
|
|
@ApiOperation("更新学习时间")
|
||
|
|
@AnonymousAccess
|
||
|
|
public ResultEntity<StuModuleDTO> updateStudyTime(@RequestParam String userId, @RequestParam @ApiParam("项目名称 市场需求挖掘、产品规划") String projectName, @RequestParam int time) {
|
||
|
|
//先查询有无这个对象 没有则新增对象
|
||
|
|
StuStudyTimeExample stuStudyTimeExample = new StuStudyTimeExample();
|
||
|
|
stuStudyTimeExample.createCriteria().andUserIdEqualTo(userId);
|
||
|
|
List<StuStudyTime> stuStudyTimes = stuStudyTimeMapper.selectByExample(stuStudyTimeExample);
|
||
|
1 year ago
|
int insert = 0;
|
||
|
1 year ago
|
if (stuStudyTimes.isEmpty() || stuStudyTimes == null) {
|
||
|
|
Userinfo userinfo = userinfoMapper.selectByPrimaryKey(userId);
|
||
|
|
StuStudyTime stuStudyTime = new StuStudyTime();
|
||
|
|
stuStudyTime.setId(UUID.randomUUID().toString());
|
||
|
|
stuStudyTime.setSchoolId(userinfo.getSchoolId());
|
||
|
|
stuStudyTime.setUserId(userId);
|
||
|
|
stuStudyTime.setName(userinfo.getName());
|
||
|
|
stuStudyTime.setSchoolClassId(userinfo.getSchoolClassId());
|
||
|
|
stuStudyTime.setClassName(userinfo.getClassName());
|
||
|
|
stuStudyTime.setMarketResearchTime(0);
|
||
|
|
stuStudyTime.setProductEvaluationTime(0);
|
||
|
|
stuStudyTime.setProductLaunchTestTime(0);
|
||
|
|
stuStudyTime.setProductPlanningTime(0);
|
||
|
|
stuStudyTime.setSupplyChannelTime(0);
|
||
|
|
if (Constant.PRO_SCXQWJ.equals(projectName)) {
|
||
|
|
stuStudyTime.setMarketResearchTime(time);
|
||
|
|
} else if (Constant.PRO_CPGH.equals(projectName)) {
|
||
|
|
stuStudyTime.setProductPlanningTime(time);
|
||
|
1 year ago
|
} else if (Constant.PRO_CPTFCS.equals(projectName)) {
|
||
|
1 year ago
|
stuStudyTime.setProductLaunchTestTime(time);
|
||
|
1 year ago
|
} else if (Constant.PRO_GYQDGL.equals(projectName)) {
|
||
|
1 year ago
|
stuStudyTime.setSupplyChannelTime(time);
|
||
|
1 year ago
|
} else if (Constant.PRO_CPPGYKH.equals(projectName)) {
|
||
|
1 year ago
|
stuStudyTime.setProductEvaluationTime(time);
|
||
|
|
}
|
||
|
|
insert = stuStudyTimeMapper.insert(stuStudyTime);
|
||
|
1 year ago
|
} else {
|
||
|
1 year ago
|
StuStudyTime stuStudyTime = stuStudyTimes.get(0);
|
||
|
|
if (Constant.PRO_SCXQWJ.equals(projectName)) {
|
||
|
1 year ago
|
stuStudyTime.setMarketResearchTime(stuStudyTime.getMarketResearchTime() + time);
|
||
|
1 year ago
|
} else if (Constant.PRO_CPGH.equals(projectName)) {
|
||
|
1 year ago
|
stuStudyTime.setProductPlanningTime(stuStudyTime.getProductPlanningTime() + time);
|
||
|
|
} else if (Constant.PRO_CPTFCS.equals(projectName)) {
|
||
|
|
stuStudyTime.setProductLaunchTestTime(stuStudyTime.getProductLaunchTestTime() + time);
|
||
|
|
} else if (Constant.PRO_GYQDGL.equals(projectName)) {
|
||
|
|
stuStudyTime.setSupplyChannelTime(stuStudyTime.getSupplyChannelTime() + time);
|
||
|
|
} else if (Constant.PRO_CPPGYKH.equals(projectName)) {
|
||
|
|
stuStudyTime.setProductEvaluationTime(stuStudyTime.getProductEvaluationTime() + time);
|
||
|
1 year ago
|
}
|
||
|
|
insert = stuStudyTimeMapper.updateByPrimaryKey(stuStudyTime);
|
||
|
|
}
|
||
|
1 year ago
|
if (insert == 1) {
|
||
|
1 year ago
|
return new ResultEntity<>(HttpStatus.OK, "更新学习时间成功");
|
||
|
1 year ago
|
} else {
|
||
|
1 year ago
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "更新学习时间失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("/selectStudyTime")
|
||
|
|
@ApiOperation("查看学习时间")
|
||
|
|
@AnonymousAccess
|
||
|
1 year ago
|
public ResultEntity<StuStudyTime> selectStudyTime(@RequestParam String userId) {
|
||
|
1 year ago
|
StuStudyTimeExample stuStudyTimeExample = new StuStudyTimeExample();
|
||
|
|
stuStudyTimeExample.createCriteria().andUserIdEqualTo(userId);
|
||
|
|
List<StuStudyTime> stuStudyTimes = stuStudyTimeMapper.selectByExample(stuStudyTimeExample);
|
||
|
|
if (stuStudyTimes.isEmpty() || stuStudyTimes == null) {
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "暂无学习时间");
|
||
|
1 year ago
|
} else {
|
||
|
1 year ago
|
StuStudyTime stuStudyTime = stuStudyTimes.get(0);
|
||
|
1 year ago
|
return new ResultEntity<>(HttpStatus.OK, "查看学习时间成功", stuStudyTime);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
@PostMapping("/updateStudyCount")
|
||
|
|
@ApiOperation("更新访问次数")
|
||
|
|
@AnonymousAccess
|
||
|
|
public ResultEntity updateStudyCount(@RequestParam String userId,@RequestParam String classId,@RequestParam String schoolId, @RequestParam @ApiParam("项目名称 市场需求挖掘、产品规划") String projectName) {
|
||
|
|
//先查询stucount表是否存在
|
||
|
|
StuCountExample stuCountExample = new StuCountExample();
|
||
|
|
stuCountExample.createCriteria().andUserIdEqualTo(userId).andProjectEqualTo(projectName);
|
||
|
|
List<StuCount> stuCounts = stuCountMapper.selectByExample(stuCountExample);
|
||
|
|
if(stuCounts.isEmpty() || stuCounts==null){
|
||
|
|
StuCount stuCount = new StuCount();
|
||
|
|
stuCount.setId(UUID.randomUUID().toString());
|
||
|
|
stuCount.setUserId(userId);
|
||
|
|
stuCount.setVisitCount(1);
|
||
|
|
stuCount.setClassId(classId);
|
||
|
|
stuCount.setProject(projectName);
|
||
|
|
stuCount.setSchoolId(schoolId);
|
||
|
|
int insert = stuCountMapper.insert(stuCount);
|
||
|
|
if(insert==1){
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "更新成功");
|
||
|
|
}else {
|
||
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "更新失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
StuCount stuCount = stuCounts.get(0);
|
||
|
|
stuCount.setVisitCount(stuCount.getVisitCount()+1);
|
||
|
|
int insert = stuCountMapper.updateByPrimaryKey(stuCount);
|
||
|
|
if(insert==1){
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "更新成功");
|
||
|
|
}else {
|
||
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "更新失败");
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("/selectStuCount")
|
||
|
|
@ApiOperation("查询学生项目访问次数")
|
||
|
|
@AnonymousAccess
|
||
|
|
public ResultEntity<List<StuCount>> selectStuCount(@RequestParam String userId, @RequestParam String schoolId) {
|
||
|
|
StuCountExample stuCountExample = new StuCountExample();
|
||
|
|
stuCountExample.createCriteria().andUserIdEqualTo(userId);
|
||
|
|
List<StuCount> stuCounts = stuCountMapper.selectByExample(stuCountExample);
|
||
|
|
if(stuCounts.isEmpty() || stuCounts==null){
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "暂无数据");
|
||
|
|
}else {
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "查询成功",stuCounts);
|
||
|
1 year ago
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|