Browse Source

成绩接口修改

小么熊🐻 2 years ago
parent
commit
4e9c9a20d1

+ 1 - 1
jpcj-admin/src/main/java/com/miaxis/JpcjApplication.java

@@ -21,7 +21,7 @@ public class JpcjApplication
     {
         // System.setProperty("spring.devtools.restart.enabled", "false");
         SpringApplication.run(JpcjApplication.class, args);
-        System.out.println(" 金牌车教!  发车!  \n") ;
+        System.out.println(" 金牌车教,已启动!~  \n") ;
 
     }
 }

+ 8 - 43
jpcj-admin/src/main/java/com/miaxis/app/controller/h5/ScoreInfoController.java

@@ -44,9 +44,10 @@ public class ScoreInfoController extends BaseController {
     })
     public ResponsePageInfo<ScoreInfo> list(){
         startPage();
-        ScoreInfo scoreInfo = new ScoreInfo();
-        scoreInfo.setUserId(SecurityUtils.getLoginUser().getStudent().getId());
-        List<ScoreInfo> list = scoreInfoService.selectScoreInfoList(scoreInfo);
+        ScoreInfoUserIdDTO  scoreInfoUserIdDTO = new ScoreInfoUserIdDTO();
+        scoreInfoUserIdDTO.setUserId(SecurityUtils.getLoginUser().getStudent().getId());
+        scoreInfoUserIdDTO.setDeviceType(1);
+        List<ScoreInfo> list = scoreInfoService.selectScoreInfoList(scoreInfoUserIdDTO);
         return toResponsePageInfo(list);
     }
 
