From d599942e79ea0198898bdfde049b908418debf54 Mon Sep 17 00:00:00 2001 From: lty <876263681@qq.com> Date: 星期五, 13 六月 2025 10:13:14 +0800 Subject: [PATCH] #新增生产日期和到期日期,和超期检索 --- src/main/java/com/zy/common/web/BaseController.java | 66 +++++++++++++++++++++++++++++++- 1 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/zy/common/web/BaseController.java b/src/main/java/com/zy/common/web/BaseController.java index 60d9fc1..3651942 100644 --- a/src/main/java/com/zy/common/web/BaseController.java +++ b/src/main/java/com/zy/common/web/BaseController.java @@ -7,9 +7,13 @@ import com.core.common.Cools; import com.core.controller.AbstractBaseController; import com.core.exception.CoolException; +import com.zy.asrs.entity.Node; import com.zy.asrs.entity.Tag; +import com.zy.asrs.service.NodeService; import com.zy.asrs.service.TagService; import com.zy.system.entity.User; +import com.zy.system.entity.UserLogin; +import com.zy.system.service.UserLoginService; import com.zy.system.service.UserService; import io.swagger.annotations.ApiModelProperty; import org.springframework.beans.factory.annotation.Autowired; @@ -32,16 +36,21 @@ private UserService userService; @Autowired private TagService tagService; + @Autowired + private NodeService nodeService; + + @Autowired + private UserLoginService userLoginService; protected Long getUserId(){ + if(Cools.isEmpty(request.getAttribute("userId"))){ + return 000L; + } return Long.parseLong(String.valueOf(request.getAttribute("userId"))); } protected User getUser(){ User user = userService.selectById(getUserId()); - if (null == user) { - throw new CoolException(BaseRes.DENIED); - } return user; } @@ -57,6 +66,14 @@ protected Tag getOriginTag(){ return tagService.getTop(); + } + + protected Node getOriginNode(){ + Node node = nodeService.getTop(); + if (node == null) { + throw new CoolException("搴撳尯鏁版嵁閿欒"); + } + return node; } /** @@ -142,4 +159,47 @@ wrapper.like(columns.get(i), condition); } } + + public static boolean isJSON(String str) { + if (Cools.isEmpty(str)) { + return false; + } else { + str = str.trim(); + if (str.startsWith("{") && str.endsWith("}")) { + return true; + } else if (str.startsWith("[") && str.endsWith("]")) { + return true; + } else { + return false; + } + } + } + + protected <T> void hostEq(EntityWrapper<T> wrapper){ + Long hostId = getHostId(); + if (hostId != null) { + wrapper.eq("host_id", hostId); + } + } + + protected Long getHostId(){ + if (getUserId() == 9527) { + return null; + } + User user = getUser(); + if (user.getRoleId() == 1) { + String hostId = String.valueOf(request.getAttribute("hostId")); + if (Cools.isEmpty(hostId)) { + UserLogin userLogin = userLoginService.selectOne(new EntityWrapper<UserLogin>().eq("user_id", user.getId())); + if (userLogin != null) { + //return userLogin.getHostId(); + return 1L; + } + } + return Long.parseLong(hostId); + } else { + return user.getHostId(); + } + } + } -- Gitblit v1.9.1