| | |
| | | import com.google.gson.Gson; |
| | | import com.open.common.util.OpenApiClient; |
| | | import com.open.common.util.SystemParameterNames; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.util.SpringContextsUtil; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.model.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public static SaveStaffNode saveStaffNode(SaveStaffNodeRequest request){ |
| | | public static ResultUtil<SaveStaffNode> saveStaffNode(SaveStaffNodeRequest request){ |
| | | //请求路径 |
| | | String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/saveStaffNode"; |
| | | //私钥文件 |
| | |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【企业增加员工】请求失败:" + result); |
| | | throw new RuntimeException("【企业增加员工】请求失败:" + result); |
| | | String retMsg = jsonObject.getString("retMsg"); |
| | | if(retMsg.contains("员工昵称已存在")){ |
| | | request.setEmpName(request.getEmpName() + Double.valueOf(Math.random() * 100).intValue()); |
| | | request.setEmpNickname(request.getEmpName()); |
| | | return saveStaffNode(request); |
| | | } |
| | | retMsg = retMsg.substring(retMsg.indexOf("{")); |
| | | jsonObject = JSON.parseObject(retMsg); |
| | | return ResultUtil.error("【企业增加员工】请求失败:" + jsonObject.getString("msg")); |
| | | } |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【企业增加员工】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【企业增加员工】失败:" + object.toJSONString()); |
| | | return ResultUtil.error("【企业增加员工】失败:" + object.getString("desc")); |
| | | } |
| | | SaveStaffNode saveStaffNode = object.getObject("data", SaveStaffNode.class); |
| | | return saveStaffNode; |
| | | return ResultUtil.success(saveStaffNode); |
| | | } |
| | | |
| | | |