| | |
| | | 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.qianyuntong.model.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | |
| | | |
| | | /** |
| | | * 企业员工工具类 |
| | | * |
| | | * @author zhibing.pu |
| | | * @Date 2025/6/6 16:17 |
| | | */ |
| | | @Slf4j |
| | | public class EmployeeUtil { |
| | | |
| | | public static void main(String[] args) { |
| | | SaveStaffNodeRequest request = new SaveStaffNodeRequest(); |
| | | request.setMobile("15828353127"); |
| | | request.setEntercode("981100006005951"); |
| | | request.setEmpName("蒲"); |
| | | request.setEmpNickname("蒲"); |
| | | request.setLoginNo("15828353125"); |
| | | request.setEmpSex("男"); |
| | | request.setMphone("15828353125"); |
| | | request.setEmail("15828353125@qyt.com"); |
| | | request.setDeptId(0); |
| | | request.setPositionId(1); |
| | | request.setSuperLevel(0); |
| | | request.setHideMobile(0); |
| | | ResultUtil<SaveStaffNode> resultUtil = EmployeeUtil.saveStaffNode(request); |
| | | System.out.println(resultUtil.getData()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 企业增加员工 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public static SaveStaffNode saveStaffNode(SaveStaffNodeRequest request){ |
| | | public static ResultUtil<SaveStaffNode> saveStaffNode(SaveStaffNodeRequest request) { |
| | | //请求路径 |
| | | String url = QianYunTongProperties.apiUrl + "/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"); |
| | | 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 = jsonObject.getObject("object", SaveStaffNode.class); |
| | | return saveStaffNode; |
| | | SaveStaffNode saveStaffNode = object.getObject("data", SaveStaffNode.class); |
| | | return ResultUtil.success(saveStaffNode); |
| | | } |
| | | |
| | | |
| | |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【根据员工ID获取人员信息】请求失败:" + result); |
| | | throw new RuntimeException("【根据员工ID获取人员信息】请求失败:" + result); |
| | | return null; |
| | | } |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【根据员工ID获取人员信息】失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【根据员工ID获取人员信息】失败:" + object.toJSONString()); |
| | | return null; |
| | | } |
| | | StaffNodeInfo staffNodeInfo = object.getObject("data", StaffNodeInfo.class); |
| | | return staffNodeInfo; |