提交 d77788fc authored 作者: 000516's avatar 000516

部门编码展示、添加阿里云oss

......@@ -90,6 +90,15 @@
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>sts20150401</artifactId>
</dependency>
</dependencies>
<build>
......
package com.sfa.system.controller.aliyun;
import com.alibaba.fastjson.JSONObject;
import com.sfa.system.utils.AliyunUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author : liqiulin
* @date : 2025-02-06 13
* @describe :
*/
@Slf4j
@RestController
@RequestMapping("/aliyun/")
public class AliyunGetToken {
@Autowired
private AliyunUtil aliyunUtil;
@GetMapping("/sts_token")
public Object getStsToken() {
try {
JSONObject stsToken = aliyunUtil.getStsToken();
return stsToken;
} catch (Exception e) {
return e.getMessage();
}
}
}
package com.sfa.system.utils;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.sts20150401.Client;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* @author : liqiulin
* @date : 2025-02-06 13
* @describe :
*/
@Component
public class AliyunUtil {
@Value("${aliyun.access-key-id}")
private String OSS_ACCESS_KEY_ID;
@Value("${aliyun.access-key-secret}")
private String OSS_ACCESS_KEY_SECRET;
@Value("${aliyun.halogen-oss.region-id}")
private String REGION_ID;
@Value("${aliyun.halogen-oss.bucket-name}")
private String BUCKET_NAME;
@Value("${aliyun.halogen-oss.web-js-link}")
private String WEB_JS_LIN;
@Value("${aliyun.halogen-oss.sts-role-arm}")
private String OSS_STS_ROLE_ARN;
public JSONObject getStsToken() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
.setAccessKeyId(OSS_ACCESS_KEY_ID)
.setAccessKeySecret(OSS_ACCESS_KEY_SECRET);
config.endpoint = "sts." + REGION_ID + ".aliyuncs.com";
Client client = new Client(config);
com.aliyun.sts20150401.models.AssumeRoleRequest assumeRoleRequest = new com.aliyun.sts20150401.models.AssumeRoleRequest()
.setDurationSeconds(3600L)
.setRoleArn(OSS_STS_ROLE_ARN)
.setRoleSessionName("000516");
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
com.aliyun.sts20150401.models.AssumeRoleResponse assumeRoleResponse = client.assumeRoleWithOptions(assumeRoleRequest, runtime);
JSONObject rj = JSONObject.parseObject(JSONObject.toJSONString(assumeRoleResponse.body.getCredentials()));
rj.put("web_js_link",BUCKET_NAME);
rj.put("region",REGION_ID);
return rj;
}
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="deptName" column="dept_name" />
<result property="deptCode" column="dept_code" />
<result property="orderNum" column="order_num" />
<result property="leader" column="leader" />
<result property="phone" column="phone" />
......@@ -51,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
select d.dept_id, d.parent_id, d.ancestors, d.dept_name,d.dept_code, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
from sys_dept d
</sql>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论