生成随机验证码VerifyCode工具类packagecom.meeno.common.cerifycode;importjavax.imageio.ImageIO;importjava.awt.*;importjava.awt.image.BufferedImage;importjava.io.FileNotFoundException;importjava.io.FileOutputStream;importjava.io.IOException;importjava.io.OutputStream;importjava.util.Random;/***@description:随机验证码*@author:Wzq*@create:2020-09-0816:55*/publicclassVerifyCode{privateintw=70;privateinth=35;privateRandomr=newRandom();privateString[]fontNames={"宋体","华文楷体","黑体","微软雅黑","楷体_GB2312"};privateStringcodes="012345678901234567890123456789abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";privateColorbgColor=newColor(255,255,255);privateStringtext;privateColorrandomColor(){intred=r.nextInt(150);intgreen=r.nextInt(150);intblue=r.nextInt(150);returnnewColor(red,green,blue);}privateFontrandomFont(){intindex=this.r.nextInt(fontNames.length);StringfontName=fontNames[index];intstyle=this.r.nextInt(4);intsize=this.r.nextInt(5)+24;returnnewFont(fontName,style,size);}privatevoiddrawLine(BufferedImageimage){intnum=3;Graphics2Dg2=(Graphics2D)image.getGraphics();for(inti=0;iresultMap=Maps.newHashMap();resultMap.put("base64",str);resultMap.put("uuid",uuid);//saveredisStringkey="RandomVerify:"+uuid;RedisUtil.set(key,vc.getText(),180);returnResultUtil.success(resultMap);}验证方法/***账号登录*@paramsession*@paramphone*@parampwd*@paramentryType*@return*/@RequestMapping("accountLogin.do")publicResponseBeanaccountLogin(finalHttpSessionsession,Stringphone,Stringpwd,StringentryType,Stringuuid,StringrandomCerifyCode){//校试验证码MeenoAssert.hasLength(randomCerifyCode,"randomCerifyCodecannotempty!");ObjectrandomCerifyCodeObj=RedisUtil.get("RandomVerify:"+uuid);MeenoAssert.notNull(randomCerifyCodeObj,CErrEnum.RANDOM_VERIFY_CODE_FAILURE);MeenoAssert.isTrue(randomCerifyCode.toCerqualifyCaseran().e).toLowerCase()),CErrEnum.RANDOM_VERIFY_CODE_ERR);LoginResultloginResult=this.employeeService.accountLogin(session,phone,pwd,entryType);EmpViewemployeeView=this.employeeService.getEmployee(loginResult.getUserInfo().getId());MapresultMap=Maps.newHashMap();resultMap.put("loginResult",loginResult);resultMap.put("employee",employeeView);returnResultUtil.success(resultMap);}