|  |  | 
 |  |  | 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"); | 
 |  |  |         if(wxDataSourceName != null && wxDataSourceName.trim().length() > 0){ | 
 |  |  |             log.info("微信开发,设置数据源名称为:" + wxDataSourceName); | 
 |  |  |             //把组织单位标签作为数据源名称 | 
 |  |  |             DataSourceContext.set(wxDataSourceName); | 
 |  |  |         } else { | 
 |  |  |             log.info("用户未选择数据源"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         // 生成验证码实体 | 
 |  |  |         CaptchaDomain captchaDomain = captchaSV.createGoogleCaptcha(type); | 
 |  |  |         if (null != captchaDomain) { | 
 |  |  | 
 |  |  |             captchaDomain.setText(null); | 
 |  |  |             captchaDomain.setCode(null); | 
 |  |  |             // 返回前端信息 | 
 |  |  |             return captchaDomain; | 
 |  |  |             return BaseResponseUtils.buildSuccess(captchaDomain); | 
 |  |  |         } else { | 
 |  |  |             return null; | 
 |  |  |         } |