|
@@ -39,18 +39,11 @@ public class UserServiceImpl implements UserService {
|
|
@Autowired
|
|
@Autowired
|
|
private StaffMapper staffMapper;
|
|
private StaffMapper staffMapper;
|
|
|
|
|
|
- public void addStaffWithUser(String externalUserId, String staffUserId) {
|
|
|
|
- if (StringUtils.isEmpty(externalUserId) || StringUtils.isEmpty(staffUserId)) {
|
|
|
|
|
|
+ public void addStaffWithUser(String externalUserId, String carrierId) {
|
|
|
|
+ if (StringUtils.isEmpty(externalUserId) || StringUtils.isEmpty(carrierId)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- StaffExample example = new StaffExample();
|
|
|
|
- example.createCriteria().andCarrierIdEqualTo(staffUserId);
|
|
|
|
- List<Staff> staffList = staffMapper.selectByExample(example);
|
|
|
|
- if (CollectionUtils.isEmpty(staffList)) {
|
|
|
|
- log.error("addUserWithStaff staff empty staffUserId={}", staffUserId);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- Staff staff = staffList.get(0);
|
|
|
|
|
|
+ Staff staff = getStaff(carrierId);
|
|
// insertStaffWithUser(externalUserId, staff);
|
|
// insertStaffWithUser(externalUserId, staff);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -140,6 +133,52 @@ public class UserServiceImpl implements UserService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void delStaffWithUser(String externalUserId, String carrierId) {
|
|
|
|
+ if (StringUtils.isEmpty(externalUserId) || StringUtils.isEmpty(carrierId)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Staff staff = getStaff(carrierId);
|
|
|
|
+ if (staff == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ User user = getUser(externalUserId);
|
|
|
|
+ if (user == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ StaffWithUserExample example = new StaffWithUserExample();
|
|
|
|
+ example.createCriteria().andStaffIdEqualTo(staff.getId()).andUserIdEqualTo(user.getId());
|
|
|
|
+ List<StaffWithUser> staffWithUserList = staffWithUserMapper.selectByExample(example);
|
|
|
|
+ if (CollectionUtils.isEmpty(staffWithUserList) || staffWithUserList.get(0).getIsDelete() == 1) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ StaffWithUser staffWithUser = staffWithUserList.get(0);
|
|
|
|
+ staffWithUser.setIsDelete(1);
|
|
|
|
+ staffWithUserMapper.updateByPrimaryKeySelective(staffWithUser);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Staff getStaff(String carrierId) {
|
|
|
|
+ StaffExample example = new StaffExample();
|
|
|
|
+ example.createCriteria().andCarrierIdEqualTo(carrierId);
|
|
|
|
+ List<Staff> staffList = staffMapper.selectByExample(example);
|
|
|
|
+ if (CollectionUtils.isEmpty(staffList)) {
|
|
|
|
+ log.error("getStaff staff empty carrierId={}", carrierId);
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ return staffList.get(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private User getUser(String externalUserId) {
|
|
|
|
+ UserExample userExample = new UserExample();
|
|
|
|
+ userExample.createCriteria().andExternalUserIdEqualTo(externalUserId);
|
|
|
|
+ List<User> userList = userMapper.selectByExample(userExample);
|
|
|
|
+ if (CollectionUtils.isEmpty(userList)) {
|
|
|
|
+ log.error("getUser user empty externalUserId={}", externalUserId);
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ return userList.get(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
public JSONObject getUserDetail(String externalUserId) throws IOException {
|
|
public JSONObject getUserDetail(String externalUserId) throws IOException {
|
|
String weComAccessToken = accessTokenService.getWeComAccessToken();
|
|
String weComAccessToken = accessTokenService.getWeComAccessToken();
|