A00000Service.java 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package com.miniframe.bisiness.system;
  2. import com.miniframe.core.ExecProcessFlow;
  3. import com.miniframe.core.ext.UtilTools;
  4. import com.miniframe.export.VerificationImage;
  5. import com.miniframe.generate.business.system.model.A00000BaseModel;
  6. import com.miniframe.httpserver.HttpServerTransFile;
  7. import org.springframework.http.MediaType;
  8. import java.io.ByteArrayOutputStream;
  9. import java.util.Map;
  10. import static com.miniframe.constant.XIConstant.IMAGE_CODE;
  11. /**
  12. * 基础系统,“获取图片验证码”逻辑处理(重新生成不覆盖)。
  13. */
  14. public class A00000Service extends A00000BaseModel implements ExecProcessFlow {
  15. private static final long serialVersionUID = -7051358269847459502L;
  16. /**
  17. * 基础系统,“获取图片验证码”业务核心处理
  18. */
  19. public void transExecute() throws Exception {
  20. //产生验证码文件,并且已经将验证码放入的userCache中。
  21. VerificationImage image = new VerificationImage();
  22. String clientToken = this.getA_systemhead().getClientToken();
  23. org.apache.commons.io.output.ByteArrayOutputStream bos = image.createImage(clientToken);
  24. //验证验证码是否正确使用
  25. //VerificationImage.checkImage(clientToken, image.capText)
  26. //设置下行回写的文件
  27. String contentType = MediaType.IMAGE_JPEG_VALUE;
  28. String fileName = this.getA_systemhead().getTransCode() + "." + "jpg";
  29. ByteArrayOutputStream bos1 = new ByteArrayOutputStream();
  30. bos1.write(bos.toByteArray());
  31. HttpServerTransFile transFile = new HttpServerTransFile(fileName, contentType, bos1,true);
  32. bos1.close();
  33. UtilTools.setHttpServerTransFile(transFile);
  34. String key = UtilTools.getBaseCode() + IMAGE_CODE + clientToken;
  35. UtilTools.putUserCache(key, image.capText);
  36. }
  37. /**
  38. * 基础系统,“获取图片验证码”业务前处理
  39. */
  40. public void preTransFlow() throws Exception {
  41. this.validater();
  42. }
  43. /**
  44. * 基础系统,“获取图片验证码”业务后处理
  45. */
  46. public void afterTransFlow() throws Exception {
  47. }
  48. /**
  49. * 基础系统,“获取图片验证码”逻辑入口处理方法
  50. */
  51. @SuppressWarnings("rawtypes")
  52. @Override
  53. public Map execute(Map vars) throws Exception {
  54. this.setTransMap(vars);
  55. preTransFlow();// 执行业务开始的规则检查和校验
  56. transExecute();// 执行核心业务段
  57. afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
  58. return this.getTransMap();
  59. }
  60. }