|
@@ -2,6 +2,7 @@ package com.yh.saas.plugin.yiliangyiyun.controller;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
|
import com.winsea.svc.base.base.entity.CommonCompany;
|
|
|
import com.winsea.svc.base.base.entity.CommonStaff;
|
|
@@ -30,15 +31,30 @@ import com.yh.saas.plugin.yiliangyiyun.util.HttpUtil;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.util.WebSocket;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import com.aliyuncs.DefaultAcsClient;
|
|
|
+import com.aliyuncs.IAcsClient;
|
|
|
+import com.aliyuncs.exceptions.ClientException;
|
|
|
+import com.aliyuncs.exceptions.ServerException;
|
|
|
+import com.aliyuncs.profile.DefaultProfile;
|
|
|
+import com.google.gson.Gson;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+import com.aliyuncs.sts.model.v20150401.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.InputStreamReader;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.URL;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 前端控制器
|
|
|
+ * 前端控制器
|
|
|
* </p>
|
|
|
*
|
|
|
* @author Gongdc
|
|
@@ -66,19 +82,47 @@ public class CommonUserController {
|
|
|
private WebSocket webSocket;
|
|
|
|
|
|
|
|
|
+ @GetMapping("/getAuth")
|
|
|
+ public String getAuth(String apiKey, String secretKey) {
|
|
|
+ //构建一个阿里云客户端,用于发起请求。
|
|
|
+ //构建阿里云客户端时需要设置AccessKey ID和AccessKey Secret。
|
|
|
+ DefaultProfile profile = DefaultProfile.getProfile("cn-beijing", "'LTAI4G9c14PgKvM23WZ9zrpc", "FpClTp4OVrRRtHEfi3lBOWUoLxKieW");
|
|
|
+ IAcsClient client = new DefaultAcsClient(profile);
|
|
|
+
|
|
|
+ //构造请求,设置参数。关于参数含义和设置方法,请参见《API参考》。
|
|
|
+ AssumeRoleRequest request = new AssumeRoleRequest();
|
|
|
+ request.setRegionId("cn-beijing");
|
|
|
+ request.setRoleArn("acs:ram::1822896003496259:role/aliyuncasdefaultrole");
|
|
|
+ request.setRoleSessionName("Ok");
|
|
|
+
|
|
|
+ //发起请求,并得到响应。
|
|
|
+ try {
|
|
|
+ AssumeRoleResponse response = client.getAcsResponse(request);
|
|
|
+ return new Gson().toJson(response);
|
|
|
+ } catch (ServerException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (ClientException e) {
|
|
|
+ System.out.println("ErrCode:" + e.getErrCode());
|
|
|
+ System.out.println("ErrMsg:" + e.getErrMsg());
|
|
|
+ System.out.println("RequestId:" + e.getRequestId());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 图像审核识别Demo
|
|
|
+ *
|
|
|
* @param imagePath
|
|
|
* @param accessToken
|
|
|
* @return UserDefinedBean
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/getUserDefinedBean")
|
|
|
- public static UserDefinedBean getUserDefinedBean(String imagePath, String accessToken) throws Exception{
|
|
|
+ public static UserDefinedBean getUserDefinedBean(String imagePath, String accessToken) throws Exception {
|
|
|
byte[] imgData = FileUtil.readFileByBytes(imagePath);
|
|
|
String imgStr = Base64Util.encode(imgData);
|
|
|
- String param = "image=" + URLEncoder.encode(imgStr,"UTF-8");
|
|
|
+ String param = "image=" + URLEncoder.encode(imgStr, "UTF-8");
|
|
|
// String jsonParam = "{\"top_num\":5,\"image\":\"图片的base64\"}";
|
|
|
// 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。
|
|
|
String result = HttpUtil.post(ImageCensorConsts.ANTI_USER_DEFINED_URL, accessToken, param);
|
|
@@ -88,58 +132,64 @@ public class CommonUserController {
|
|
|
|
|
|
/**
|
|
|
* 注册
|
|
|
+ *
|
|
|
* @param commonUser
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/register")
|
|
|
- public String register(@RequestBody CommonUser commonUser) throws ServiceException {
|
|
|
+ public String register(@RequestBody CommonUser commonUser) throws ServiceException {
|
|
|
return commonUserService.register(commonUser);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 重置密码
|
|
|
+ *
|
|
|
* @param commonUser
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/resetPassword")
|
|
|
- public String resetPassword(@RequestBody CommonUser commonUser) throws ServiceException {
|
|
|
+ public String resetPassword(@RequestBody CommonUser commonUser) throws ServiceException {
|
|
|
return commonUserService.resetPassword(commonUser);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 重置账号
|
|
|
+ *
|
|
|
* @param commonUser
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/resetAccount")
|
|
|
- public String resetAccount(@RequestBody CommonUser commonUser) throws ServiceException {
|
|
|
+ public String resetAccount(@RequestBody CommonUser commonUser) throws ServiceException {
|
|
|
return commonUserService.resetAccount(commonUser);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 修改用户信息
|
|
|
+ *
|
|
|
* @param commonUser
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/editUserInfo")
|
|
|
- public String editUserInfo(@RequestBody CommonUser commonUser) throws ServiceException {
|
|
|
+ public String editUserInfo(@RequestBody CommonUser commonUser) throws ServiceException {
|
|
|
return commonUserService.editUserInfo(commonUser);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发送验证码
|
|
|
+ *
|
|
|
* @param phone
|
|
|
* @return
|
|
|
* @throws ServiceException
|
|
|
*/
|
|
|
@GetMapping("/sendVerifyCode")
|
|
|
- public String sendVerifyCode(String phone) throws ServiceException {
|
|
|
+ public String sendVerifyCode(String phone) throws ServiceException {
|
|
|
return commonUserService.sendVerifyCode(phone);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 登录
|
|
|
+ *
|
|
|
* @param commonUser
|
|
|
* @return
|
|
|
* @throws ServiceException
|
|
@@ -151,6 +201,7 @@ public class CommonUserController {
|
|
|
|
|
|
/**
|
|
|
* 快捷登录
|
|
|
+ *
|
|
|
* @param commonUser
|
|
|
* @return
|
|
|
* @throws ServiceException
|
|
@@ -159,8 +210,10 @@ public class CommonUserController {
|
|
|
public CommonUser loginVerifyCode(CommonUser commonUser) throws ServiceException {
|
|
|
return commonUserService.loginVerifyCode(commonUser);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 校验验证码
|
|
|
+ *
|
|
|
* @param commonUser
|
|
|
* @return
|
|
|
* @throws ServiceException
|
|
@@ -182,7 +235,6 @@ public class CommonUserController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 创建登录用户
|
|
|
*
|
|
@@ -217,7 +269,7 @@ public class CommonUserController {
|
|
|
compId = companyService.getCompanyIdByDomainName(authUser.getCompanyId(), authUser.getDomainName(),
|
|
|
request.getServerName());
|
|
|
|
|
|
- if (StringUtils.isEmpty(compId)){
|
|
|
+ if (StringUtils.isEmpty(compId)) {
|
|
|
compId = userService.findPhoneCompId(authUser.getMobilePhone());
|
|
|
}
|
|
|
}
|
|
@@ -259,6 +311,7 @@ public class CommonUserController {
|
|
|
public String checkApp(@RequestBody CommonUser commonUser) throws ServiceException {
|
|
|
return commonUserService.checkApp(commonUser);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* Session检测
|
|
|
*
|
|
@@ -279,6 +332,7 @@ public class CommonUserController {
|
|
|
public List<CommonCompany> getComp() {
|
|
|
return commonUserService.getComp();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 公司
|
|
|
*
|
|
@@ -288,6 +342,7 @@ public class CommonUserController {
|
|
|
public List<CommonCompany> getCompOwn(String phone) {
|
|
|
return commonUserService.getCompOwn(phone);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 首页公司下拉列表
|
|
|
*
|