业务单据,扫码单据关联用户,仓库信息等;bug修复
parent
94b9941e49
commit
f921753024
@ -0,0 +1,67 @@
|
|||||||
|
package com.glxp.sale.admin.service.auth;
|
||||||
|
|
||||||
|
import com.glxp.sale.admin.dao.auth.AuthLicenseDao;
|
||||||
|
import com.glxp.sale.admin.entity.auth.AuthAdmin;
|
||||||
|
import com.glxp.sale.admin.entity.auth.AuthLicense;
|
||||||
|
import com.glxp.sale.admin.exception.JsonException;
|
||||||
|
import com.glxp.sale.common.enums.ResultEnum;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CustomerService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AuthAdminService authAdminService;
|
||||||
|
@Resource
|
||||||
|
private AuthLicenseDao authLicenseDao;
|
||||||
|
|
||||||
|
public AuthAdmin getUserBean() {
|
||||||
|
Integer userId = getUserId();
|
||||||
|
AuthAdmin authAdmin = authAdminService.findById(userId.longValue());
|
||||||
|
return authAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUserId() {
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
|
||||||
|
if (attributes == null) {
|
||||||
|
throw new JsonException(ResultEnum.NOT_NETWORK);
|
||||||
|
}
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
String userId = request.getHeader("ADMIN_ID");
|
||||||
|
return Integer.parseInt(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCustomerId() {
|
||||||
|
AuthAdmin authAdmin = getUserBean();
|
||||||
|
return authAdmin.getCustomerId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public long getCustomerIdByKey() {
|
||||||
|
AuthAdmin authAdmin = getUserBeanByKey();
|
||||||
|
return authAdmin.getCustomerId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUserIdByKey() {
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
if (attributes == null) {
|
||||||
|
throw new JsonException(ResultEnum.NOT_NETWORK);
|
||||||
|
}
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
String userId = request.getHeader("api_key");
|
||||||
|
return Integer.parseInt(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public AuthAdmin getUserBeanByKey() {
|
||||||
|
Integer userId = getUserIdByKey();
|
||||||
|
AuthAdmin authAdmin = authAdminService.findById(userId.longValue());
|
||||||
|
return authAdmin;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue