|
@@ -1,85 +1,85 @@
|
|
|
-package com.yx.face.service.Aspect;
|
|
|
-
|
|
|
-import com.yx.face.boot.restful.ServiceException;
|
|
|
-import com.yx.face.boot.uitls.Base64Util;
|
|
|
-import com.yx.face.boot.uitls.ThumbnailsUtil;
|
|
|
-import com.yx.face.dao.FaceLogFromDao;
|
|
|
-import com.yx.face.model.entity.FaceLog;
|
|
|
-import com.yx.face.model.entity.FaceLogFrom;
|
|
|
-import org.apache.tomcat.util.codec.binary.Base64;
|
|
|
-import org.aspectj.lang.JoinPoint;
|
|
|
-import org.aspectj.lang.annotation.After;
|
|
|
-import org.aspectj.lang.annotation.Aspect;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-
|
|
|
-/**
|
|
|
- * @description:
|
|
|
- * @ClassName FaceLogDaoAspect
|
|
|
- * @Author WXG
|
|
|
- * @Date 2021/12/2 15:09
|
|
|
- */
|
|
|
-@Component
|
|
|
-@Aspect
|
|
|
-public class FaceLogDaoAspect {
|
|
|
-
|
|
|
- @Resource
|
|
|
- FaceLogFromDao faceLogFromDao;
|
|
|
-
|
|
|
- @After("execution( public * com.yx.face.dao.FaceLogDao.delete*(*))")
|
|
|
- public void deleteAfter(JoinPoint joinPoint) {
|
|
|
- String name = joinPoint.getSignature().getName();
|
|
|
- Object[] args = joinPoint.getArgs();
|
|
|
- if (name.equals("deleteByPrimaryKey")) {
|
|
|
- faceLogFromDao.delteByForgeinId((Long) args[0]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @After("execution( public * com.yx.face.dao.FaceLogDao.insert*(*))")
|
|
|
- public void insertAfter(JoinPoint joinPoint) {
|
|
|
- String name = joinPoint.getSignature().getName();
|
|
|
- Object[] args = joinPoint.getArgs();
|
|
|
- FaceLogFrom ublf = new FaceLogFrom();
|
|
|
- if (name.equals("insert") || name.equals("insertSelective")) {
|
|
|
- FaceLog ubl = (FaceLog) args[0];
|
|
|
- boolean photo = ubl.getPhoto() != null && !ubl.getPhoto().equals("") && ubl.getPhoto().indexOf("请求失败") == -1 && ubl.getId() != null;
|
|
|
- boolean sfzPhoto = ubl.getSfzPhoto() != null && !ubl.getSfzPhoto().equals("") && ubl.getSfzPhoto().indexOf("请求失败") == -1 && ubl.getId() != null;
|
|
|
- if (photo) {
|
|
|
- ublf.setFaceLogId(ubl.getId());
|
|
|
- ublf.setImgBase(this.picForScale(Base64Util.getByteArrayFromUrl(ubl.getPhoto())));
|
|
|
- if(sfzPhoto) {
|
|
|
- ublf.setSfzImgBase(this.picForScale((Base64Util.getByteArrayFromUrl(ubl.getSfzPhoto()))));
|
|
|
- }
|
|
|
- faceLogFromDao.insertSelective(ublf);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @After("execution( public * com.yx.face.dao.FaceLogDao.update*(*))")
|
|
|
- public void updateAfter(JoinPoint joinPoint) {
|
|
|
- String name = joinPoint.getSignature().getName();
|
|
|
- Object[] args = joinPoint.getArgs();
|
|
|
- FaceLogFrom ublf = new FaceLogFrom();
|
|
|
- if (name.equals("updateByPrimaryKey") || name.equals("updateByPrimaryKeySelective")) {
|
|
|
- FaceLog ubl = (FaceLog) args[0];
|
|
|
- boolean photo = ubl.getPhoto() != null && !ubl.getPhoto().equals("") && ubl.getPhoto().indexOf("请求失败") == -1 && ubl.getId() != null;
|
|
|
- boolean sfzPhoto = ubl.getSfzPhoto() != null && !ubl.getSfzPhoto().equals("") && ubl.getSfzPhoto().indexOf("请求失败") == -1 && ubl.getId() != null;
|
|
|
- if (photo && sfzPhoto) {
|
|
|
- ublf.setFaceLogId(ubl.getId());
|
|
|
- ublf.setImgBase(this.picForScale(Base64Util.getByteArrayFromUrl(ubl.getPhoto())));
|
|
|
- ublf.setSfzImgBase(this.picForScale(Base64Util.getByteArrayFromUrl(ubl.getSfzPhoto())));
|
|
|
- faceLogFromDao.updateByForgeinId(ublf);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- private byte[] picForScale(byte[] bytes) {
|
|
|
- try {
|
|
|
- bytes = ThumbnailsUtil.compressPicForScale(bytes, 40);// 图片小于40kb
|
|
|
- return bytes;
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-}
|
|
|
+//package com.yx.face.service.Aspect;
|
|
|
+//
|
|
|
+//import com.yx.face.boot.restful.ServiceException;
|
|
|
+//import com.yx.face.boot.uitls.Base64Util;
|
|
|
+//import com.yx.face.boot.uitls.ThumbnailsUtil;
|
|
|
+//import com.yx.face.dao.FaceLogFromDao;
|
|
|
+//import com.yx.face.model.entity.FaceLog;
|
|
|
+//import com.yx.face.model.entity.FaceLogFrom;
|
|
|
+//import org.apache.tomcat.util.codec.binary.Base64;
|
|
|
+//import org.aspectj.lang.JoinPoint;
|
|
|
+//import org.aspectj.lang.annotation.After;
|
|
|
+//import org.aspectj.lang.annotation.Aspect;
|
|
|
+//import org.springframework.stereotype.Component;
|
|
|
+//
|
|
|
+//import javax.annotation.Resource;
|
|
|
+//
|
|
|
+///**
|
|
|
+// * @description:
|
|
|
+// * @ClassName FaceLogDaoAspect
|
|
|
+// * @Author WXG
|
|
|
+// * @Date 2021/12/2 15:09
|
|
|
+// */
|
|
|
+//@Component
|
|
|
+//@Aspect
|
|
|
+//public class FaceLogDaoAspect {
|
|
|
+//
|
|
|
+// @Resource
|
|
|
+// FaceLogFromDao faceLogFromDao;
|
|
|
+//
|
|
|
+// @After("execution( public * com.yx.face.dao.FaceLogDao.delete*(*))")
|
|
|
+// public void deleteAfter(JoinPoint joinPoint) {
|
|
|
+// String name = joinPoint.getSignature().getName();
|
|
|
+// Object[] args = joinPoint.getArgs();
|
|
|
+// if (name.equals("deleteByPrimaryKey")) {
|
|
|
+// faceLogFromDao.delteByForgeinId((Long) args[0]);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// @After("execution( public * com.yx.face.dao.FaceLogDao.insert*(*))")
|
|
|
+// public void insertAfter(JoinPoint joinPoint) {
|
|
|
+// String name = joinPoint.getSignature().getName();
|
|
|
+// Object[] args = joinPoint.getArgs();
|
|
|
+// FaceLogFrom ublf = new FaceLogFrom();
|
|
|
+// if (name.equals("insert") || name.equals("insertSelective")) {
|
|
|
+// FaceLog ubl = (FaceLog) args[0];
|
|
|
+// boolean photo = ubl.getPhoto() != null && !ubl.getPhoto().equals("") && ubl.getPhoto().indexOf("请求失败") == -1 && ubl.getId() != null;
|
|
|
+// boolean sfzPhoto = ubl.getSfzPhoto() != null && !ubl.getSfzPhoto().equals("") && ubl.getSfzPhoto().indexOf("请求失败") == -1 && ubl.getId() != null;
|
|
|
+// if (photo) {
|
|
|
+// ublf.setFaceLogId(ubl.getId());
|
|
|
+// ublf.setImgBase(this.picForScale(Base64Util.getByteArrayFromUrl(ubl.getPhoto())));
|
|
|
+// if(sfzPhoto) {
|
|
|
+// ublf.setSfzImgBase(this.picForScale((Base64Util.getByteArrayFromUrl(ubl.getSfzPhoto()))));
|
|
|
+// }
|
|
|
+// faceLogFromDao.insertSelective(ublf);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// @After("execution( public * com.yx.face.dao.FaceLogDao.update*(*))")
|
|
|
+// public void updateAfter(JoinPoint joinPoint) {
|
|
|
+// String name = joinPoint.getSignature().getName();
|
|
|
+// Object[] args = joinPoint.getArgs();
|
|
|
+// FaceLogFrom ublf = new FaceLogFrom();
|
|
|
+// if (name.equals("updateByPrimaryKey") || name.equals("updateByPrimaryKeySelective")) {
|
|
|
+// FaceLog ubl = (FaceLog) args[0];
|
|
|
+// boolean photo = ubl.getPhoto() != null && !ubl.getPhoto().equals("") && ubl.getPhoto().indexOf("请求失败") == -1 && ubl.getId() != null;
|
|
|
+// boolean sfzPhoto = ubl.getSfzPhoto() != null && !ubl.getSfzPhoto().equals("") && ubl.getSfzPhoto().indexOf("请求失败") == -1 && ubl.getId() != null;
|
|
|
+// if (photo && sfzPhoto) {
|
|
|
+// ublf.setFaceLogId(ubl.getId());
|
|
|
+// ublf.setImgBase(this.picForScale(Base64Util.getByteArrayFromUrl(ubl.getPhoto())));
|
|
|
+// ublf.setSfzImgBase(this.picForScale(Base64Util.getByteArrayFromUrl(ubl.getSfzPhoto())));
|
|
|
+// faceLogFromDao.updateByForgeinId(ublf);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// private byte[] picForScale(byte[] bytes) {
|
|
|
+// try {
|
|
|
+// bytes = ThumbnailsUtil.compressPicForScale(bytes, 40);// 图片小于40kb
|
|
|
+// return bytes;
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+//}
|