Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
ops
Commits
0cd4136b
Commit
0cd4136b
authored
Feb 28, 2025
by
wujipeng
Browse files
初步整合钉钉系统
parent
f1a74efb
Changes
5
Show whitespace changes
Inline
Side-by-side
pom.xml
View file @
0cd4136b
...
...
@@ -106,6 +106,18 @@
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
3.15.1
</version>
</dependency>
<!-- 钉钉 -->
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
dingtalk
</artifactId>
<version>
2.1.42
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
alibaba-dingtalk-service-sdk
</artifactId>
<version>
2.0.0
</version>
</dependency>
</dependencies>
<repositories>
...
...
@@ -118,6 +130,7 @@
<id>
jitpack.io
</id>
<url>
https://jitpack.io
</url>
</repository>
</repositories>
<build>
...
...
src/main/java/com/ruzhoukj/sms/controller/DingAttendanceController.java
0 → 100644
View file @
0cd4136b
package
com.ruzhoukj.sms.controller
;
/**
* @author : wujipeng
* @date : 2025/2/28 10:00
* @Version: 1.0
* @Desc : 钉钉考勤管理
*/
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/ding/attendance"
)
public
class
DingAttendanceController
{
}
src/main/java/com/ruzhoukj/sms/controller/DingEmployeeController.java
0 → 100644
View file @
0cd4136b
package
com.ruzhoukj.sms.controller
;
import
com.dingtalk.api.DefaultDingTalkClient
;
import
com.dingtalk.api.DingTalkClient
;
import
com.dingtalk.api.request.OapiSmartworkHrmEmployeeQueryonjobRequest
;
import
com.dingtalk.api.response.OapiSmartworkHrmEmployeeQueryonjobResponse
;
import
com.ruzhoukj.sms.ding.PermissionConfig
;
import
com.taobao.api.ApiException
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author : wujipeng
* @date : 2025/2/28 10:03
* @Version: 1.0
* @Desc : 钉钉员工管理
*/
@RestController
@RequestMapping
(
"/ding/employee"
)
public
class
DingEmployeeController
{
@Resource
private
PermissionConfig
permissionConfig
;
@ApiOperation
(
value
=
"获取在职员工id列表"
)
@GetMapping
(
"/list"
)
public
List
<
String
>
getEmployeeIdList
()
{
String
accessToken
=
permissionConfig
.
getAccessToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/queryonjob"
);
OapiSmartworkHrmEmployeeQueryonjobRequest
req
=
new
OapiSmartworkHrmEmployeeQueryonjobRequest
();
Map
<
String
,
String
>
textParams
=
req
.
getTextParams
();
textParams
.
put
(
"access_token"
,
accessToken
);
OapiSmartworkHrmEmployeeQueryonjobResponse
rsp
=
client
.
execute
(
req
,
""
);
System
.
out
.
println
(
rsp
.
getBody
());
return
null
;
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
src/main/java/com/ruzhoukj/sms/ding/PermissionConfig.java
0 → 100644
View file @
0cd4136b
package
com.ruzhoukj.sms.ding
;
import
com.dingtalk.api.DefaultDingTalkClient
;
import
com.dingtalk.api.DingTalkClient
;
import
com.dingtalk.api.request.OapiGettokenRequest
;
import
com.dingtalk.api.response.OapiGettokenResponse
;
import
com.taobao.api.ApiException
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Configuration
;
/**
* @author : wujipeng
* @date : 2025/2/27 15:15
* @Version: 1.0
* @Desc : 钉钉token获取
*/
@Configuration
public
class
PermissionConfig
{
@Value
(
"ding.key"
)
private
String
key
;
@Value
(
"ding.secret"
)
private
String
secret
;
public
String
getAccessToken
()
{
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/gettoken"
);
OapiGettokenRequest
req
=
new
OapiGettokenRequest
();
req
.
setAppkey
(
key
);
req
.
setAppsecret
(
secret
);
req
.
setHttpMethod
(
"GET"
);
OapiGettokenResponse
rsp
=
client
.
execute
(
req
);
return
rsp
.
getAccessToken
();
}
catch
(
ApiException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
src/main/resources/application.yml
View file @
0cd4136b
...
...
@@ -32,3 +32,8 @@ oss:
secret
:
Q006EvMzC63i1ozDiVNxEAxo8eH9zA
endPoint
:
https://oss-cn-beijing.aliyuncs.com
bucket
:
manj
ding
:
key
:
dingatpypxs4jlryvh85
secret
:
_GVhUwb1bX3_tEAuIMxbD9LIsJsTGlzpUvBroG83_NPt3nxbL4jzbBAPkd_dijD6
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment