package com.miniframe.bisiness.system; import com.miniframe.core.ExecProcessFlow; import com.miniframe.core.ext.UtilTools; import com.miniframe.export.VerificationImage; import com.miniframe.generate.business.system.model.A00000BaseModel; import com.miniframe.httpserver.HttpServerTransFile; import org.springframework.http.MediaType; import java.io.ByteArrayOutputStream; import java.util.Map; import static com.miniframe.constant.XIConstant.IMAGE_CODE; /** * 基础系统,“获取图片验证码”逻辑处理(重新生成不覆盖)。 */ public class A00000Service extends A00000BaseModel implements ExecProcessFlow { private static final long serialVersionUID = -7051358269847459502L; /** * 基础系统,“获取图片验证码”业务核心处理 */ public void transExecute() throws Exception { //产生验证码文件,并且已经将验证码放入的userCache中。 VerificationImage image = new VerificationImage(); String clientToken = this.getA_systemhead().getClientToken(); org.apache.commons.io.output.ByteArrayOutputStream bos = image.createImage(clientToken); //验证验证码是否正确使用 //VerificationImage.checkImage(clientToken, image.capText) //设置下行回写的文件 String contentType = MediaType.IMAGE_JPEG_VALUE; String fileName = this.getA_systemhead().getTransCode() + "." + "jpg"; ByteArrayOutputStream bos1 = new ByteArrayOutputStream(); bos1.write(bos.toByteArray()); HttpServerTransFile transFile = new HttpServerTransFile(fileName, contentType, bos1,true); bos1.close(); UtilTools.setHttpServerTransFile(transFile); String key = UtilTools.getBaseCode() + IMAGE_CODE + clientToken; UtilTools.putUserCache(key, image.capText); } /** * 基础系统,“获取图片验证码”业务前处理 */ public void preTransFlow() throws Exception { this.validater(); } /** * 基础系统,“获取图片验证码”业务后处理 */ public void afterTransFlow() throws Exception { } /** * 基础系统,“获取图片验证码”逻辑入口处理方法 */ @SuppressWarnings("rawtypes") @Override public Map execute(Map vars) throws Exception { this.setTransMap(vars); preTransFlow();// 执行业务开始的规则检查和校验 transExecute();// 执行核心业务段 afterTransFlow();// 执行核心逻辑完成后的收尾逻辑 return this.getTransMap(); } }