|
@@ -0,0 +1,215 @@
|
|
|
|
+package cn.cslg.report.service;
|
|
|
|
+
|
|
|
|
+import cn.cslg.report.common.core.base.Constants;
|
|
|
|
+import cn.cslg.report.common.model.vo.LoginVO;
|
|
|
|
+import cn.cslg.report.common.model.vo.PersonnelVO;
|
|
|
|
+import cn.cslg.report.common.utils.LogExceptionUtil;
|
|
|
|
+import cn.cslg.report.common.utils.Response;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+@Slf4j
|
|
|
|
+@Service
|
|
|
|
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
|
+public class BaseService {
|
|
|
|
+ private final OutInterfaceService outInterfaceService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return 1.生成验证码的base64转码 2.生成的UUID 与Redis里面的验证码KEY值一致
|
|
|
|
+ * @title 获取验证码
|
|
|
|
+ * @author 沈永艺
|
|
|
|
+ */
|
|
|
|
+ public String verifyCode() {
|
|
|
|
+ try {
|
|
|
|
+ String resBody = outInterfaceService.getVerifyCodeFromPCS();
|
|
|
|
+ JSONObject data = (JSONObject) JSONObject.parseObject(resBody).get("data");
|
|
|
|
+ Map<String, String> result = new HashMap<>();
|
|
|
|
+ result.put("captcha", data.get("captcha").toString());
|
|
|
|
+ result.put("uuid", data.get("uuid").toString());
|
|
|
|
+ return Response.success(result);
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ log.error("权限系统获取验证码失败,错误信息:" + LogExceptionUtil.getMessage(ex));
|
|
|
|
+ return Response.error(Constants.NET_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return 成功返回Token 失败返回错误信息
|
|
|
|
+ * @title 登录接口
|
|
|
|
+ * @author 沈永艺
|
|
|
|
+ */
|
|
|
|
+ public String login(LoginVO loginVO) throws IOException {
|
|
|
|
+ String resBody = outInterfaceService.loginFromPCS(loginVO);
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
|
+ //判断请求返回是否为200,不是的话则返回报错信息
|
|
|
|
+ if (!jsonObject.get("code").equals(200)) {
|
|
|
|
+ log.error("权限系统登录失败,错误信息:" + jsonObject.get("message").toString());
|
|
|
|
+ return Response.error(Constants.NET_ERROR);
|
|
|
|
+ } else {
|
|
|
|
+ PersonnelVO personnelVO = com.alibaba.fastjson2.JSONObject.parseObject(jsonObject.get("data").toString(), PersonnelVO.class);
|
|
|
|
+ return Response.success(personnelVO.getToken());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return 成功返回用户信息 失败返回错误信息
|
|
|
|
+ * @title 获取登录人信息
|
|
|
|
+ * @author 沈永艺
|
|
|
|
+ */
|
|
|
|
+ public String getUserInfo() {
|
|
|
|
+ try {
|
|
|
|
+ String resBody = outInterfaceService.userInfoFromPCS();
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
|
+ PersonnelVO personnelVO = com.alibaba.fastjson2.JSONObject.parseObject(jsonObject.get("data").toString(), PersonnelVO.class);
|
|
|
|
+ return Response.success(personnelVO);
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ log.error("权限系统获取用户信息失败,错误信息:" + LogExceptionUtil.getMessage(ex));
|
|
|
|
+ return Response.error(Constants.NET_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return 成功返回Map类型字典项信息 失败返回错误信息
|
|
|
|
+ * @title 获取字典项信息
|
|
|
|
+ * @author 沈永艺
|
|
|
|
+ */
|
|
|
|
+ public String getDictMessage() {
|
|
|
|
+ try {
|
|
|
|
+ Map<String, Object> map = outInterfaceService.dictMessageFromPCS();
|
|
|
|
+ return Response.success(map);
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ log.error("权限系统获取字典项信息失败,错误信息:" + LogExceptionUtil.getMessage(ex));
|
|
|
|
+ return Response.error(Constants.NET_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return 成功返回权限列表信息 失败返回错误信息
|
|
|
|
+ * @title 获取权限列表
|
|
|
|
+ * @author 沈永艺
|
|
|
|
+ */
|
|
|
|
+ public String getPermissionList(String code) {
|
|
|
|
+ try {
|
|
|
|
+ String resBody = outInterfaceService.getPermissionListFromPCS(code);
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
|
+ return Response.success(jsonObject.get("data"));
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ log.error("权限系统获取权限列表失败,错误信息:" + LogExceptionUtil.getMessage(ex));
|
|
|
|
+ return Response.error(Constants.NET_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return 成功返回部门列表信息 失败返回错误信息
|
|
|
|
+ * @title 获取所有部门
|
|
|
|
+ * @author 沈永艺
|
|
|
|
+ */
|
|
|
|
+ public String getAllDepartment() {
|
|
|
|
+ try {
|
|
|
|
+ String resBody = outInterfaceService.getAllDepartmentFromPCS();
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
|
+ return Response.success(jsonObject.get("data"));
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ log.error("权限系统获取部门列表失败,错误信息:" + LogExceptionUtil.getMessage(ex));
|
|
|
|
+ return Response.error(Constants.NET_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return 成功返回部门列表信息 失败返回错误信息
|
|
|
|
+ * @title 获取部分部门
|
|
|
|
+ * @author 沈永艺
|
|
|
|
+ */
|
|
|
|
+ public String getPartDepartment() {
|
|
|
|
+ try {
|
|
|
|
+ String resBody = outInterfaceService.getPartDepartmentFromPCS();
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
|
+ return Response.success(jsonObject.get("data"));
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ log.error("权限系统获取部门列表失败,错误信息:" + LogExceptionUtil.getMessage(ex));
|
|
|
|
+ return Response.error(Constants.NET_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return 成功返回人员列表信息 失败返回错误信息
|
|
|
|
+ * @title 获取全部人员
|
|
|
|
+ * @author 沈永艺
|
|
|
|
+ */
|
|
|
|
+ public String getAllPersonnel() {
|
|
|
|
+ try {
|
|
|
|
+ String resBody = outInterfaceService.getAllPersonnelFromPCS();
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
|
+ return Response.success(jsonObject.get("data"));
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ log.error("权限系统获取人员列表失败,错误信息:" + LogExceptionUtil.getMessage(ex));
|
|
|
|
+ return Response.error(Constants.NET_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return 成功返回人员列表信息 失败返回错误信息
|
|
|
|
+ * @title 获取部分人员
|
|
|
|
+ * @author 沈永艺
|
|
|
|
+ */
|
|
|
|
+ public String getPartPersonnel() {
|
|
|
|
+ try {
|
|
|
|
+ String resBody = outInterfaceService.getPartPersonnelFromPCS();
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
|
+ return Response.success(jsonObject.get("data"));
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ log.error("权限系统获取人员列表失败,错误信息:" + LogExceptionUtil.getMessage(ex));
|
|
|
|
+ return Response.error(Constants.NET_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return 成功返回客户列表信息 失败返回错误信息
|
|
|
|
+ * @title 获取所有客户
|
|
|
|
+ * @author 沈永艺
|
|
|
|
+ */
|
|
|
|
+ public String getAllClient() {
|
|
|
|
+ try {
|
|
|
|
+ String resBody = outInterfaceService.getAllClientFromPCS();
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
|
+ return Response.success(jsonObject.get("data"));
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ log.error("权限系统获取客户列表失败,错误信息:" + LogExceptionUtil.getMessage(ex));
|
|
|
|
+ return Response.error(Constants.NET_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return 成功返回客户列表信息 失败返回错误信息
|
|
|
|
+ * @title 获取部分客户
|
|
|
|
+ * @author 沈永艺
|
|
|
|
+ */
|
|
|
|
+ public String getPartClient() {
|
|
|
|
+ try {
|
|
|
|
+ String resBody = outInterfaceService.getPartClientFromPCS();
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
|
+ return Response.success(jsonObject.get("data"));
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ log.error("权限系统获取客户列表失败,错误信息:" + LogExceptionUtil.getMessage(ex));
|
|
|
|
+ return Response.error(Constants.NET_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|