|
|
@@ -0,0 +1,124 @@
|
|
|
+package com.uas.platform.home.controller;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.uas.account.entity.User;
|
|
|
+import com.uas.account.entity.UserSpaceDetail;
|
|
|
+import com.uas.account.entity.UserView;
|
|
|
+import com.uas.account.util.AccountUtils;
|
|
|
+import com.uas.platform.home.core.support.SystemSession;
|
|
|
+import com.uas.platform.home.model.ResultInfo;
|
|
|
+import com.uas.platform.home.model.UuzcUserInfo;
|
|
|
+import com.uas.platform.home.web.BaseController;
|
|
|
+import com.uas.sso.common.util.HttpUtil;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 关于优软众创的一些接口
|
|
|
+ *
|
|
|
+ * Created by hejq on 2017-11-02.
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping(value = "/uuzc")
|
|
|
+public class UuzcController extends BaseController {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 对当前登录账号进行检验
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/account/check", method = RequestMethod.GET)
|
|
|
+ public ModelMap checkAccount() throws Exception {
|
|
|
+ UserView user = SystemSession.getUser();
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ //先判断个人账户类型
|
|
|
+ String personalUrl = "http://job.uutest.com/index.php?m=&c=ubtob&a=check_user&uc_uid=" + user.getDialectUID();
|
|
|
+ HttpUtil.ResponseWrap responseWrap = HttpUtil.doGet(personalUrl);
|
|
|
+ ResultInfo userInfo = JSONObject.parseObject(responseWrap.getContent(), ResultInfo.class);
|
|
|
+ if(null != userInfo.getData()) {
|
|
|
+ if(userInfo.getData().getCode().equals("2")) {//个人用户
|
|
|
+ UuzcUserInfo info = getUserInfo(user, false);
|
|
|
+ JSONObject formData = JSON.parseObject(JSON.toJSONString(info));
|
|
|
+ map.put("user", formData);
|
|
|
+ map.put("usertype", "personal");
|
|
|
+ return map;
|
|
|
+ } else if(userInfo.getData().getCode().equals("1")) {// 企业用户
|
|
|
+ UuzcUserInfo info = getUserInfo(user, true);
|
|
|
+ JSONObject formData = JSON.parseObject(JSON.toJSONString(info));
|
|
|
+ //判断是否设置了hr
|
|
|
+ String result = AccountUtils.getHrAccount(info.getLicense());
|
|
|
+ ResultInfo resInfo = JSONObject.parseObject(result, ResultInfo.class);
|
|
|
+ map.put("hr", resInfo.getExistHr() ? true : false);
|
|
|
+ if(user.getName().equals(user.getUserSpaceDetail().getAdminName())) {
|
|
|
+ map.put("manager", true);
|
|
|
+ }
|
|
|
+ map.put("user", info);
|
|
|
+ map.put("usertype", "company");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将账户中心信息转成众创需要的信息
|
|
|
+ *
|
|
|
+ * @param user
|
|
|
+ * @param company
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private UuzcUserInfo getUserInfo(UserView user, boolean company) {
|
|
|
+ UuzcUserInfo info = new UuzcUserInfo();
|
|
|
+ info.setEmail(user.getSecondUID());
|
|
|
+ info.setMobile(user.getUid());
|
|
|
+ info.setUc_uid(user.getDialectUID());
|
|
|
+ info.setPassword(user.getPassword());
|
|
|
+ info.setSalt(user.getSalt());
|
|
|
+ info.setUsername(user.getName());
|
|
|
+ if(null != user.getUserSpaceDetail() && company) {
|
|
|
+ info.setCompanyname(user.getSpaceName());
|
|
|
+ info.setLicense(user.getSpaceUID());
|
|
|
+ info.setContact(user.getUserSpaceDetail().getContactMan());
|
|
|
+ info.setWebsite(user.getUserSpaceDetail().getUrl());
|
|
|
+ info.setTelephone(user.getUserSpaceDetail().getTel());
|
|
|
+ info.setLandine_tel(user.getUserSpaceDetail().getContactTel());
|
|
|
+ }
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置hr账号
|
|
|
+ *
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/setHrAccount", method = RequestMethod.POST)
|
|
|
+ public ModelMap setHrAccount(UuzcUserInfo user) throws Exception {
|
|
|
+ UserSpaceDetail detail = SystemSession.getUser().getUserSpaceDetail();
|
|
|
+ User userInfo = new User();
|
|
|
+ userInfo.setHr((short) 1);
|
|
|
+ userInfo.setName(user.getUsername());
|
|
|
+ userInfo.setUid(user.getMobile());
|
|
|
+ userInfo.setSecondUID(user.getEmail());
|
|
|
+ String result = AccountUtils.setHrAccount(userInfo, detail);
|
|
|
+ ResultInfo resInfo = JSONObject.parseObject(result, ResultInfo.class);
|
|
|
+ return new ModelMap("result", resInfo.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前企业的用户信息
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/existusers", method = RequestMethod.GET)
|
|
|
+ public ModelMap getExistUsers() throws Exception {
|
|
|
+ List<User> users = AccountUtils.getEmployees(SystemSession.getUser().getUserSpaceDetail().getBusinessCode());
|
|
|
+ return success(users);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|