|
|
@@ -1,16 +1,31 @@
|
|
|
package bus.service.impl;
|
|
|
|
|
|
+import bus.model.dto.CommonLoginDto;
|
|
|
import bus.model.dto.WChatUserDto;
|
|
|
-import bus.model.dto.WChatUserPageDto;
|
|
|
-import bus.model.vo.WChatUserVo;
|
|
|
+import bus.model.dto.page.WChatUserPageDto;
|
|
|
+import bus.model.dto.req.WxLoginReq;
|
|
|
import bus.model.po.WChatUserPo;
|
|
|
import bus.mapper.WChatUserMapper;
|
|
|
|
|
|
+import bus.service.CommonService;
|
|
|
import bus.service.WChatUserService;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.orcas.common.sso.model.SsoUserAuthDto;
|
|
|
+import com.orcas.common.usercenter.entity.RoleEntity;
|
|
|
+import com.orcas.common.usercenter.entity.StaffEntity;
|
|
|
+import com.orcas.common.usercenter.model.StaffBindRoleDto;
|
|
|
+import com.orcas.common.usercenter.model.StaffRequest;
|
|
|
+import com.orcas.iso.service.RoleClient;
|
|
|
+import com.orcas.iso.service.StaffClient;
|
|
|
+import com.orcas.iso.service.UserClient;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -25,9 +40,59 @@ public class WChatUserServiceImpl implements WChatUserService {
|
|
|
|
|
|
@Autowired
|
|
|
private WChatUserMapper wChatUserMapper;
|
|
|
+ @Autowired
|
|
|
+ private StaffClient staffClient;
|
|
|
+ @Autowired
|
|
|
+ private UserClient userClient;
|
|
|
+ @Autowired
|
|
|
+ private RoleClient roleClient;
|
|
|
+ @Autowired
|
|
|
+ private CommonService commonService;
|
|
|
+ @Value("${orcas.organizeId}")
|
|
|
+ private String organizeId;
|
|
|
+ @Value("${orcas.creditCode}")
|
|
|
+ private String creditCode;
|
|
|
+ @Value("${orcas.productNo}")
|
|
|
+ private String productNo;
|
|
|
+ @Override
|
|
|
+ public SsoUserAuthDto wxLogin(HttpServletRequest request, HttpServletResponse response, WxLoginReq wxLoginReq) {
|
|
|
+ //http://58.221.153.58:48989/api-gateway/iso-server/usercenter/role/addRole
|
|
|
+//http://58.221.153.58:48989/api-gateway/iso-server/usercenter/role/assignStaffs
|
|
|
+ //http://58.221.153.58:48989/api-gateway/iso-server/usercenter/staff/addStaff
|
|
|
+ //根据用户名称查询底座接口
|
|
|
+ String mobile = wxLoginReq.getMobile();
|
|
|
+ String wxName = wxLoginReq.getWxName();
|
|
|
+ StaffEntity staffByUserName = staffClient.getStaffByUserName(mobile, organizeId);
|
|
|
+ if(staffByUserName == null){
|
|
|
+ //注册用户
|
|
|
+ StaffRequest req = new StaffRequest();
|
|
|
+ req.setPhone(mobile);
|
|
|
+ req.setAccountName(mobile);
|
|
|
+ String sub = StrUtil.sub(mobile, mobile.length() - 6, mobile.length());
|
|
|
+ req.setPassword(sub);
|
|
|
+ req.setStaffName(wxName);
|
|
|
+ req.setUnitOrganizeId(organizeId);
|
|
|
+ req.setUniformCreditCode(creditCode);
|
|
|
+ req.setIsAdmin(0);
|
|
|
+ StaffEntity staffEntity = staffClient.addStaff(req);
|
|
|
+ List<RoleEntity> roleListByProId = (List<RoleEntity>)roleClient.getRoleListByProId(productNo);
|
|
|
+ //绑定角色
|
|
|
+ StaffBindRoleDto staffBindRoleDto = new StaffBindRoleDto();
|
|
|
+ staffBindRoleDto.setRoleIds(CollectionUtil.newArrayList(roleListByProId.get(0).getId()));
|
|
|
+ staffBindRoleDto.setProductNo(productNo);
|
|
|
+ staffBindRoleDto.setUnitOrganizeId(organizeId);
|
|
|
+ staffBindRoleDto.setStaffId(staffEntity.getId());
|
|
|
+ roleClient.staffBindRole(staffBindRoleDto);
|
|
|
+ }
|
|
|
+ //登录
|
|
|
+ CommonLoginDto userLoginRequest= new CommonLoginDto();
|
|
|
+ userLoginRequest.setAccount(mobile);
|
|
|
+ userLoginRequest.setPassword(StrUtil.sub(mobile, mobile.length() - 6, mobile.length()));
|
|
|
+ SsoUserAuthDto ssoUserAuthDto = commonService.doLogin(request,response,userLoginRequest);
|
|
|
+ return ssoUserAuthDto;
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 详情
|
|
|
* @param id
|
|
|
* @return
|