登录增加所属客户id

This commit is contained in:
st 2024-03-02 16:18:40 +08:00
parent b91cc06d22
commit 02a6a1df18
4 changed files with 21 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package com.ics.admin.controller;
import com.alibaba.fastjson.JSONObject;
import com.ics.admin.domain.IcsCustomerStaff;
import com.ics.admin.service.IIcsCustomerStaffService;
import com.ics.common.constant.Constants;
@ -41,7 +42,8 @@ public class CustomerStaffController extends BaseController {
@GetMapping("list")
public R list(IcsCustomerStaff icsCustomerStaff) {
startPage();
icsCustomerStaff.setIcsCustomerId(1L);//临时设置,需要从用户信息中获取
Integer staffId = getLoginStaffId();
icsCustomerStaff.setIcsCustomerId(staffId.longValue());
icsCustomerStaff.setDataType(Constants.CUSTOMER_STAFF);
return result(icsCustomerStaffService.selectIcsCustomerStaffList(icsCustomerStaff));
}
@ -53,7 +55,8 @@ public class CustomerStaffController extends BaseController {
@RequiresPermissions("admin:staff:add")
@PostMapping("save")
public R addSave(@RequestBody IcsCustomerStaff icsCustomerStaff) {
icsCustomerStaff.setIcsCustomerId(1L);
Integer staffId = getLoginStaffId();
icsCustomerStaff.setIcsCustomerId(staffId.longValue());
icsCustomerStaff.setCreateTime(new Date());
icsCustomerStaff.setCreateBy(getLoginName());
icsCustomerStaff.setDataType(Constants.CUSTOMER_STAFF);

View File

@ -113,6 +113,16 @@ public class BaseController {
return null;
}
public Integer getLoginStaffId() {
Token token = SubjectUtil.getToken(getRequest());
String value = valueOperations.get(ACCESS_USERID + ":" + token.getUserId());
JSONObject jo = StringUtils.isEmpty(value) ? null : JSON.parseObject(value, JSONObject.class);
if (jo != null && jo.containsKey("staffId")) {
return (Integer)jo.get("staffId");
}
return null;
}
/**
* 响应返回结果

View File

@ -76,4 +76,9 @@ public class CurrentUserVO {
*/
private Boolean isAdmin;
/**
* 客户id
*/
private Long staffId;
}

View File

@ -89,6 +89,7 @@ public class PublishFactory {
userOnline.setDeptId(user.getDept().getId());
userOnline.setDeptName(user.getDept().getDeptName());
}
userOnline.setStaffId(user.getStaffId());
// 发布事件
SpringContextHolder.publishEvent(new UserOnlineEvent(userOnline));
}