|  |  |  | 
|---|
|  |  |  | package com.dy.pipIrrApp.captcha; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.multiDataSource.DataSourceContext; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponse; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponseUtils; | 
|---|
|  |  |  | import com.dy.pipIrrApp.captcha.dto.CaptchaDomain; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoBa.BaCaptcha; | 
|---|
|  |  |  | import jakarta.servlet.ServletOutputStream; | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("/get") | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | public CaptchaDomain getCaptcha(HttpServletRequest request, @RequestParam(value = "type", required = false, defaultValue = "char") String type) { | 
|---|
|  |  |  | public BaseResponse<CaptchaDomain> getCaptcha(HttpServletRequest request, @RequestParam(value = "type", required = false, defaultValue = "char") String type) { | 
|---|
|  |  |  | // 配置数据源 | 
|---|
|  |  |  | HttpServletRequest httpRequest = (HttpServletRequest) request; | 
|---|
|  |  |  | String wxDataSourceName = httpRequest.getHeader("tag"); | 
|---|
|  |  |  | 
|---|
|  |  |  | baCaptcha.setCode(captchaDomain.getCode()); | 
|---|
|  |  |  | baCaptcha.setExpiration(calendar.getTimeInMillis()); | 
|---|
|  |  |  | Long rec = captchaSV.addCaptcha(baCaptcha); | 
|---|
|  |  |  | System.out.println("token: " + captchaDomain.getToken() + "; code: " + captchaDomain.getCode()); | 
|---|
|  |  |  | //System.out.println("token: " + captchaDomain.getToken() + "; code: " + captchaDomain.getCode()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 无用信息设空 | 
|---|
|  |  |  | captchaDomain.setText(null); | 
|---|
|  |  |  | captchaDomain.setCode(null); | 
|---|
|  |  |  | // 返回前端信息 | 
|---|
|  |  |  | return captchaDomain; | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(captchaDomain); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | baCaptcha.setCode(captchaDomain.getCode()); | 
|---|
|  |  |  | baCaptcha.setExpiration(calendar.getTimeInMillis()); | 
|---|
|  |  |  | Long rec = captchaSV.addCaptcha(baCaptcha); | 
|---|
|  |  |  | System.out.println("token: " + captchaDomain.getToken() + "; code: " + captchaDomain.getCode()); | 
|---|
|  |  |  | //System.out.println("token: " + captchaDomain.getToken() + "; code: " + captchaDomain.getCode()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 以文件流的形式,输出验证码图片 | 
|---|
|  |  |  | ServletOutputStream out = null; | 
|---|