企业管理员增加同时修改用户表中关联id

This commit is contained in:
st 2024-03-09 17:23:55 +08:00
parent b7554338cd
commit 9bbf62fd06
5 changed files with 50 additions and 8 deletions

View File

@ -6,11 +6,15 @@ import com.ics.admin.service.IIcsCustomerStaffService;
import com.ics.common.constant.Constants;
import com.ics.common.core.controller.BaseController;
import com.ics.common.core.domain.R;
import com.ics.system.domain.User;
import com.ics.system.service.IUserService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.wf.jwtp.annotation.RequiresPermissions;
import java.util.Date;
import java.util.List;
/**
* 企业员工 提供者
@ -26,6 +30,8 @@ public class CustomerStaffController extends BaseController {
@Autowired
private IIcsCustomerStaffService icsCustomerStaffService;
@Autowired
private IUserService userService;
/**
* 查询企业员工
@ -42,8 +48,8 @@ public class CustomerStaffController extends BaseController {
@GetMapping("list")
public R list(IcsCustomerStaff icsCustomerStaff) {
startPage();
Integer staffId = getLoginStaffId();
icsCustomerStaff.setIcsCustomerId(staffId.longValue());
Integer customerId = getLoginCustomerId();
icsCustomerStaff.setIcsCustomerId(customerId.longValue());
icsCustomerStaff.setDataType(Constants.CUSTOMER_STAFF);
return result(icsCustomerStaffService.selectIcsCustomerStaffList(icsCustomerStaff));
}
@ -55,12 +61,18 @@ public class CustomerStaffController extends BaseController {
@RequiresPermissions("admin:staff:add")
@PostMapping("save")
public R addSave(@RequestBody IcsCustomerStaff icsCustomerStaff) {
Integer staffId = getLoginStaffId();
icsCustomerStaff.setIcsCustomerId(staffId.longValue());
Integer customerId = getLoginCustomerId();
icsCustomerStaff.setIcsCustomerId(customerId.longValue());
icsCustomerStaff.setCreateTime(new Date());
icsCustomerStaff.setCreateBy(getLoginName());
icsCustomerStaff.setDataType(Constants.CUSTOMER_STAFF);
return toAjax(icsCustomerStaffService.insertIcsCustomerStaff(icsCustomerStaff));
User user = userService.selectUserByMobile(icsCustomerStaff.getMobile());
int i = icsCustomerStaffService.insertIcsCustomerStaff(icsCustomerStaff);
if(i>0){
user.setStaffId(icsCustomerStaff.getId());
userService.updateUser(user);
}
return toAjax(i);
}
/**

View File

@ -113,6 +113,10 @@ public class BaseController {
return null;
}
/**
* 获取微信id
* @return
*/
public Integer getLoginStaffId() {
Token token = SubjectUtil.getToken(getRequest());
String value = valueOperations.get(ACCESS_USERID + ":" + token.getUserId());
@ -123,6 +127,20 @@ public class BaseController {
return null;
}
/**
* 获取企业id
* @return
*/
public Integer getLoginCustomerId() {
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("customerId")) {
return (Integer)jo.get("customerId");
}
return null;
}
/**
* 响应返回结果

View File

@ -81,7 +81,10 @@ public class User extends BaseEntity<User> {
@NotBlank(message = "登录名称不能为空")
private String username;
private String customerId;
/**
* 企业id
*/
private Long customerId;
/**
* 用户名称
@ -167,7 +170,9 @@ public class User extends BaseEntity<User> {
*/
private Set<String> buttons;
/**
* 用户id
*/
private Long staffId;
/**

View File

@ -77,8 +77,13 @@ public class CurrentUserVO {
private Boolean isAdmin;
/**
* 户id
* 户id
*/
private Long staffId;
/**
* 企业id
*/
private Long customerId;
}

View File

@ -90,6 +90,8 @@ public class PublishFactory {
userOnline.setDeptName(user.getDept().getDeptName());
}
userOnline.setStaffId(user.getStaffId());
userOnline.setCustomerId(user.getCustomerId());
// 发布事件
SpringContextHolder.publishEvent(new UserOnlineEvent(userOnline));
}