@@ -67,64 +68,25 @@ public class ScoreInfoController extends BaseController {
     /**
      * 新增模拟考成绩
      */
-    @Log(title = "模拟考成绩", businessType = BusinessTypeEnum.INSERT)
     @PostMapping
     @ApiOperation("新增模拟考成绩")
     public Response<Integer> add(@RequestBody ScoreInfoDTO scoreInfoDTO){
         ScoreInfo scoreInfo = new ScoreInfo();
         BeanUtils.copyProperties(scoreInfoDTO,scoreInfo);
         scoreInfo.setUserId(SecurityUtils.getLoginUser().getStudent().getId());
+        scoreInfo.setDeviceType(1);
         return toResponse(scoreInfoService.save(scoreInfo) ? 1 : 0);
     }
 
     /**
      * 修改模拟考成绩
      */
-    @Log(title = "模拟考成绩", businessType = BusinessTypeEnum.UPDATE)
     @PutMapping
     @ApiOperation("修改模拟考成绩")
     public Response<Integer> edit(@RequestBody ScoreInfo scoreInfo){
         return toResponse(scoreInfoService.updateById(scoreInfo) ? 1 : 0);
     }
 
-    /**
-     * 删除模拟考成绩
-     */
-//    @Log(title = "模拟考成绩", businessType = BusinessTypeEnum.DELETE)
-//	@DeleteMapping("/{ids}")
-//    @ApiOperation("删除模拟考成绩")
-//    public Response<Integer> remove(
-//            @ApiParam(name = "ids", value = "模拟考成绩ids参数", required = true)
-//            @PathVariable Long[] ids
-//    ){
-//        return toResponse(scoreInfoService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
-//    }
-
-
-    /**
-     * 获取预测成功
-     */
-//    @GetMapping(value = "/forecastScore")
-//    @ApiOperation("获取预测成绩")
-//    public Response<Integer> getInfo(){
-//        ScoreInfo scoreInfo = new ScoreInfo();
-//        scoreInfo.setUserId(SecurityUtils.getLoginUser().getStudent().getId());
-//        int forecastScore = scoreInfoService.getForecastScore(scoreInfo);
-//        return Response.success(forecastScore);
-//    }
-
-
-    /**
-     * 获取预测成功
-     */
-//    @GetMapping(value = "/avgScore")
-//    @ApiOperation("获取平均成绩")
-//    public Response<Integer> getAvgScore(){
-//        ScoreInfo scoreInfo = new ScoreInfo();
-//        scoreInfo.setUserId(SecurityUtils.getLoginUser().getStudent().getId());
-//        int aveScore = scoreInfoService.getAveScore(scoreInfo);
-//        return Response.success(aveScore);
-//    }
 
 
 
@@ -136,6 +98,7 @@ public class ScoreInfoController extends BaseController {
     public Response<ScoreInfoAllDTO> getScoreInfoAll(){
         ScoreInfo scoreInfo = new ScoreInfo();
         scoreInfo.setUserId(SecurityUtils.getLoginUser().getStudent().getId());
+        scoreInfo.setDeviceType(1);
         ScoreInfoAllDTO scoreInfoAllDTO = scoreInfoService.getScoreInfoAll(scoreInfo);
         return Response.success(scoreInfoAllDTO);
     }
@@ -146,6 +109,7 @@ public class ScoreInfoController extends BaseController {
     @GetMapping(value = "/getScoreInfoByUserId")
     @ApiOperation("根据用户ID获取列表")
     public Response<List<ScoreInfoH5Vo>> getScoreInfoByUserId(ScoreInfoUserIdDTO scoreInfoUserIdDTO){
+        scoreInfoUserIdDTO.setDeviceType(1);
         List<ScoreInfoH5Vo> list = scoreInfoService.getScoreInfoByUserId(scoreInfoUserIdDTO);
         return Response.success(list);
     }
@@ -158,6 +122,7 @@ public class ScoreInfoController extends BaseController {
     public Response<ScoreInfoAllDTO> getScoreInfoAllByUserId(ScoreInfoUserIdDTO scoreInfoUserIdDTO){
         ScoreInfo scoreInfo = new ScoreInfo();
         scoreInfo.setUserId(scoreInfoUserIdDTO.getUserId());
+        scoreInfo.setDeviceType(1);
         ScoreInfoAllDTO scoreInfoAllDTO = scoreInfoService.getScoreInfoAll(scoreInfo);
         return Response.success(scoreInfoAllDTO);
     }

+ 1 - 1
jpcj-admin/src/main/java/com/miaxis/pc/controller/question/PcQuestionWrongController.java

@@ -52,7 +52,7 @@ public class PcQuestionWrongController extends BaseController {
         }
         QuestionWrong questionWrong = new QuestionWrong();
         BeanUtils.copyProperties(questionWrongDTO, questionWrong);
-        questionWrong.setUserId(SecurityUtils.getLoginUser().getStudent().getId());
+        questionWrong.setUserId(SecurityUtils.getLoginUser().getUser().getUserId());
         questionWrong.setDeviceType(2);
         return toResponse(questionWrongService.save(questionWrong) ? 1 : 0);
     }

+ 49 - 44
jpcj-admin/src/main/java/com/miaxis/pc/controller/question/PcScoreInfoController.java

@@ -11,12 +11,14 @@ import com.miaxis.common.enums.BusinessTypeEnum;
 import com.miaxis.common.utils.SecurityUtils;
 import com.miaxis.score.domain.ScoreInfo;
 import com.miaxis.score.dto.ScoreInfoAllDTO;
+import com.miaxis.score.dto.ScoreInfoDTO;
 import com.miaxis.score.dto.ScoreInfoPcDTO;
 import com.miaxis.score.dto.ScoreInfoUserIdDTO;
 import com.miaxis.score.service.IScoreInfoService;
 import com.miaxis.score.vo.ScoreIStudentInfoPcVo;
 import com.miaxis.user.service.IUserInfoService;
 import io.swagger.annotations.*;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -31,7 +33,7 @@ import java.util.List;
  */
 @RestController
 @RequestMapping("score/info")
-@Api(tags={"【PC-模拟考成绩】"})
+@Api(tags = {"【PC-模拟考成绩】"})
 public class PcScoreInfoController extends BaseController {
     @Autowired
     private IScoreInfoService scoreInfoService;
@@ -40,20 +42,37 @@ public class PcScoreInfoController extends BaseController {
     @Autowired
     private IUserInfoService userInfoService;
 
-//    /**
-//     * 查询模拟考成绩列表
-//     */
-//    @GetMapping("/list")
-//    @ApiOperation("查询模拟考成绩列表")
-//    @ApiImplicitParams({
-//            @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
-//            @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
-//    })
-//    public ResponsePageInfo<ScoreInfoPcVo> list(@ModelAttribute ScoreInfoPcDTO scoreInfoPcDTO){
-//        startPage();
-//        List<ScoreInfoPcVo> list = scoreInfoService.selectScoreInfoPcList(scoreInfoPcDTO);
-//        return toResponsePageInfo(list);
-//    }
+    /**
+     * 根据当前用户查询模拟考成绩列表
+     */
+    @GetMapping("/list")
+    @ApiOperation("查询模拟考成绩列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
+            @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
+    })
+    public ResponsePageInfo<ScoreInfo> list(){
+        startPage();
+        ScoreInfoUserIdDTO  scoreInfoUserIdDTO = new ScoreInfoUserIdDTO();
+        scoreInfoUserIdDTO.setUserId(SecurityUtils.getLoginUser().getUser().getUserId());
+        scoreInfoUserIdDTO.setDeviceType(2);
+        List<ScoreInfo> list = scoreInfoService.selectScoreInfoList(scoreInfoUserIdDTO);
+        return toResponsePageInfo(list);
+    }
+
+
+    /**
+     * 新增模拟考成绩
+     */
+    @PostMapping
+    @ApiOperation("新增模拟考成绩")
+    public Response<Integer> add(@RequestBody ScoreInfoDTO scoreInfoDTO) {
+        ScoreInfo scoreInfo = new ScoreInfo();
+        BeanUtils.copyProperties(scoreInfoDTO, scoreInfo);
+        scoreInfo.setUserId(SecurityUtils.getLoginUser().getUser().getUserId());
+        scoreInfo.setDeviceType(2);
+        return toResponse(scoreInfoService.save(scoreInfo) ? 1 : 0);
+    }
 
 
     /**
@@ -62,21 +81,21 @@ public class PcScoreInfoController extends BaseController {
     @GetMapping("/studentlist")
     @ApiOperation("查询驾校学员列表")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
-            @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
+            @ApiImplicitParam(name = "pageNum", value = "当前页码", dataType = "int", paramType = "query", required = false),
+            @ApiImplicitParam(name = "pageSize", value = "每页数据量", dataType = "int", paramType = "query", required = false),
     })
-    public ResponsePageInfo<ScoreIStudentInfoPcVo> studentList(@ModelAttribute ScoreInfoPcDTO scoreInfoPcDTO){
+    public ResponsePageInfo<ScoreIStudentInfoPcVo> studentList(@ModelAttribute ScoreInfoPcDTO scoreInfoPcDTO) {
         startPage();
         //判断该用户是否拥有amin或者manager角色
         SysUser user = SecurityUtils.getLoginUser().getUser();
         List<SysRole> roles = user.getRoles();
         Boolean hasAdminAuthority = false;
-        for (SysRole sysRole : roles){
-            if (sysRole.getRoleKey().equals("admin") || sysRole.getRoleKey().equals("manager")){
-                hasAdminAuthority =true;
+        for (SysRole sysRole : roles) {
+            if (sysRole.getRoleKey().equals("admin") || sysRole.getRoleKey().equals("manager")) {
+                hasAdminAuthority = true;
             }
         }
-        if (!hasAdminAuthority){
+        if (!hasAdminAuthority) {
             scoreInfoPcDTO.setSchoolName(user.getNickName());
         }
         List<ScoreIStudentInfoPcVo> list = scoreInfoService.selectStudentList(scoreInfoPcDTO);
@@ -89,50 +108,36 @@ public class PcScoreInfoController extends BaseController {
     @GetMapping("/studentscore/{userId}")
     @ApiOperation("查询学员成绩")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
-            @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
+            @ApiImplicitParam(name = "pageNum", value = "当前页码", dataType = "int", paramType = "query", required = false),
+            @ApiImplicitParam(name = "pageSize", value = "每页数据量", dataType = "int", paramType = "query", required = false),
     })
-    public ResponsePageInfo<ScoreInfo> studentscore( @PathVariable("userId") Long userId){
+    public ResponsePageInfo<ScoreInfo> studentscore(@PathVariable("userId") Long userId) {
         startPage();
-        List<ScoreInfo> list = scoreInfoService.list(new QueryWrapper<ScoreInfo>().eq("user_id",userId).orderByDesc("create_time"));
+        List<ScoreInfo> list = scoreInfoService.list(new QueryWrapper<ScoreInfo>().eq("user_id", userId)
+                                                        .eq("device_type",2).orderByDesc("create_time"));
         return toResponsePageInfo(list);
     }
 
 
-
-
-
-    /**
-     * 修改模拟考成绩
-     */
-    @Log(title = "模拟考成绩", businessType = BusinessTypeEnum.UPDATE)
-    @PutMapping
-    @ApiOperation("修改模拟考成绩")
-    public Response<Integer> edit(@RequestBody ScoreInfo scoreInfo){
-        return toResponse(scoreInfoService.updateById(scoreInfo) ? 1 : 0);
-    }
-
     /**
      * 删除模拟考成绩
      */
-    @Log(title = "模拟考成绩", businessType = BusinessTypeEnum.DELETE)
-	@DeleteMapping("/{ids}")
+    @DeleteMapping("/{ids}")
     @ApiOperation("删除模拟考成绩")
     public Response<Integer> remove(
             @ApiParam(name = "ids", value = "模拟考成绩ids参数", required = true)
             @PathVariable Long[] ids
-    ){
+    ) {
         return toResponse(scoreInfoService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
     }
 
 
-
     /**
      * 根据userID获取最大成绩,平均成绩,预测成绩
      */
     @GetMapping(value = "/getScoreInfoAllByUserId")
     @ApiOperation("根据userID获取最大成绩,平均成绩,预测成绩")
-    public Response<ScoreInfoAllDTO> getScoreInfoAllByUserId(ScoreInfoUserIdDTO scoreInfoUserIdDTO){
+    public Response<ScoreInfoAllDTO> getScoreInfoAllByUserId(ScoreInfoUserIdDTO scoreInfoUserIdDTO) {
         ScoreInfo scoreInfo = new ScoreInfo();
         scoreInfo.setUserId(scoreInfoUserIdDTO.getUserId());
         ScoreInfoAllDTO scoreInfoAllDTO = scoreInfoService.getScoreInfoAll(scoreInfo);

+ 5 - 44
jpcj-service/src/main/java/com/miaxis/score/domain/ScoreInfo.java

@@ -52,52 +52,13 @@ public class ScoreInfo extends BaseBusinessEntity {
     @ApiModelProperty(value = "分数")
     private Long score;
 
-    public void setId(Long id){
-        this.id = id;
-    }
 
-    public Long getId(){
-        return id;
-    }
-    public void setUserId(Long userId){
-        this.userId = userId;
-    }
+    /** 终端类型 1:H5  2:PC端 */
+    @Excel(name = "终端类型 1:H5  2:PC端")
+    @TableField("device_type")
+    @ApiModelProperty(value = "终端类型 1:H5  2:PC端")
+    private Integer deviceType;
 
-    public Long getUserId(){
-        return userId;
-    }
-    public void setType(String type){
-        this.type = type;
-    }
 
-    public String getType(){
-        return type;
-    }
-    public void setKskm(String kskm){
-        this.kskm = kskm;
-    }
 
-    public String getKskm(){
-        return kskm;
-    }
-    public void setScore(Long score){
-        this.score = score;
-    }
-
-    public Long getScore(){
-        return score;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
-            .append("userId", getUserId())
-            .append("type", getType())
-            .append("kskm", getKskm())
-            .append("score", getScore())
-            .append("createTime", getCreateTime())
-            .append("updateTime", getUpdateTime())
-            .toString();
-    }
 }

+ 6 - 2
jpcj-service/src/main/java/com/miaxis/score/dto/ScoreInfoUserIdDTO.java

@@ -14,9 +14,13 @@ public class ScoreInfoUserIdDTO {
     private static final long serialVersionUID = 1L;
 
 
-    /** 用户id */
+    /**
+     * 用户id
+     */
     @ApiModelProperty(value = "用户ID")
     private Long userId;
 
-
+    @ApiModelProperty(value = "终端类型 1:H5  2:PC端")
+    private Integer deviceType;
 }
+

+ 2 - 2
jpcj-service/src/main/java/com/miaxis/score/mapper/ScoreInfoMapper.java

@@ -20,10 +20,10 @@ public interface ScoreInfoMapper extends BaseMapper<ScoreInfo> {
     /**
      * 查询模拟考成绩列表
      *
-     * @param scoreInfo 模拟考成绩
+     * @param scoreInfoUserIdDTO 模拟考成绩
      * @return 模拟考成绩集合
      */
-    public List<ScoreInfo> selectScoreInfoList(ScoreInfo scoreInfo);
+    public List<ScoreInfo> selectScoreInfoList(ScoreInfoUserIdDTO scoreInfoUserIdDTO);
 
 
     /**

+ 2 - 2
jpcj-service/src/main/java/com/miaxis/score/service/IScoreInfoService.java

@@ -21,10 +21,10 @@ public interface IScoreInfoService extends IService<ScoreInfo>{
     /**
      * 查询模拟考成绩列表
      *
-     * @param scoreInfo 模拟考成绩
+     * @param scoreInfoUserIdDTO 模拟考成绩
      * @return 模拟考成绩集合
      */
-    public List<ScoreInfo> selectScoreInfoList(ScoreInfo scoreInfo);
+    public List<ScoreInfo> selectScoreInfoList(ScoreInfoUserIdDTO scoreInfoUserIdDTO);
 
     /**
      * 查询模拟考试平均成绩

+ 3 - 3
jpcj-service/src/main/java/com/miaxis/score/service/impl/ScoreInfoServiceImpl.java

@@ -29,12 +29,12 @@ public class ScoreInfoServiceImpl extends ServiceImpl<ScoreInfoMapper, ScoreInfo
     /**
      * 查询模拟考成绩列表
      *
-     * @param scoreInfo 模拟考成绩
+     * @param scoreInfoUserIdDTO 模拟考成绩
      * @return 模拟考成绩
      */
     @Override
-    public List<ScoreInfo> selectScoreInfoList(ScoreInfo scoreInfo){
-        return scoreInfoMapper.selectScoreInfoList(scoreInfo);
+    public List<ScoreInfo> selectScoreInfoList(ScoreInfoUserIdDTO scoreInfoUserIdDTO){
+        return scoreInfoMapper.selectScoreInfoList(scoreInfoUserIdDTO);
     }
 
     @Override

+ 8 - 1
jpcj-service/src/main/resources/mapper/score/ScoreInfoMapper.xml

@@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="type"    column="type"    />
         <result property="kskm"    column="kskm"    />
         <result property="score"    column="score"    />
+        <result property="deviceType"    column="device_type"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateTime"    column="update_time"    />
     </resultMap>
@@ -23,6 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="type"    column="type"    />
         <result property="kskm"    column="kskm"    />
         <result property="score"    column="score"    />
+        <result property="deviceType"    column="device_type"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateTime"    column="update_time"    />
     </resultMap>
@@ -32,13 +34,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select * from score_info
     </sql>
 
-    <select id="selectScoreInfoList" parameterType="ScoreInfo" resultMap="ScoreInfoResult">
+    <select id="selectScoreInfoList" parameterType="com.miaxis.score.dto.ScoreInfoUserIdDTO" resultMap="ScoreInfoResult">
         <include refid="selectScoreInfoVo"/>
         <where>
             <if test="userId != null "> and user_id = #{userId}</if>
             <if test="type != null  and type != ''"> and type = #{type}</if>
             <if test="kskm != null  and kskm != ''"> and kskm = #{kskm}</if>
             <if test="score != null "> and score = #{score}</if>
+            <if test="deviceType != null  "> and device_type = #{deviceType}</if>
         </where>
     </select>
 
@@ -48,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         (select score from score_info s
         <where>
             <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="deviceType != null  "> and device_type = #{deviceType}</if>
         </where>
         order by id desc limit 0,10) x order by score
     </select>
@@ -56,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select IFNULL(ROUND(avg(score),0),0) from score_info s
         <where>
             <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="deviceType != null  "> and device_type = #{deviceType}</if>
         </where>
     </select>
 
@@ -65,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select IFNULL(max(score),0) from score_info s
         <where>
             <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="deviceType != null  "> and device_type = #{deviceType}</if>
         </where>
     </select>
 
@@ -87,6 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     FROM user_info u JOIN score_info s ON u.id = s.user_id
     <where>
         <if test="userId != null"> and s.user_id =  #{userId} </if>
+        <if test="deviceType != null  "> and device_type = #{deviceType}</if>
     </where>
     order by user_id,create_time desc
 </select>