Просмотр исходного кода

Merge remote-tracking branch 'origin/dev_v2.1.0' into dev_v2.1.0

caozixuan 4 лет назад
Родитель
Сommit
e03ceca553

+ 10 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/domain/SysDomain.java

@@ -45,6 +45,16 @@ public class SysDomain implements Serializable {
 
 
     Duration sessionActive;
     Duration sessionActive;
 
 
+    String loginAuthenUrl;
+
+    public String getLoginAuthenUrl() {
+        return loginAuthenUrl;
+    }
+
+    public void setLoginAuthenUrl(String loginAuthenUrl) {
+        this.loginAuthenUrl = loginAuthenUrl;
+    }
+
     public Duration getSessionActive() {
     public Duration getSessionActive() {
         return sessionActive;
         return sessionActive;
     }
     }

+ 1 - 1
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/mapper/TBExamStudentMapper.java

@@ -91,7 +91,7 @@ public interface TBExamStudentMapper extends BaseMapper<TBExamStudent> {
      * @param courseCode
      * @param courseCode
      * @return
      * @return
      */
      */
-    List<TBExamStudentResult> selectClassList(@Param("schoolId") Long schoolId, @Param("examId") Long examId,@Param("teacherId") Long teacherId, @Param("courseCode") String courseCode);
+    List<TBExamStudentResult> selectClassList(@Param("schoolId") Long schoolId, @Param("examId") Long examId,@Param("teacherId") Long teacherId, @Param("courseCode") String courseCode, @Param("inspectCollegeId") Long inspectCollegeId);
 
 
     /**
     /**
      * 开课成绩查询
      * 开课成绩查询

+ 3 - 1
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TBExamStudentServiceImpl.java

@@ -180,7 +180,9 @@ public class TBExamStudentServiceImpl extends ServiceImpl<TBExamStudentMapper, T
      */
      */
     @Override
     @Override
     public List<TBExamStudentResult> selectClassList(Long schoolId, Long examId,Long teacherId, String courseCode) {
     public List<TBExamStudentResult> selectClassList(Long schoolId, Long examId,Long teacherId, String courseCode) {
-        return tbExamStudentMapper.selectClassList(schoolId, examId, teacherId, courseCode);
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        Long orgId = sysUser.getOrgId();
+        return tbExamStudentMapper.selectClassList(schoolId, examId, teacherId, courseCode, orgId);
     }
     }
 
 
     @Override
     @Override

+ 3 - 0
teachcloud-report-business/src/main/resources/mapper/TBExamStudentMapper.xml

@@ -130,6 +130,9 @@
             <if test="teacherId != null and teacherId != ''">
             <if test="teacherId != null and teacherId != ''">
                 and tbes.teacher_id = #{teacherId}
                 and tbes.teacher_id = #{teacherId}
             </if>
             </if>
+            <if test="inspectCollegeId != null and teacherId != ''">
+                and tbes.inspect_college_id = #{inspectCollegeId}
+            </if>
         </where>
         </where>
     </select>
     </select>
 
 

+ 24 - 20
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/SysController.java

@@ -7,6 +7,7 @@ import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.params.LoginParam;
 import com.qmth.distributed.print.business.bean.params.LoginParam;
 import com.qmth.distributed.print.business.bean.result.EditResult;
 import com.qmth.distributed.print.business.bean.result.EditResult;
+import com.qmth.distributed.print.business.entity.BasicVerifyCode;
 import com.qmth.distributed.print.business.service.BasicVerifyCodeService;
 import com.qmth.distributed.print.business.service.BasicVerifyCodeService;
 import com.qmth.distributed.print.business.service.PrintCommonService;
 import com.qmth.distributed.print.business.service.PrintCommonService;
 import com.qmth.teachcloud.common.bean.auth.AuthBean;
 import com.qmth.teachcloud.common.bean.auth.AuthBean;
@@ -82,6 +83,9 @@ public class SysController {
     @Resource
     @Resource
     TeachcloudCommonService teachcloudCommonService;
     TeachcloudCommonService teachcloudCommonService;
 
 
+    @Resource
+    SysConfigService sysConfigService;
+
     /**
     /**
      * 登录
      * 登录
      *
      *
@@ -135,26 +139,26 @@ public class SysController {
         if (Objects.nonNull(sysUser.getSchoolId()) && sysUser.getSchoolId().longValue() != basicSchool.getId().longValue()) {
         if (Objects.nonNull(sysUser.getSchoolId()) && sysUser.getSchoolId().longValue() != basicSchool.getId().longValue()) {
             throw ExceptionResultEnum.ERROR.exception("用户学校不匹配");
             throw ExceptionResultEnum.ERROR.exception("用户学校不匹配");
         }
         }
-//        校验验证码
-//        SysConfig value = sysConfigService.getByKey("sys.code.enable");
-//        if (Objects.nonNull(value) && value.getConfigValue().equals("true")) {
-//            String code = login.getCode();
-//            if (Objects.isNull(code)) {
-//                throw ExceptionResultEnum.ERROR.exception("验证码为空");
-//            }
-//            if (!dictionaryConfig.smsDomain().getSmsNormalCode().equals(code)) {
-//                QueryWrapper<BasicVerifyCode> codeWrapper = new QueryWrapper<>();
-//                codeWrapper.lambda().eq(BasicVerifyCode::getMobileNumber, sysUser.getMobileNumber()).eq(BasicVerifyCode::getUserId, sysUser.getId());
-//                BasicVerifyCode accessControl = basicVerifyCodeService.getOne(codeWrapper);
-//                if (accessControl == null || (accessControl != null && !accessControl.getVerifyCode().equals(code))) {
-//                    throw ExceptionResultEnum.ERROR.exception("短信验证码错误,请仔细核对后再次输入");
-//                }
-//
-//                if (new Date(accessControl.getExpireTime()).before(new Date())) {
-//                    throw ExceptionResultEnum.ERROR.exception("短信验证码已过期");
-//                }
-//            }
-//        }
+        //校验验证码
+        SysConfig value = sysConfigService.getByKey("sys.code.enable");
+        if (Objects.nonNull(value) && value.getConfigValue().equals("true")) {
+            String code = login.getCode();
+            if (Objects.isNull(code)) {
+                throw ExceptionResultEnum.ERROR.exception("验证码为空");
+            }
+            if (!dictionaryConfig.smsDomain().getSmsNormalCode().equals(code)) {
+                QueryWrapper<BasicVerifyCode> codeWrapper = new QueryWrapper<>();
+                codeWrapper.lambda().eq(BasicVerifyCode::getMobileNumber, sysUser.getMobileNumber()).eq(BasicVerifyCode::getUserId, sysUser.getId());
+                BasicVerifyCode accessControl = basicVerifyCodeService.getOne(codeWrapper);
+                if (accessControl == null || (accessControl != null && !accessControl.getVerifyCode().equals(code))) {
+                    throw ExceptionResultEnum.ERROR.exception("短信验证码错误,请仔细核对后再次输入");
+                }
+
+                if (new Date(accessControl.getExpireTime()).before(new Date())) {
+                    throw ExceptionResultEnum.ERROR.exception("短信验证码已过期");
+                }
+            }
+        }
         return ResultUtil.ok(teachcloudCommonService.login(login.getPassword(), sysUser));
         return ResultUtil.ok(teachcloudCommonService.login(login.getPassword(), sysUser));
     }
     }
 
 

+ 40 - 14
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/WudaOpenApiController.java

@@ -12,28 +12,32 @@ import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicSchool;
 import com.qmth.teachcloud.common.entity.BasicSchool;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
-import com.qmth.teachcloud.common.enums.RoleTypeEnum;
 import com.qmth.teachcloud.common.service.CacheService;
 import com.qmth.teachcloud.common.service.CacheService;
 import com.qmth.teachcloud.common.service.SysUserService;
 import com.qmth.teachcloud.common.service.SysUserService;
 import com.qmth.teachcloud.common.service.TeachcloudCommonService;
 import com.qmth.teachcloud.common.service.TeachcloudCommonService;
-import com.qmth.teachcloud.common.util.*;
-import com.qmth.teachcloud.report.aspect.ApiControllerAspect;
+import com.qmth.teachcloud.common.util.JacksonUtil;
+import com.qmth.teachcloud.common.util.Result;
+import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.report.business.cache.WhuUserAuthCacheUtil;
 import com.qmth.teachcloud.report.business.cache.WhuUserAuthCacheUtil;
 import io.swagger.annotations.*;
 import io.swagger.annotations.*;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
-import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
-import javax.validation.Valid;
+import javax.servlet.http.HttpSession;
 import java.io.IOException;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
 import java.security.NoSuchAlgorithmException;
 import java.security.NoSuchAlgorithmException;
 import java.text.MessageFormat;
 import java.text.MessageFormat;
-import java.util.List;
 import java.util.Objects;
 import java.util.Objects;
 
 
 @Api(tags = "武大开放接口层apiController")
 @Api(tags = "武大开放接口层apiController")
@@ -69,6 +73,21 @@ public class WudaOpenApiController {
         response.sendRedirect(dictionaryConfig.sysDomain().getReportUrl() + basicSchool.getId() + "/" + uid);
         response.sendRedirect(dictionaryConfig.sysDomain().getReportUrl() + basicSchool.getId() + "/" + uid);
     }
     }
 
 
+    @ApiOperation(value = "cas鉴权退出接口")
+    @RequestMapping(value = "/authentication/logout", method = RequestMethod.GET)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回消息", response = Result.class)})
+    @Aac(auth = BOOL.FALSE)
+    public void authenticationLogout(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        log.info("logout is come in:{}");
+        HttpSession session = request.getSession();
+        session.invalidate();
+        String casLogoutURL = "http://cas.whu.edu.cn/authserver/logout";
+        // service后面带的参数为应用的访问地址,需要使用URLEncoder进行编码
+        String redirectURL = casLogoutURL + "?service=" + URLEncoder.encode("http://cas.whu.edu.cn/authserver/login", SystemConstant.CHARSET_NAME);
+        response.setHeader("Access-Control-Allow-Origin", "*");
+        response.sendRedirect(redirectURL);
+    }
+
     @ApiOperation(value = "cas用户鉴权接口")
     @ApiOperation(value = "cas用户鉴权接口")
     @RequestMapping(value = "/user/authentication", method = RequestMethod.GET)
     @RequestMapping(value = "/user/authentication", method = RequestMethod.GET)
     @ApiResponses({@ApiResponse(code = 200, message = "返回消息", response = Result.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "返回消息", response = Result.class)})
@@ -79,9 +98,13 @@ public class WudaOpenApiController {
         if (Objects.isNull(uid)) {
         if (Objects.isNull(uid)) {
             throw ExceptionResultEnum.NOT_LOGIN.exception();
             throw ExceptionResultEnum.NOT_LOGIN.exception();
         }
         }
-        BasicSchool basicSchool = cacheService.schoolCache(SystemConstant.SCHOOL_CODE);
+        UserAuthenticationDto userAuthenticationDto = new UserAuthenticationDto(uid, SystemConstant.getUuid());
+        WhuUserAuthCacheUtil.setAuthCode(userAuthenticationDto);
+        String pattern = "{0}{1}{2}";
+        String code = URLEncoder.encode(MessageFormat.format(pattern, userAuthenticationDto.getUid(), SignatureEntityTest.FIELD_JOINER, SignatureEntityTest.encrypt(userAuthenticationDto.getCode())), SystemConstant.CHARSET_NAME);
+        log.info("code:{}", code);
         response.setHeader("Access-Control-Allow-Origin", "*");
         response.setHeader("Access-Control-Allow-Origin", "*");
-        response.sendRedirect(dictionaryConfig.sysDomain().getReportUrl() + basicSchool.getId() + "/" + uid);
+        response.sendRedirect(dictionaryConfig.sysDomain().getLoginAuthenUrl() + "/" + code);
     }
     }
 
 
     @ApiOperation(value = "cas用户鉴权测试接口")
     @ApiOperation(value = "cas用户鉴权测试接口")
@@ -92,19 +115,22 @@ public class WudaOpenApiController {
         String uid = "yz1";
         String uid = "yz1";
         UserAuthenticationDto userAuthenticationDto = new UserAuthenticationDto(uid, SystemConstant.getUuid());
         UserAuthenticationDto userAuthenticationDto = new UserAuthenticationDto(uid, SystemConstant.getUuid());
         WhuUserAuthCacheUtil.setAuthCode(userAuthenticationDto);
         WhuUserAuthCacheUtil.setAuthCode(userAuthenticationDto);
-        String PATTERN = "{0}{1}{2}";
-        String code = MessageFormat.format(PATTERN, userAuthenticationDto.getUid(), SignatureEntityTest.FIELD_JOINER, SignatureEntityTest.encrypt(userAuthenticationDto.getCode()));
+        String pattern = "{0}{1}{2}";
+        String code = URLEncoder.encode(MessageFormat.format(pattern, userAuthenticationDto.getUid(), SignatureEntityTest.FIELD_JOINER, SignatureEntityTest.encrypt(userAuthenticationDto.getCode())), SystemConstant.CHARSET_NAME);
         log.info("code:{}", code);
         log.info("code:{}", code);
         response.setHeader("Access-Control-Allow-Origin", "*");
         response.setHeader("Access-Control-Allow-Origin", "*");
-        response.sendRedirect(dictionaryConfig.sysDomain().getReportUrl() + code);
+        response.sendRedirect(dictionaryConfig.sysDomain().getLoginAuthenUrl() + code);
     }
     }
 
 
     @ApiOperation(value = "cas用户临时授权登录接口")
     @ApiOperation(value = "cas用户临时授权登录接口")
     @RequestMapping(value = "/user/authentication/login", method = RequestMethod.POST)
     @RequestMapping(value = "/user/authentication/login", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回消息", response = LoginResult.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "返回消息", response = LoginResult.class)})
     @Aac(auth = BOOL.FALSE)
     @Aac(auth = BOOL.FALSE)
-    public Result login(@ApiParam(value = "授权码信息", required = true) @RequestParam String code) throws NoSuchAlgorithmException {
-        String[] values = StringUtils.split(code, SignatureEntityTest.FIELD_JOINER);
+    public Result login(@ApiParam(value = "授权码信息", required = true) @RequestParam String code) throws NoSuchAlgorithmException, UnsupportedEncodingException {
+        String[] values = StringUtils.split(URLDecoder.decode(code, SystemConstant.CHARSET_NAME), SignatureEntityTest.FIELD_JOINER);
+        if (Objects.isNull(values) || values.length != 2) {
+            throw ExceptionResultEnum.ERROR.exception("临时授权码出错,请重新获取");
+        }
         log.info("values:{}", JacksonUtil.parseJson(values));
         log.info("values:{}", JacksonUtil.parseJson(values));
         QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
         QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
         wrapper.lambda().eq(SysUser::getLoginName, values[0]);
         wrapper.lambda().eq(SysUser::getLoginName, values[0]);

+ 1 - 0
teachcloud-report/src/main/resources/application-dev.properties

@@ -60,6 +60,7 @@ sys.config.threadPoolCoreSize=1
 sys.config.customThreadPoolCoreSize=false
 sys.config.customThreadPoolCoreSize=false
 sys.config.sessionActive=1h
 sys.config.sessionActive=1h
 sys.config.reportUrl=http://localhost:9099/#/student-report/
 sys.config.reportUrl=http://localhost:9099/#/student-report/
+sys.config.loginAuthenUrl=http://localhost:9099/#/login-authen/
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 
 
 org.center.url=https://solar.qmth.com.cn
 org.center.url=https://solar.qmth.com.cn

+ 1 - 0
teachcloud-report/src/main/resources/application-release.properties

@@ -58,6 +58,7 @@ sys.config.threadPoolCoreSize=1
 sys.config.customThreadPoolCoreSize=false
 sys.config.customThreadPoolCoreSize=false
 sys.config.sessionActive=1h
 sys.config.sessionActive=1h
 sys.config.reportUrl=https://wdfx.qmth.com.cn/#/student-report/
 sys.config.reportUrl=https://wdfx.qmth.com.cn/#/student-report/
+sys.config.loginAuthenUrl=https://wdfx.qmth.com.cn/#/login-authen/
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 
 
 org.center.url=https://solar.qmth.com.cn
 org.center.url=https://solar.qmth.com.cn

+ 1 - 0
teachcloud-report/src/main/resources/application-test.properties

@@ -58,6 +58,7 @@ sys.config.threadPoolCoreSize=1
 sys.config.customThreadPoolCoreSize=false
 sys.config.customThreadPoolCoreSize=false
 sys.config.sessionActive=1h
 sys.config.sessionActive=1h
 sys.config.reportUrl=http://192.168.10.136:7005/#/student-report/
 sys.config.reportUrl=http://192.168.10.136:7005/#/student-report/
+sys.config.loginAuthenUrl=http://192.168.10.136:7005/#/login-authen/
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 
 
 org.center.url=https://solar.qmth.com.cn
 org.center.url=https://solar.qmth.com.cn