Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dd_school
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangqi
dd_school
Commits
9837e388
Commit
9837e388
authored
Oct 09, 2023
by
xuwenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增钉钉api
parent
77d756c5
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
3801 additions
and
29 deletions
+3801
-29
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
+11
-5
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SchoolTeacher.java
+10
-0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
+22
-0
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
+2
-0
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
+53
-1
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
+6
-0
smart-campus/pom.xml
+18
-0
smart-campus/src/main/java/yangtz/cs/liu/campus/controller/auditorium/SchoolAuditoriumController.java
+78
-15
smart-campus/src/main/java/yangtz/cs/liu/campus/domain/auditorium/SchoolAuditorium.java
+6
-0
smart-campus/src/main/java/yangtz/cs/liu/campus/mapper/teacher/SchoolTeacherMapper.java
+12
-0
smart-campus/src/main/java/yangtz/cs/liu/campus/service/auditorium/ISchoolAuditoriumService.java
+6
-0
smart-campus/src/main/java/yangtz/cs/liu/campus/service/impl/auditorium/SchoolAuditoriumServiceImpl.java
+99
-4
smart-campus/src/main/java/yangtz/cs/liu/campus/service/impl/teacher/SchoolTeacherServiceImpl.java
+26
-0
smart-campus/src/main/java/yangtz/cs/liu/campus/service/teacher/ISchoolTeacherService.java
+12
-0
smart-campus/src/main/java/yangtz/cs/liu/campus/vo/auditorium/SchoolAuditoriumVo.java
+6
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/config/Constant.java
+14
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/DdApiController.java
+309
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/DdLoginController.java
+113
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/DdSchoolDeptController.java
+16
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/dingEvent/DingEventController.java
+85
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/dingMessage/DingMessageController.java
+98
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/dingProcess/DingProcessController.java
+141
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/dingRole/DingRoleController.java
+11
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/dingUser/DingUserController.java
+59
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/AccessTokenUtils.java
+55
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingCallbackCrypto.java
+407
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingDeptUtils.java
+304
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingMessageUtils.java
+135
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingProcessInstanceUtils.java
+468
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingRoleUtils.java
+244
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingTaskUtils.java
+79
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingUserUtils.java
+404
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingHandleVo.java
+40
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingMessageVo.java
+39
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingProcessInstanceVo.java
+57
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingSchoolDeptVo.java
+85
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingSchoolRoleVo.java
+17
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingSchoolTaskVo.java
+70
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingSchoolUserVo.java
+113
-0
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingTransferVo.java
+36
-0
smart-campus/src/main/resources/mapper/auditorium/SchoolAuditoriumMapper.xml
+10
-3
smart-campus/src/main/resources/mapper/teacher/SchoolTeacherMapper.xml
+25
-1
No files found.
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
View file @
9837e388
...
@@ -18,12 +18,13 @@ import com.ruoyi.common.utils.SecurityUtils;
...
@@ -18,12 +18,13 @@ import com.ruoyi.common.utils.SecurityUtils;
import
com.ruoyi.framework.web.service.SysLoginService
;
import
com.ruoyi.framework.web.service.SysLoginService
;
import
com.ruoyi.framework.web.service.SysPermissionService
;
import
com.ruoyi.framework.web.service.SysPermissionService
;
import
com.ruoyi.system.service.ISysMenuService
;
import
com.ruoyi.system.service.ISysMenuService
;
import
yangtz.cs.liu.campus.service.teacher.ISchoolTeacherService
;
import
static
com
.
ruoyi
.
common
.
utils
.
SecurityUtils
.
getUserId
;
import
static
com
.
ruoyi
.
common
.
utils
.
SecurityUtils
.
getUserId
;
/**
/**
* 登录验证
* 登录验证
*
*
* @author ruoyi
* @author ruoyi
*/
*/
@RestController
@RestController
...
@@ -38,9 +39,12 @@ public class SysLoginController
...
@@ -38,9 +39,12 @@ public class SysLoginController
@Autowired
@Autowired
private
SysPermissionService
permissionService
;
private
SysPermissionService
permissionService
;
@Autowired
private
ISchoolTeacherService
schoolTeacherService
;
/**
/**
* 登录方法
* 登录方法
*
*
* @param loginBody 登录信息
* @param loginBody 登录信息
* @return 结果
* @return 结果
*/
*/
...
@@ -59,7 +63,7 @@ public class SysLoginController
...
@@ -59,7 +63,7 @@ public class SysLoginController
/**
/**
* 获取用户信息
* 获取用户信息
*
*
* @return 用户信息
* @return 用户信息
*/
*/
@GetMapping
(
"getInfo"
)
@GetMapping
(
"getInfo"
)
...
@@ -67,7 +71,9 @@ public class SysLoginController
...
@@ -67,7 +71,9 @@ public class SysLoginController
{
{
getUserId
();
getUserId
();
SysUser
user
=
SecurityUtils
.
getLoginUser
().
getUser
();
SysUser
user
=
SecurityUtils
.
getLoginUser
().
getUser
();
SchoolTeacher
teacher
=
SecurityUtils
.
getLoginUser
().
getSchoolTeacher
();
// SchoolTeacher teacher = SecurityUtils.getLoginUser().getSchoolTeacher();
//教师信息
SchoolTeacher
teacher
=
schoolTeacherService
.
getById
(
user
.
getUserId
());
// 角色集合
// 角色集合
Set
<
String
>
roles
=
permissionService
.
getRolePermission
(
user
);
Set
<
String
>
roles
=
permissionService
.
getRolePermission
(
user
);
// 权限集合
// 权限集合
...
@@ -82,7 +88,7 @@ public class SysLoginController
...
@@ -82,7 +88,7 @@ public class SysLoginController
/**
/**
* 获取路由信息
* 获取路由信息
*
*
* @return 路由信息
* @return 路由信息
*/
*/
@GetMapping
(
"getRouters"
)
@GetMapping
(
"getRouters"
)
...
...
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SchoolTeacher.java
View file @
9837e388
...
@@ -98,6 +98,16 @@ public class SchoolTeacher extends BaseEntity{
...
@@ -98,6 +98,16 @@ public class SchoolTeacher extends BaseEntity{
* */
* */
private
String
openId
;
private
String
openId
;
/*
* 钉钉用户unionId
* */
private
String
unionId
;
/*
* 钉钉用户id
* */
private
String
ddUserId
;
//设备工号
//设备工号
private
String
deviceNum
;
private
String
deviceNum
;
...
...
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
View file @
9837e388
...
@@ -92,6 +92,12 @@ public class SysUser extends BaseEntity
...
@@ -92,6 +92,12 @@ public class SysUser extends BaseEntity
/** 微信openId */
/** 微信openId */
private
String
openId
;
private
String
openId
;
/** 钉钉用户unionId */
private
String
unionId
;
/** 钉钉用户id */
private
String
ddUserId
;
/** 部门对象 */
/** 部门对象 */
@Excels
({
@Excels
({
@Excel
(
name
=
"部门名称"
,
targetAttr
=
"deptName"
,
type
=
Type
.
EXPORT
),
@Excel
(
name
=
"部门名称"
,
targetAttr
=
"deptName"
,
type
=
Type
.
EXPORT
),
...
@@ -128,6 +134,22 @@ public class SysUser extends BaseEntity
...
@@ -128,6 +134,22 @@ public class SysUser extends BaseEntity
}
}
public
String
getUnionId
()
{
return
unionId
;
}
public
void
setUnionId
(
String
unionId
)
{
this
.
unionId
=
unionId
;
}
public
String
getDdUserId
()
{
return
ddUserId
;
}
public
void
setDdUserId
(
String
ddUserId
)
{
this
.
ddUserId
=
ddUserId
;
}
public
SysUser
(
Long
userId
)
public
SysUser
(
Long
userId
)
{
{
this
.
userId
=
userId
;
this
.
userId
=
userId
;
...
...
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
View file @
9837e388
...
@@ -113,7 +113,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
...
@@ -113,7 +113,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.
antMatchers
(
"/webSocket/**"
).
anonymous
()
.
antMatchers
(
"/webSocket/**"
).
anonymous
()
.
antMatchers
(
"/login"
,
"/register"
,
"/captchaImage"
).
anonymous
()
.
antMatchers
(
"/login"
,
"/register"
,
"/captchaImage"
).
anonymous
()
.
antMatchers
(
"/wx/user/login"
).
permitAll
()
.
antMatchers
(
"/wx/user/login"
).
permitAll
()
.
antMatchers
(
"/dd/user/login"
).
permitAll
()
.
antMatchers
(
"/common/**"
).
permitAll
()
.
antMatchers
(
"/common/**"
).
permitAll
()
.
antMatchers
(
"/dd/school/**"
).
permitAll
()
//网页注册登录接口放行
//网页注册登录接口放行
.
antMatchers
(
"/web/artStudent/register"
,
"/web/artStudent/login"
).
permitAll
()
.
antMatchers
(
"/web/artStudent/register"
,
"/web/artStudent/login"
).
permitAll
()
// 静态资源,可匿名访问
// 静态资源,可匿名访问
...
...
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
View file @
9837e388
...
@@ -6,6 +6,9 @@ import org.springframework.security.authentication.AuthenticationManager;
...
@@ -6,6 +6,9 @@ import org.springframework.security.authentication.AuthenticationManager;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.authority.AuthorityUtils
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
com.ruoyi.common.constant.CacheConstants
;
import
com.ruoyi.common.constant.CacheConstants
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.constant.Constants
;
...
@@ -49,6 +52,8 @@ public class SysLoginService
...
@@ -49,6 +52,8 @@ public class SysLoginService
@Autowired
@Autowired
private
ISysConfigService
configService
;
private
ISysConfigService
configService
;
@Autowired
private
SysPermissionService
permissionService
;
/**
/**
* 登录验证
* 登录验证
...
@@ -70,7 +75,7 @@ public class SysLoginService
...
@@ -70,7 +75,7 @@ public class SysLoginService
Authentication
authentication
=
null
;
Authentication
authentication
=
null
;
try
try
{
{
UsernamePasswordAuthenticationToken
authenticationToken
=
new
UsernamePasswordAuthenticationToken
(
phonenumber
,
password
);
UsernamePasswordAuthenticationToken
authenticationToken
=
new
UsernamePasswordAuthenticationToken
(
phonenumber
,
password
);
AuthenticationContextHolder
.
setContext
(
authenticationToken
);
AuthenticationContextHolder
.
setContext
(
authenticationToken
);
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
authentication
=
authenticationManager
.
authenticate
(
authenticationToken
);
authentication
=
authenticationManager
.
authenticate
(
authenticationToken
);
...
@@ -101,6 +106,53 @@ public class SysLoginService
...
@@ -101,6 +106,53 @@ public class SysLoginService
/**
/**
* 登录验证
* 登录验证
*
* @return 结果
*/
public
String
loginNew
(
SysUser
sysUser
)
{
// boolean captchaEnabled = configService.selectCaptchaEnabled();
// // 验证码开关
// if (captchaEnabled)
// {
// validateCaptcha(username, code, uuid);
// }
// 用户验证
Authentication
authentication
=
null
;
try
{
//直接不用springsecurity 认证、自己构造出数据
UserDetails
userDetails
=
new
LoginUser
(
sysUser
.
getUserId
(),
sysUser
.
getDeptId
(),
sysUser
,
permissionService
.
getMenuPermission
(
sysUser
));
authentication
=
new
UsernamePasswordAuthenticationToken
(
userDetails
,
null
,
AuthorityUtils
.
createAuthorityList
(
"ROLE_USER"
));
SecurityContextHolder
.
getContext
().
setAuthentication
(
authentication
);
}
catch
(
Exception
e
)
{
if
(
e
instanceof
BadCredentialsException
)
{
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordLogininfor
(
sysUser
.
getPhonenumber
(),
Constants
.
LOGIN_FAIL
,
MessageUtils
.
message
(
"user.password.not.match"
)));
throw
new
UserPasswordNotMatchException
();
}
else
{
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordLogininfor
(
sysUser
.
getPhonenumber
(),
Constants
.
LOGIN_FAIL
,
e
.
getMessage
()));
throw
new
ServiceException
(
e
.
getMessage
());
}
}
finally
{
AuthenticationContextHolder
.
clearContext
();
}
LoginUser
loginUser
=
(
LoginUser
)
authentication
.
getPrincipal
();
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordLogininfor
(
loginUser
.
getUsername
(),
Constants
.
LOGIN_SUCCESS
,
MessageUtils
.
message
(
"user.login.success"
)));
recordLoginInfo
(
loginUser
.
getUserId
());
// 生成token
return
tokenService
.
createToken
(
loginUser
);
}
/**
* 登录验证
*
*
* @param username 用户名
* @param username 用户名
* @param password 密码
* @param password 密码
...
...
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
View file @
9837e388
...
@@ -21,6 +21,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -21,6 +21,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"loginIp"
column=
"login_ip"
/>
<result
property=
"loginIp"
column=
"login_ip"
/>
<result
property=
"loginDate"
column=
"login_date"
/>
<result
property=
"loginDate"
column=
"login_date"
/>
<result
property=
"pwdUpdateDate"
column=
"pwd_update_date"
/>
<result
property=
"pwdUpdateDate"
column=
"pwd_update_date"
/>
<result
property=
"openId"
column=
"open_id"
/>
<result
property=
"ddUserId"
column=
"dd_user_id"
/>
<result
property=
"unionId"
column=
"union_id"
/>
<result
property=
"createBy"
column=
"create_by"
/>
<result
property=
"createBy"
column=
"create_by"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"updateBy"
column=
"update_by"
/>
...
@@ -216,6 +219,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -216,6 +219,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"employeeType != null and employeeType != ''"
>
employee_type = #{employeeType},
</if>
<if
test=
"employeeType != null and employeeType != ''"
>
employee_type = #{employeeType},
</if>
<if
test=
"studentId != null and studentId != 0"
>
student_id = #{studentId},
</if>
<if
test=
"studentId != null and studentId != 0"
>
student_id = #{studentId},
</if>
<if
test=
"sign != null and sign != ''"
>
sign = #{sign},
</if>
<if
test=
"sign != null and sign != ''"
>
sign = #{sign},
</if>
<if
test=
"openId != null and openId != ''"
>
open_id = #{openId},
</if>
<if
test=
"ddUserId != null and ddUserId != ''"
>
dd_user_id = #{ddUserId},
</if>
<if
test=
"unionId != null and unionId != ''"
>
union_id = #{unionId},
</if>
update_time = sysdate()
update_time = sysdate()
</set>
</set>
where user_id = #{userId}
where user_id = #{userId}
...
...
smart-campus/pom.xml
View file @
9837e388
...
@@ -12,6 +12,19 @@
...
@@ -12,6 +12,19 @@
<artifactId>
smart-campus
</artifactId>
<artifactId>
smart-campus
</artifactId>
<dependencies>
<dependencies>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
alibaba-dingtalk-service-sdk
</artifactId>
<version>
2.0.0
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
dingtalk
</artifactId>
<version>
2.0.14
</version>
</dependency>
<dependency>
<dependency>
<groupId>
com.ruoyi
</groupId>
<groupId>
com.ruoyi
</groupId>
<artifactId>
core-common
</artifactId>
<artifactId>
core-common
</artifactId>
...
@@ -87,6 +100,11 @@
...
@@ -87,6 +100,11 @@
<groupId>
org.quartz-scheduler
</groupId>
<groupId>
org.quartz-scheduler
</groupId>
<artifactId>
quartz
</artifactId>
<artifactId>
quartz
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.8
</version>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
smart-campus/src/main/java/yangtz/cs/liu/campus/controller/auditorium/SchoolAuditoriumController.java
View file @
9837e388
package
yangtz
.
cs
.
liu
.
campus
.
controller
.
auditorium
;
package
yangtz
.
cs
.
liu
.
campus
.
controller
.
auditorium
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request
;
import
com.ruoyi.common.core.domain.entity.SysUser
;
import
com.ruoyi.common.core.domain.entity.SysUser
;
import
com.ruoyi.common.exception.ServiceException
;
import
com.ruoyi.common.exception.ServiceException
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.DateUtils
;
...
@@ -47,6 +45,8 @@ import yangtz.cs.liu.campus.service.teacher.ISchoolTeacherService;
...
@@ -47,6 +45,8 @@ import yangtz.cs.liu.campus.service.teacher.ISchoolTeacherService;
import
yangtz.cs.liu.campus.util.VxTemlateSendApi
;
import
yangtz.cs.liu.campus.util.VxTemlateSendApi
;
import
yangtz.cs.liu.campus.vo.auditorium.SchoolAuditoriumVo
;
import
yangtz.cs.liu.campus.vo.auditorium.SchoolAuditoriumVo
;
import
yangtz.cs.liu.campus.vo.teacher.TeacherLeaveVO
;
import
yangtz.cs.liu.campus.vo.teacher.TeacherLeaveVO
;
import
yangtz.cs.liu.dingding.utils.DingMessageUtils
;
import
yangtz.cs.liu.dingding.vo.DingMessageVo
;
import
yangtz.cs.liu.wechat.service.api.IWxApiService
;
import
yangtz.cs.liu.wechat.service.api.IWxApiService
;
import
static
com
.
core
.
constant
.
ProcessDefinition
.*;
import
static
com
.
core
.
constant
.
ProcessDefinition
.*;
...
@@ -73,6 +73,8 @@ public class SchoolAuditoriumController extends BaseController
...
@@ -73,6 +73,8 @@ public class SchoolAuditoriumController extends BaseController
private
ISchoolTeacherService
teacherService
;
private
ISchoolTeacherService
teacherService
;
@Autowired
@Autowired
private
IWxApiService
wxApiService
;
private
IWxApiService
wxApiService
;
@Autowired
private
DingMessageUtils
dingMessageUtils
;
/**
/**
* 查询全部学校礼堂预约列表
* 查询全部学校礼堂预约列表
...
@@ -170,22 +172,60 @@ public class SchoolAuditoriumController extends BaseController
...
@@ -170,22 +172,60 @@ public class SchoolAuditoriumController extends BaseController
schoolAuditorium
.
setApplyTime
(
DateUtils
.
getNowDate
());
schoolAuditorium
.
setApplyTime
(
DateUtils
.
getNowDate
());
schoolAuditoriumService
.
submitApply
(
schoolAuditorium
,
userName
,
AUDITORIUMAPPLY
,
new
HashMap
<>());
schoolAuditoriumService
.
submitApply
(
schoolAuditorium
,
userName
,
AUDITORIUMAPPLY
,
new
HashMap
<>());
/** 发送发送钉钉审批实例 */
String
ddInstanceId
=
schoolAuditoriumService
.
sendDdInstance
(
schoolAuditorium
);
//转换时间
//转换时间
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
Date
time
=
schoolAuditorium
.
getApplyTime
();
Date
time
=
schoolAuditorium
.
getApplyTime
();
String
applyTime
=
format
.
format
(
time
);
String
applyTime
=
format
.
format
(
time
);
//发送钉钉消息到分管领导
//获取钉钉用户id
String
ddUserId
=
teacherService
.
getDdUserIdByUserId
(
schoolAuditorium
.
getLeadershipId
());
//发送钉钉消息给分管领导
DingMessageVo
messageVo
=
new
DingMessageVo
();
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
msg
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
();
msg
.
setOa
(
new
OapiMessageCorpconversationAsyncsendV2Request
.
OA
());
msg
.
getOa
().
setHead
(
new
OapiMessageCorpconversationAsyncsendV2Request
.
Head
());
msg
.
getOa
().
getHead
().
setText
(
"二中校园测试"
);
msg
.
getOa
().
setBody
(
new
OapiMessageCorpconversationAsyncsendV2Request
.
Body
());
msg
.
getOa
().
getBody
().
setAuthor
(
schoolAuditorium
.
getApplyName
());
msg
.
getOa
().
getBody
().
setContent
(
"申请内容:"
+
schoolAuditorium
.
getActivityName
());
msg
.
getOa
().
getBody
().
setTitle
(
"您好,您有礼堂预约申请等待审批!"
);
OapiMessageCorpconversationAsyncsendV2Request
.
Form
form1
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Form
();
form1
.
setKey
(
"申请时间:"
);
form1
.
setValue
(
applyTime
);
msg
.
getOa
().
getBody
().
setForm
(
Arrays
.
asList
(
form1
));
msg
.
getOa
().
setPcMessageUrl
(
"https://open.dingtalk.com/"
);
msg
.
getOa
().
setMessageUrl
(
"https://open.dingtalk.com/"
);
msg
.
setMsgtype
(
"oa"
);
OapiMessageCorpconversationAsyncsendV2Request
.
StatusBar
statusBar
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
StatusBar
();
statusBar
.
setStatusBg
(
"0xFFF65E5E"
);
statusBar
.
setStatusValue
(
"进行中"
);
msg
.
getOa
().
setStatusBar
(
statusBar
);
messageVo
.
setMsg
(
msg
);
messageVo
.
setToAllUser
(
false
);
messageVo
.
setUseridList
(
ddUserId
);
Long
ddTaskId
=
dingMessageUtils
.
sendMessage
(
messageVo
);
//更新消息任务id、钉钉流程实例id
SchoolAuditorium
auditorium
=
new
SchoolAuditorium
();
auditorium
.
setId
(
id
);
auditorium
.
setDdTaskId
(
ddTaskId
);
auditorium
.
setDdInstanceId
(
ddInstanceId
);
schoolAuditoriumService
.
updateById
(
auditorium
);
/**发送模板消息到分管领导*/
/**发送模板消息到分管领导*/
//获取用户openid
//获取用户openid
String
openId
=
teacherService
.
getOpenIdByUserId
(
schoolAuditorium
.
getLeadershipId
());
// String openId = teacherService.getOpenIdByUserId(schoolAuditorium.getLeadershipId());
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
// Map<String,Object> map = new HashMap<>();
map
.
put
(
"toUserOpenId"
,
openId
);
// map.put("toUserOpenId",openId);
map
.
put
(
"applyTime"
,
applyTime
);
// map.put("applyTime",applyTime);
map
.
put
(
"remark"
,
"请您尽快处理。"
);
// map.put("remark","请您尽快处理。");
map
.
put
(
"applyUser"
,
schoolAuditorium
.
getApplyName
());
// map.put("applyUser",schoolAuditorium.getApplyName());
map
.
put
(
"content"
,
schoolAuditorium
.
getActivityName
());
// map.put("content",schoolAuditorium.getActivityName());
map
.
put
(
"first"
,
"您好,您有礼堂预约申请等待审批!"
);
// map.put("first","您好,您有礼堂预约申请等待审批!");
VxTemlateSendApi
.
sendVxTemlate
(
map
);
// VxTemlateSendApi.sendVxTemlate(map);
// AuditoriumTemplate template = new AuditoriumTemplate();
// AuditoriumTemplate template = new AuditoriumTemplate();
// template.setToUserOpenId(openId);
// template.setToUserOpenId(openId);
// template.setFirst("您好,您有礼堂预约申请等待审批。");
// template.setFirst("您好,您有礼堂预约申请等待审批。");
...
@@ -244,6 +284,30 @@ public class SchoolAuditoriumController extends BaseController
...
@@ -244,6 +284,30 @@ public class SchoolAuditoriumController extends BaseController
/** 修改任务结果 */
/** 修改任务结果 */
schoolAuditoriumService
.
updateById
(
leave
);
schoolAuditoriumService
.
updateById
(
leave
);
/** 发送消息通知到申请人,审批结果 */
//获取钉钉用户id
String
ddUserId
=
teacherService
.
getDdUserIdByUserId
(
leave
.
getApplyId
());
//发送钉钉消息给分管领导
DingMessageVo
messageVo
=
new
DingMessageVo
();
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
msg
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
();
msg
.
setOa
(
new
OapiMessageCorpconversationAsyncsendV2Request
.
OA
());
msg
.
getOa
().
setHead
(
new
OapiMessageCorpconversationAsyncsendV2Request
.
Head
());
msg
.
getOa
().
getHead
().
setText
(
"二中校园测试"
);
msg
.
getOa
().
setBody
(
new
OapiMessageCorpconversationAsyncsendV2Request
.
Body
());
msg
.
getOa
().
getBody
().
setAuthor
(
leave
.
getLeadershipName
());
msg
.
getOa
().
getBody
().
setContent
(
flag
?
"已通过"
:
"已驳回"
);
msg
.
getOa
().
getBody
().
setTitle
(
"您好,您的礼堂预约申请已回复。"
);
msg
.
getOa
().
setPcMessageUrl
(
"https://open.dingtalk.com/"
);
msg
.
getOa
().
setMessageUrl
(
"https://open.dingtalk.com/"
);
msg
.
setMsgtype
(
"oa"
);
messageVo
.
setMsg
(
msg
);
messageVo
.
setToAllUser
(
false
);
messageVo
.
setUseridList
(
ddUserId
);
dingMessageUtils
.
sendMessage
(
messageVo
);
//修改消息任务状态为已完成
dingMessageUtils
.
updateStatusBar
(
leave
.
getDdTaskId
(),
"已完成"
,
"0xFF78C06E"
);
/**发送模板消息到申请人,审批结果*/
/**发送模板消息到申请人,审批结果*/
//获取申请人openId
//获取申请人openId
String
openId
=
teacherService
.
getOpenIdByUserId
(
leave
.
getApplyId
());
String
openId
=
teacherService
.
getOpenIdByUserId
(
leave
.
getApplyId
());
...
@@ -268,4 +332,4 @@ public class SchoolAuditoriumController extends BaseController
...
@@ -268,4 +332,4 @@ public class SchoolAuditoriumController extends BaseController
}
}
return
AjaxResult
.
success
(
"审批完成"
);
return
AjaxResult
.
success
(
"审批完成"
);
}
}
}
}
\ No newline at end of file
smart-campus/src/main/java/yangtz/cs/liu/campus/domain/auditorium/SchoolAuditorium.java
View file @
9837e388
...
@@ -29,6 +29,9 @@ public class SchoolAuditorium extends OurBaseEntity
...
@@ -29,6 +29,9 @@ public class SchoolAuditorium extends OurBaseEntity
/** 流程实例id */
/** 流程实例id */
private
String
instanceId
;
private
String
instanceId
;
/** 流程实例id */
private
String
ddInstanceId
;
/** 活动名称 */
/** 活动名称 */
private
String
activityName
;
private
String
activityName
;
...
@@ -103,6 +106,9 @@ public class SchoolAuditorium extends OurBaseEntity
...
@@ -103,6 +106,9 @@ public class SchoolAuditorium extends OurBaseEntity
/** 附件名称 */
/** 附件名称 */
private
String
fjmc
;
private
String
fjmc
;
/** 消息任务id */
private
Long
ddTaskId
;
/** 创建人id */
/** 创建人id */
private
Long
createById
;
private
Long
createById
;
...
...
smart-campus/src/main/java/yangtz/cs/liu/campus/mapper/teacher/SchoolTeacherMapper.java
View file @
9837e388
...
@@ -103,4 +103,16 @@ public interface SchoolTeacherMapper extends BaseMapper<SchoolTeacher>{
...
@@ -103,4 +103,16 @@ public interface SchoolTeacherMapper extends BaseMapper<SchoolTeacher>{
* 根据userId 查询 openId
* 根据userId 查询 openId
*/
*/
String
getOpenIdByUserId
(
Long
userId
);
String
getOpenIdByUserId
(
Long
userId
);
/**
*
* 根据userId 查询 ddUserId
*/
String
getDdUserIdByUserId
(
Long
userId
);
/**
*
* 根据userId 查询 unionId
*/
String
getUnionIdByUserId
(
Long
userId
);
}
}
smart-campus/src/main/java/yangtz/cs/liu/campus/service/auditorium/ISchoolAuditoriumService.java
View file @
9837e388
...
@@ -96,4 +96,10 @@ public interface ISchoolAuditoriumService extends IService<SchoolAuditorium>
...
@@ -96,4 +96,10 @@ public interface ISchoolAuditoriumService extends IService<SchoolAuditorium>
* @return
* @return
*/
*/
List
<
SchoolAuditoriumVo
>
findDoneTasks
(
String
key
,
SchoolAuditorium
entity
,
String
userId
);
List
<
SchoolAuditoriumVo
>
findDoneTasks
(
String
key
,
SchoolAuditorium
entity
,
String
userId
);
/**
* 发送钉钉审批实例
* @param schoolAuditorium
*/
String
sendDdInstance
(
SchoolAuditorium
schoolAuditorium
);
}
}
smart-campus/src/main/java/yangtz/cs/liu/campus/service/impl/auditorium/SchoolAuditoriumServiceImpl.java
View file @
9837e388
package
yangtz
.
cs
.
liu
.
campus
.
service
.
impl
.
auditorium
;
package
yangtz
.
cs
.
liu
.
campus
.
service
.
impl
.
auditorium
;
import
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.ruoyi.common.core.domain.entity.SysUser
;
import
com.ruoyi.common.core.domain.entity.SysUser
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.DateUtils
;
...
@@ -20,14 +21,15 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -20,14 +21,15 @@ import org.springframework.transaction.annotation.Transactional;
import
yangtz.cs.liu.activiti.service.IProcessService
;
import
yangtz.cs.liu.activiti.service.IProcessService
;
import
yangtz.cs.liu.campus.domain.auditorium.SchoolAuditorium
;
import
yangtz.cs.liu.campus.domain.auditorium.SchoolAuditorium
;
import
yangtz.cs.liu.campus.mapper.auditorium.SchoolAuditoriumMapper
;
import
yangtz.cs.liu.campus.mapper.auditorium.SchoolAuditoriumMapper
;
import
yangtz.cs.liu.campus.mapper.teacher.SchoolTeacherMapper
;
import
yangtz.cs.liu.campus.service.auditorium.ISchoolAuditoriumService
;
import
yangtz.cs.liu.campus.service.auditorium.ISchoolAuditoriumService
;
import
yangtz.cs.liu.campus.vo.auditorium.SchoolAuditoriumVo
;
import
yangtz.cs.liu.campus.vo.auditorium.SchoolAuditoriumVo
;
import
yangtz.cs.liu.dingding.utils.DingProcessInstanceUtils
;
import
yangtz.cs.liu.dingding.vo.DingProcessInstanceVo
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.text.SimpleDateFormat
;
import
java.util.Comparator
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
static
com
.
core
.
constant
.
ProcessCommon
.
PENDING
;
import
static
com
.
core
.
constant
.
ProcessCommon
.
PENDING
;
...
@@ -53,6 +55,10 @@ public class SchoolAuditoriumServiceImpl extends ServiceImpl<SchoolAuditoriumMap
...
@@ -53,6 +55,10 @@ public class SchoolAuditoriumServiceImpl extends ServiceImpl<SchoolAuditoriumMap
private
IProcessService
processService
;
private
IProcessService
processService
;
@Autowired
@Autowired
private
HistoryService
historyService
;
private
HistoryService
historyService
;
@Autowired
private
DingProcessInstanceUtils
instanceUtils
;
@Autowired
private
SchoolTeacherMapper
schoolTeacherMapper
;
/**
/**
* 查询学校礼堂预约
* 查询学校礼堂预约
...
@@ -271,6 +277,95 @@ public class SchoolAuditoriumServiceImpl extends ServiceImpl<SchoolAuditoriumMap
...
@@ -271,6 +277,95 @@ public class SchoolAuditoriumServiceImpl extends ServiceImpl<SchoolAuditoriumMap
List
<
SchoolAuditoriumVo
>
resList
=
list
.
stream
().
sorted
(
Comparator
.
comparing
(
SchoolAuditoriumVo:
:
getApplyTime
).
reversed
()).
collect
(
Collectors
.
toList
());
List
<
SchoolAuditoriumVo
>
resList
=
list
.
stream
().
sorted
(
Comparator
.
comparing
(
SchoolAuditoriumVo:
:
getApplyTime
).
reversed
()).
collect
(
Collectors
.
toList
());
return
resList
;
return
resList
;
}
}
/**
* 发送钉钉审批实例
* @param schoolAuditorium
* @return
*/
@Override
public
String
sendDdInstance
(
SchoolAuditorium
schoolAuditorium
)
{
//转换时间
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
Date
time
=
schoolAuditorium
.
getActivityTime
();
String
activityTime
=
format
.
format
(
time
);
//获取钉钉用户id
String
ddUserIdByUserId
=
schoolTeacherMapper
.
getDdUserIdByUserId
(
schoolAuditorium
.
getApplyId
());
DingProcessInstanceVo
dingProcessInstanceVo
=
new
DingProcessInstanceVo
();
dingProcessInstanceVo
.
setOriginatorUserId
(
ddUserIdByUserId
);
dingProcessInstanceVo
.
setDeptId
(
896846044L
);
dingProcessInstanceVo
.
setProcessCode
(
"PROC-DB0E3FEC-562B-4023-AA4A-CC33963D3537"
);
dingProcessInstanceVo
.
setCcList
(
Arrays
.
asList
(
ddUserIdByUserId
));
dingProcessInstanceVo
.
setCcPosition
(
"START"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestTargetSelectActioners
targetSelectActioners
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestTargetSelectActioners
();
targetSelectActioners
.
setActionerKey
(
"manual_1918_5cd3_6444_06af"
);
targetSelectActioners
.
setActionerUserIds
(
Arrays
.
asList
(
ddUserIdByUserId
));
dingProcessInstanceVo
.
setTargetSelectActioners
(
Arrays
.
asList
(
targetSelectActioners
));
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues1
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues1
.
setName
(
"活动名称"
);
componentValues1
.
setValue
(
schoolAuditorium
.
getActivityName
());
componentValues1
.
setComponentType
(
"TextField"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues2
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues2
.
setName
(
"活动场地"
);
componentValues2
.
setValue
(
schoolAuditorium
.
getActivityArea
());
componentValues2
.
setComponentType
(
"TextField"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues3
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues3
.
setName
(
"活动时间"
);
componentValues3
.
setValue
(
activityTime
);
componentValues3
.
setComponentType
(
"DDDateField"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues4
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues4
.
setName
(
"具体负责人"
);
componentValues4
.
setValue
(
schoolAuditorium
.
getSpecificUserName
());
componentValues4
.
setComponentType
(
"TextField"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues5
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues5
.
setName
(
"活动人数"
);
componentValues5
.
setValue
(
schoolAuditorium
.
getActivityNumber
().
toString
());
componentValues5
.
setComponentType
(
"NumberField"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues6
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues6
.
setName
(
"预计时长"
);
componentValues6
.
setValue
(
schoolAuditorium
.
getDuration
());
componentValues6
.
setComponentType
(
"TextField"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues7
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues7
.
setName
(
"是否彩排"
);
if
(
schoolAuditorium
.
getIsRehearsal
().
equals
(
"1"
)){
componentValues7
.
setValue
(
"是"
);
}
else
{
componentValues7
.
setValue
(
"否"
);
}
componentValues7
.
setComponentType
(
"DDSelectField"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues8
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues8
.
setName
(
"是否录像"
);
if
(
schoolAuditorium
.
getIsVideo
().
equals
(
"1"
)){
componentValues8
.
setValue
(
"是"
);
}
else
{
componentValues8
.
setValue
(
"否"
);
}
componentValues8
.
setComponentType
(
"DDSelectField"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues9
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues9
.
setName
(
"是否直播"
);
if
(
schoolAuditorium
.
getIsLive
().
equals
(
"1"
)){
componentValues9
.
setValue
(
"是"
);
}
else
{
componentValues9
.
setValue
(
"否"
);
}
componentValues9
.
setComponentType
(
"DDSelectField"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues10
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues10
.
setName
(
"是否需要大屏"
);
if
(
schoolAuditorium
.
getIsBigScreen
().
equals
(
"1"
)){
componentValues10
.
setValue
(
"是"
);
}
else
{
componentValues10
.
setValue
(
"否"
);
}
componentValues10
.
setComponentType
(
"DDSelectField"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues11
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues11
.
setName
(
"其他要求"
);
componentValues11
.
setValue
(
schoolAuditorium
.
getOtherRequirements
());
componentValues11
.
setComponentType
(
"TextField"
);
dingProcessInstanceVo
.
setFormComponentValues
(
Arrays
.
asList
(
componentValues1
,
componentValues2
,
componentValues3
,
componentValues4
,
componentValues5
,
componentValues6
,
componentValues7
,
componentValues8
,
componentValues9
,
componentValues10
,
componentValues11
));
return
instanceUtils
.
sendProcessInstance
(
dingProcessInstanceVo
);
}
}
}
...
...
smart-campus/src/main/java/yangtz/cs/liu/campus/service/impl/teacher/SchoolTeacherServiceImpl.java
View file @
9837e388
...
@@ -635,4 +635,30 @@ public class SchoolTeacherServiceImpl extends ServiceImpl<SchoolTeacherMapper, S
...
@@ -635,4 +635,30 @@ public class SchoolTeacherServiceImpl extends ServiceImpl<SchoolTeacherMapper, S
public
String
getOpenIdByUserId
(
Long
userId
)
{
public
String
getOpenIdByUserId
(
Long
userId
)
{
return
schoolTeacherMapper
.
getOpenIdByUserId
(
userId
);
return
schoolTeacherMapper
.
getOpenIdByUserId
(
userId
);
}
}
@Override
public
String
getDdUserIdByUserId
(
Long
userId
)
{
return
schoolTeacherMapper
.
getDdUserIdByUserId
(
userId
);
}
@Override
public
String
getUnionIdByUserId
(
Long
userId
)
{
return
schoolTeacherMapper
.
getUnionIdByUserId
(
userId
);
}
public
void
updateDdUserId
(
SysUser
sysUser
,
String
ddUserId
)
{
//更新教师表钉钉用户id
SchoolTeacher
schoolTeacher
=
new
SchoolTeacher
();
schoolTeacher
.
setId
(
sysUser
.
getUserId
());
schoolTeacher
.
setDdUserId
(
ddUserId
);
schoolTeacher
.
setUnionId
(
sysUser
.
getUnionId
());
schoolTeacherMapper
.
updateById
(
schoolTeacher
);
//更新用户表钉钉用户id
SysUser
user
=
new
SysUser
();
user
.
setUserId
(
sysUser
.
getUserId
());
user
.
setDdUserId
(
ddUserId
);
user
.
setUnionId
(
sysUser
.
getUnionId
());
sysUserMapper
.
updateUser
(
user
);
}
}
}
smart-campus/src/main/java/yangtz/cs/liu/campus/service/teacher/ISchoolTeacherService.java
View file @
9837e388
...
@@ -145,5 +145,17 @@ public interface ISchoolTeacherService extends IService<SchoolTeacher> {
...
@@ -145,5 +145,17 @@ public interface ISchoolTeacherService extends IService<SchoolTeacher> {
*/
*/
String
getOpenIdByUserId
(
Long
userId
);
String
getOpenIdByUserId
(
Long
userId
);
/**
* 根据userId 查询 ddUserId
* @param userId
* @return
*/
String
getDdUserIdByUserId
(
Long
userId
);
/**
* 根据userId 查询 unionId
* @param userId
* @return
*/
String
getUnionIdByUserId
(
Long
userId
);
}
}
smart-campus/src/main/java/yangtz/cs/liu/campus/vo/auditorium/SchoolAuditoriumVo.java
View file @
9837e388
...
@@ -17,6 +17,9 @@ public class SchoolAuditoriumVo extends ProcessBaseEntity {
...
@@ -17,6 +17,9 @@ public class SchoolAuditoriumVo extends ProcessBaseEntity {
/** 流程实例id */
/** 流程实例id */
private
String
instanceId
;
private
String
instanceId
;
/** 流程实例id */
private
String
ddInstanceId
;
/** 活动名称 */
/** 活动名称 */
@Excel
(
name
=
"活动名称"
)
@Excel
(
name
=
"活动名称"
)
private
String
activityName
;
private
String
activityName
;
...
@@ -117,6 +120,9 @@ public class SchoolAuditoriumVo extends ProcessBaseEntity {
...
@@ -117,6 +120,9 @@ public class SchoolAuditoriumVo extends ProcessBaseEntity {
/** 附件下载路径 */
/** 附件下载路径 */
private
String
fjxzlj
;
private
String
fjxzlj
;
/** 消息任务id */
private
Long
ddTaskId
;
/** 创建人id */
/** 创建人id */
private
Long
createById
;
private
Long
createById
;
/** 创建人 */
/** 创建人 */
...
...
smart-campus/src/main/java/yangtz/cs/liu/dingding/config/Constant.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
config
;
/**
* 项目中的常量定义类
*/
public
class
Constant
{
public
static
final
String
AES_TOKEN
=
"jGt2S7Kqh475czbgxtr7j1cQsXHWYia"
;
public
static
final
String
AES_KEY
=
"hz6q2qTgLGD5SHWLvVddOm9HfvrKgKBcDCCf145egyi"
;
public
static
final
String
OWNER_KEY
=
"dingclpf8qoxvinhksyh"
;
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/DdApiController.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
controller
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.aliyun.dingtalkcontact_1_0.models.GetUserResponse
;
import
com.aliyun.dingtalkoauth2_1_0.Client
;
import
com.aliyun.dingtalkoauth2_1_0.models.GetUserTokenRequest
;
import
com.aliyun.dingtalkoauth2_1_0.models.GetUserTokenResponse
;
import
com.aliyun.tea.TeaException
;
import
com.aliyun.teaopenapi.models.Config
;
import
com.aliyun.teautil.models.RuntimeOptions
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.redis.RedisCache
;
import
com.ruoyi.common.exception.ServiceException
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.html.EscapeUtil
;
import
com.ruoyi.common.utils.http.HttpUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.*
;
import
yangtz.cs.liu.dingding.config.Constant
;
import
yangtz.cs.liu.dingding.utils.AccessTokenUtils
;
import
yangtz.cs.liu.dingding.utils.DingCallbackCrypto
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URL
;
import
java.net.URLDecoder
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Formatter
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.concurrent.TimeUnit
;
@RestController
@RequestMapping
(
"/dd/user"
)
public
class
DdApiController
{
@Value
(
"${dd.appKey}"
)
private
String
appKey
;
@Value
(
"${dd.appSecret}"
)
private
String
appSecret
;
@Value
(
"${dd.redirect-uri}"
)
private
String
redirectUri
;
@Autowired
private
AccessTokenUtils
accessTokenUtils
;
@Autowired
private
RedisCache
redisCache
;
private
Logger
log
=
LoggerFactory
.
getLogger
(
DdApiController
.
class
);
/**
* 使用 Token 初始化账号Client
* @return Client
* @throws Exception
*/
public
static
com
.
aliyun
.
dingtalkoauth2_1_0
.
Client
createClient
()
{
Config
config
=
new
Config
();
config
.
protocol
=
"https"
;
config
.
regionId
=
"central"
;
try
{
return
new
com
.
aliyun
.
dingtalkoauth2_1_0
.
Client
(
config
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
static
com
.
aliyun
.
dingtalkcontact_1_0
.
Client
createClient1
()
{
com
.
aliyun
.
teaopenapi
.
models
.
Config
config
=
new
com
.
aliyun
.
teaopenapi
.
models
.
Config
();
config
.
protocol
=
"https"
;
config
.
regionId
=
"central"
;
try
{
return
new
com
.
aliyun
.
dingtalkcontact_1_0
.
Client
(
config
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 1.用户同意授权,获取code
*/
@GetMapping
(
"/getCode"
)
public
String
getCode
(
HttpServletResponse
response
)
{
log
.
info
(
"调用getCode"
);
// state 为开发者填写参数值
String
state
=
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
// 钉钉开放平台
String
url
=
"https://login.dingtalk.com/oauth2/auth?"
+
"redirect_uri="
+
redirectUri
+
"&response_type=code"
+
"&client_id=dingsuthkncsciwpeaxq"
+
"&scope=openid"
+
"&state="
+
state
+
"&prompt=consent"
;
return
"redirect:"
+
url
;
}
//https://login.dingtalk.com/oauth2/auth?redirect_uri=http://47.105.176.202:8135/&response_type=code&client_id=dingsuthkncsciwpeaxq&scope=openid&prompt=consent
/**
* 2.获取用户openId
*/
@PostMapping
(
"/getOpenId"
)
public
AjaxResult
getOpenId
(
String
code
)
{
AjaxResult
ajax
=
AjaxResult
.
success
();
com
.
aliyun
.
dingtalkoauth2_1_0
.
Client
client
=
DdApiController
.
createClient
();
GetUserTokenRequest
getUserTokenRequest
=
new
GetUserTokenRequest
()
.
setClientId
(
appKey
)
.
setClientSecret
(
appSecret
)
.
setCode
(
code
)
.
setGrantType
(
"authorization_code"
);
try
{
GetUserTokenResponse
userToken
=
client
.
getUserToken
(
getUserTokenRequest
);
String
accessToken
=
userToken
.
getBody
().
getAccessToken
();
if
(
StringUtils
.
isNotEmpty
(
accessToken
)){
String
openId
=
getOpenByToken
(
accessToken
);
if
(
StringUtils
.
isNotEmpty
(
openId
)){
ajax
.
put
(
"openId"
,
openId
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
ajax
;
}
public
String
getOpenByToken
(
String
token
)
{
String
openId
=
""
;
log
.
info
(
"接收到重定向消息"
);
com
.
aliyun
.
dingtalkcontact_1_0
.
Client
client
=
DdApiController
.
createClient1
();
com
.
aliyun
.
dingtalkcontact_1_0
.
models
.
GetUserHeaders
getUserHeaders
=
new
com
.
aliyun
.
dingtalkcontact_1_0
.
models
.
GetUserHeaders
();
getUserHeaders
.
xAcsDingtalkAccessToken
=
token
;
try
{
GetUserResponse
me
=
client
.
getUserWithOptions
(
"me"
,
getUserHeaders
,
new
RuntimeOptions
());
String
openId1
=
me
.
getBody
().
getOpenId
();
if
(
StringUtils
.
isNotEmpty
(
openId1
)){
openId
=
openId1
;
log
.
info
(
openId1
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
openId
;
}
/**
* 获取access_token
*/
@GetMapping
(
"/getAccessToken"
)
@ResponseBody
public
AjaxResult
getAccessToken
()
{
String
token
=
accessTokenUtils
.
getToken
();
return
AjaxResult
.
success
(
token
);
}
/**
* 获取签名
*/
@GetMapping
(
"/getsignature"
)
@ResponseBody
public
AjaxResult
getsignature
(
String
url
){
//获取accesToken
String
token
=
accessTokenUtils
.
getToken
();
url
=
decodeUrl
(
url
);
//获取jsapi_ticket
String
ticket
=
null
;
ticket
=
redisCache
.
getCacheObject
(
"ticket"
);
if
(
StringUtils
.
isEmpty
(
ticket
)){
String
ticketss
=
HttpUtils
.
sendGet
(
"https://oapi.dingtalk.com/get_jsapi_ticket?"
+
"access_token="
+
token
+
"&type=jsapi"
);
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
ticketss
);
ticket
=
jsonObject
.
get
(
"ticket"
).
toString
();
redisCache
.
setCacheObject
(
"ticket"
,
ticket
,
7200
,
TimeUnit
.
MILLISECONDS
);
}
//生成JS-SDK权限验证的签名
String
noncester
=
create_nonce_str
();
String
timestamp
=
create_timestamp
();
String
string1
;
String
signature
=
""
;
//3.
//注意这里参数名必须全部小写,且必须有序
string1
=
"jsapi_ticket="
+
ticket
+
"&noncestr="
+
noncester
+
"×tamp="
+
timestamp
+
"&url="
+
url
;
System
.
out
.
println
(
string1
);
log
.
info
(
string1
);
try
{
MessageDigest
sha1
=
MessageDigest
.
getInstance
(
"SHA-256"
);
sha1
.
reset
();
sha1
.
update
(
string1
.
getBytes
(
"UTF-8"
));
byteToHex
(
sha1
.
digest
());
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"noncestr"
,
noncester
);
map
.
put
(
"jsapi_ticket"
,
ticket
);
map
.
put
(
"timestamp"
,
timestamp
);
map
.
put
(
"url"
,
url
);
map
.
put
(
"signature"
,
signature
);
map
.
put
(
"cstoken"
,
token
);
return
AjaxResult
.
success
(
map
);
}
private
static
String
decodeUrl
(
String
url
)
{
StringBuilder
urlBuffer
=
new
StringBuilder
();
try
{
URL
urler
=
new
URL
(
url
);
urlBuffer
.
append
(
urler
.
getProtocol
());
urlBuffer
.
append
(
":"
);
if
(
urler
.
getAuthority
()
!=
null
&&
urler
.
getAuthority
().
length
()
>
0
)
{
urlBuffer
.
append
(
"//"
);
urlBuffer
.
append
(
urler
.
getAuthority
());
}
if
(
urler
.
getPath
()
!=
null
)
{
urlBuffer
.
append
(
urler
.
getPath
());
}
if
(
urler
.
getQuery
()
!=
null
)
{
urlBuffer
.
append
(
'?'
);
urlBuffer
.
append
(
URLDecoder
.
decode
(
urler
.
getQuery
(),
"utf-8"
));
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
urlBuffer
.
toString
();
}
private
static
String
create_nonce_str
()
{
return
UUID
.
randomUUID
().
toString
();
}
private
static
String
create_timestamp
()
{
return
Long
.
toString
(
System
.
currentTimeMillis
()
/
1000
);
}
// 字节数组转化成十六进制字符串
private
static
String
byteToHex
(
final
byte
[]
hash
)
{
Formatter
formatter
=
new
Formatter
();
for
(
byte
b
:
hash
)
{
formatter
.
format
(
"%02x"
,
b
);
}
String
result
=
formatter
.
toString
();
formatter
.
close
();
return
result
;
}
/**
* 事件与回调
* @param msg_signature
* @param timeStamp
* @param nonce
* @param json
* @return
*/
@GetMapping
(
"/callBack"
)
public
Map
<
String
,
String
>
callBack
(
@RequestParam
(
value
=
"msg_signature"
,
required
=
false
)
String
msg_signature
,
@RequestParam
(
value
=
"timestamp"
,
required
=
false
)
String
timeStamp
,
@RequestParam
(
value
=
"nonce"
,
required
=
false
)
String
nonce
,
@RequestBody
(
required
=
false
)
com
.
alibaba
.
fastjson
.
JSONObject
json
)
{
try
{
// 1. 从http请求中获取加解密参数
// 2. 使用加解密类型
// Constant.OWNER_KEY 说明:
// 1、开发者后台配置的订阅事件为应用级事件推送,此时OWNER_KEY为应用的APP_KEY。
// 2、调用订阅事件接口订阅的事件为企业级事件推送,
// 此时OWNER_KEY为:企业的appkey(企业内部应用)或SUITE_KEY(三方应用)
DingCallbackCrypto
callbackCrypto
=
new
DingCallbackCrypto
(
Constant
.
AES_TOKEN
,
Constant
.
AES_KEY
,
Constant
.
OWNER_KEY
);
String
encryptMsg
=
json
.
getString
(
"encrypt"
);
String
decryptMsg
=
callbackCrypto
.
getDecryptMsg
(
msg_signature
,
timeStamp
,
nonce
,
encryptMsg
);
// 3. 反序列化回调事件json数据
com
.
alibaba
.
fastjson
.
JSONObject
eventJson
=
JSON
.
parseObject
(
decryptMsg
);
String
eventType
=
eventJson
.
getString
(
"EventType"
);
// 4. 根据EventType分类处理
if
(
"check_url"
.
equals
(
eventType
))
{
// 测试回调url的正确性
log
.
info
(
"测试回调url的正确性"
);
}
else
if
(
"user_add_org"
.
equals
(
eventType
))
{
// 处理通讯录用户增加事件
log
.
info
(
"发生了:"
+
eventType
+
"事件"
);
}
else
{
// 添加其他已注册的
log
.
info
(
"发生了:"
+
eventType
+
"事件"
);
}
// 5. 返回success的加密数据
Map
<
String
,
String
>
successMap
=
callbackCrypto
.
getEncryptedMap
(
"success"
);
return
successMap
;
}
catch
(
DingCallbackCrypto
.
DingTalkEncryptException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/DdLoginController.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
controller
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.dingtalk.api.DefaultDingTalkClient
;
import
com.dingtalk.api.DingTalkClient
;
import
com.dingtalk.api.request.OapiUserGetuserinfoRequest
;
import
com.dingtalk.api.request.OapiV2UserGetRequest
;
import
com.dingtalk.api.response.OapiUserGetuserinfoResponse
;
import
com.dingtalk.api.response.OapiV2UserGetResponse
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.domain.entity.SysUser
;
import
com.ruoyi.common.exception.ServiceException
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.framework.web.service.SysLoginService
;
import
com.ruoyi.system.mapper.SysUserMapper
;
import
com.ruoyi.system.service.impl.SysUserServiceImpl
;
import
com.taobao.api.ApiException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
yangtz.cs.liu.campus.service.impl.teacher.SchoolTeacherServiceImpl
;
import
yangtz.cs.liu.dingding.utils.AccessTokenUtils
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
*
* 企业内部应用免登
* @author openapi@dingtalk
* 2020-11-3
*/
@RestController
@RequestMapping
(
"/dd/user"
)
public
class
DdLoginController
{
@Autowired
private
AccessTokenUtils
accessTokenUtils
;
@Autowired
private
SysUserServiceImpl
sysUserService
;
@Autowired
private
SysLoginService
loginService
;
@Autowired
private
SchoolTeacherServiceImpl
schoolTeacherService
;
/**
*
* @param code
* @return
* ServiceResult
* 2020-11-3
*/
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
GET
)
public
AjaxResult
login
(
@RequestParam
(
"code"
)
String
code
)
{
AjaxResult
ajaxResult
=
new
AjaxResult
();
// // 获取access_token,注意正式代码要有异常流处理
// String access_token= accessTokenUtils.getToken();
// // 获取用户信息
// DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/getuserinfo");
// OapiUserGetuserinfoRequest request = new OapiUserGetuserinfoRequest();
// request.setCode(code);
// request.setHttpMethod("GET");
// OapiUserGetuserinfoResponse response;
// try {
// response = client.execute(request, access_token);
// } catch (ApiException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// return null;
// }
// // 查询得到当前用户的userId
// // 获得到userId之后应用应该处理应用自身的登录会话管理(session),避免后续的业务交互(前端到应用服务端)每次都要重新获取用户身份,提升用户体验
// String userId = response.getUserid();
// if (StringUtils.isEmpty(userId)){
// throw new ServiceException("免登码已失效,请重新获取");
// }
// //获取用户详细信息
// Map<String, Object> userInfo = getUserInfo(userId, access_token);
// String phone = (String) userInfo.get("phone");
// String unionId = (String) userInfo.get("unionId");
SysUser
sysUser
=
sysUserService
.
selectUserByPhonenumber
(
"15888888888"
);
if
(
StringUtils
.
isNull
(
sysUser
)){
throw
new
ServiceException
(
"未查询到该用户信息"
);
}
//更新钉钉用户iid和unionId
// sysUser.setUnionId(unionId);
// schoolTeacherService.updateDdUserId(sysUser, userId);
String
token
=
loginService
.
loginNew
(
sysUser
);
ajaxResult
.
put
(
Constants
.
TOKEN
,
token
);
return
ajaxResult
;
}
public
Map
<
String
,
Object
>
getUserInfo
(
String
userId
,
String
token
){
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/user/get"
);
OapiV2UserGetRequest
req
=
new
OapiV2UserGetRequest
();
req
.
setUserid
(
userId
);
OapiV2UserGetResponse
rsp
=
client
.
execute
(
req
,
token
);
OapiV2UserGetResponse
.
UserGetResponse
result
=
rsp
.
getResult
();
String
name
=
result
.
getName
();
String
phone
=
result
.
getMobile
();
String
unionId
=
result
.
getUnionid
();
map
.
put
(
"userName"
,
name
);
map
.
put
(
"phone"
,
phone
);
map
.
put
(
"unionId"
,
unionId
);
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
map
;
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/DdSchoolDeptController.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
controller
;
import
com.ruoyi.common.core.page.TableDataInfo
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/dd/school/dept"
)
public
class
DdSchoolDeptController
{
@GetMapping
(
"/getDeptList"
)
public
TableDataInfo
getDeptList
(){
return
null
;
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/dingEvent/DingEventController.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
controller
.
dingEvent
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.annotation.*
;
import
yangtz.cs.liu.dingding.config.Constant
;
import
yangtz.cs.liu.dingding.utils.AccessTokenUtils
;
import
yangtz.cs.liu.dingding.utils.DingCallbackCrypto
;
import
java.util.Map
;
/**
* 钉钉事件与回调
*/
@RestController
@RequestMapping
(
"/dd/school/event"
)
public
class
DingEventController
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
DingEventController
.
class
);
@PostMapping
(
"/callBack"
)
public
Map
<
String
,
String
>
callBack
(
@RequestParam
(
value
=
"msg_signature"
,
required
=
false
)
String
msg_signature
,
@RequestParam
(
value
=
"timestamp"
,
required
=
false
)
String
timeStamp
,
@RequestParam
(
value
=
"nonce"
,
required
=
false
)
String
nonce
,
@RequestBody
(
required
=
false
)
JSONObject
json
)
{
try
{
// 1. 从http请求中获取加解密参数
// 2. 使用加解密类型
// Constant.OWNER_KEY 说明:
// 1、开发者后台配置的订阅事件为应用级事件推送,此时OWNER_KEY为应用的APP_KEY。
// 2、调用订阅事件接口订阅的事件为企业级事件推送,
// 此时OWNER_KEY为:企业的appkey(企业内部应用)或SUITE_KEY(三方应用)
DingCallbackCrypto
callbackCrypto
=
new
DingCallbackCrypto
(
Constant
.
AES_TOKEN
,
Constant
.
AES_KEY
,
Constant
.
OWNER_KEY
);
String
encryptMsg
=
json
.
getString
(
"encrypt"
);
String
decryptMsg
=
callbackCrypto
.
getDecryptMsg
(
msg_signature
,
timeStamp
,
nonce
,
encryptMsg
);
// 3. 反序列化回调事件json数据
JSONObject
eventJson
=
JSON
.
parseObject
(
decryptMsg
);
String
eventType
=
eventJson
.
getString
(
"EventType"
);
// 4. 根据EventType分类处理
if
(
"check_url"
.
equals
(
eventType
))
{
// 测试回调url的正确性
log
.
info
(
"测试回调url的正确性"
);
}
else
if
(
"user_add_org"
.
equals
(
eventType
))
{
// 处理通讯录用户增加事件
log
.
info
(
"发生了:"
+
eventType
+
"事件"
);
}
else
if
(
"bpms_instance_change"
.
equals
(
eventType
)){
// 处理审批实例事件
processInstance
(
eventJson
);
}
else
if
(
"bpms_task_change"
.
equals
(
eventType
)){
// 处理审批任务事件
eventJson
.
get
(
""
);
}
else
{
// 添加其他已注册的
log
.
info
(
"发生了:"
+
eventType
+
"事件"
);
}
// 5. 返回success的加密数据
Map
<
String
,
String
>
successMap
=
callbackCrypto
.
getEncryptedMap
(
"success"
);
return
successMap
;
}
catch
(
DingCallbackCrypto
.
DingTalkEncryptException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 处理审批实例事件
*/
public
void
processInstance
(
JSONObject
eventJson
){
//获取审批类型
String
type
=
eventJson
.
getString
(
"type"
);
//判断审批实例是否正常结束
if
(
"finish"
.
equals
(
type
)){
}
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/dingMessage/DingMessageController.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
controller
.
dingMessage
;
import
com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request
;
import
com.dingtalk.api.response.OapiMessageCorpconversationGetsendprogressResponse
;
import
com.dingtalk.api.response.OapiMessageCorpconversationGetsendresultResponse
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
yangtz.cs.liu.dingding.utils.DingMessageUtils
;
import
yangtz.cs.liu.dingding.vo.DingMessageVo
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* 消息通知
*/
@RestController
@RequestMapping
(
"/dd/school/message"
)
public
class
DingMessageController
{
@Autowired
private
DingMessageUtils
dingMessageUtils
;
/**
* 发送消息通知
*/
@PostMapping
(
"/sendMessage"
)
public
AjaxResult
sendMessage
(
@RequestBody
DingMessageVo
messageVo
){
AjaxResult
ajaxResult
=
AjaxResult
.
success
();
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
msg
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
();
msg
.
setOa
(
new
OapiMessageCorpconversationAsyncsendV2Request
.
OA
());
msg
.
getOa
().
setHead
(
new
OapiMessageCorpconversationAsyncsendV2Request
.
Head
());
msg
.
getOa
().
getHead
().
setText
(
"text"
);
msg
.
getOa
().
getHead
().
setBgcolor
(
"FFBBBBBB"
);
msg
.
getOa
().
setBody
(
new
OapiMessageCorpconversationAsyncsendV2Request
.
Body
());
msg
.
getOa
().
getBody
().
setAuthor
(
""
);
msg
.
getOa
().
getBody
().
setContent
(
""
);
msg
.
getOa
().
getBody
().
setTitle
(
"测试请假审批消息通知"
);
OapiMessageCorpconversationAsyncsendV2Request
.
Form
form1
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Form
();
form1
.
setKey
(
"开始时间"
);
form1
.
setValue
(
"2023-09-23 08:00"
);
OapiMessageCorpconversationAsyncsendV2Request
.
Form
form2
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Form
();
form2
.
setKey
(
"结束时间"
);
form2
.
setValue
(
"2023-09-24 18:00"
);
msg
.
getOa
().
getBody
().
setForm
(
Arrays
.
asList
(
form1
,
form2
));
msg
.
getOa
().
setPcMessageUrl
(
"https://open.dingtalk.com/"
);
msg
.
getOa
().
setMessageUrl
(
"https://open.dingtalk.com/"
);
msg
.
setMsgtype
(
"oa"
);
OapiMessageCorpconversationAsyncsendV2Request
.
StatusBar
statusBar
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
StatusBar
();
statusBar
.
setStatusBg
(
"0xFFF65E5E"
);
statusBar
.
setStatusValue
(
"进行中"
);
msg
.
getOa
().
setStatusBar
(
statusBar
);
messageVo
.
setMsg
(
msg
);
messageVo
.
setToAllUser
(
false
);
messageVo
.
setUseridList
(
"02144054095224351571"
);
Long
taskId
=
dingMessageUtils
.
sendMessage
(
messageVo
);
ajaxResult
.
put
(
"taskId"
,
taskId
);
return
ajaxResult
;
}
/**
* 撤回工作通知消息
*/
@GetMapping
(
"/recallMessage"
)
public
AjaxResult
recallMessage
(
Long
taskId
){
String
message
=
dingMessageUtils
.
recallMessage
(
taskId
);
return
AjaxResult
.
success
(
message
);
}
/**
* 更新工作通知状态栏
*/
@GetMapping
(
"/updateStatusBar"
)
public
AjaxResult
updateStatusBar
(
Long
taskId
,
String
statusValue
,
String
statusBg
){
String
message
=
dingMessageUtils
.
updateStatusBar
(
taskId
,
statusValue
,
statusBg
);
return
AjaxResult
.
success
(
message
);
}
/**
* 获取工作通知消息的发送进度
*/
@GetMapping
(
"/getSendProgress"
)
public
AjaxResult
getSendProgress
(
Long
taskId
){
OapiMessageCorpconversationGetsendprogressResponse
.
AsyncSendProgress
sendProgress
=
dingMessageUtils
.
getSendProgress
(
taskId
);
return
AjaxResult
.
success
(
sendProgress
);
}
/**
* 获取工作通知消息的发送结果
*/
@GetMapping
(
"/getSendResult"
)
public
AjaxResult
getSendResult
(
Long
taskId
){
OapiMessageCorpconversationGetsendresultResponse
.
AsyncSendResult
sendResult
=
dingMessageUtils
.
getSendResult
(
taskId
);
return
AjaxResult
.
success
(
sendResult
);
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/dingProcess/DingProcessController.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
controller
.
dingProcess
;
import
com.aliyun.dingtalkworkflow_1_0.models.ProcessForecastResponseBody
;
import
com.aliyun.dingtalkworkflow_1_0.models.QuerySchemaByProcessCodeResponseBody
;
import
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
yangtz.cs.liu.dingding.utils.DingProcessInstanceUtils
;
import
yangtz.cs.liu.dingding.vo.DingHandleVo
;
import
yangtz.cs.liu.dingding.vo.DingProcessInstanceVo
;
import
yangtz.cs.liu.dingding.vo.DingTransferVo
;
import
java.util.Arrays
;
import
java.util.Map
;
/**
* 审批实例
*/
@RestController
@RequestMapping
(
"/dd/school/instance"
)
public
class
DingProcessController
{
@Autowired
private
DingProcessInstanceUtils
instanceUtils
;
/**
* 发送审批实例
*/
@PostMapping
(
"/createInstance"
)
public
AjaxResult
createInstance
(
@RequestBody
DingProcessInstanceVo
instanceVo
){
AjaxResult
ajaxResult
=
AjaxResult
.
success
();
DingProcessInstanceVo
dingProcessInstanceVo
=
new
DingProcessInstanceVo
();
// StartProcessInstanceRequest.StartProcessInstanceRequestApprovers approvers = new StartProcessInstanceRequest.StartProcessInstanceRequestApprovers();
// approvers.setActionType("NONE");
// approvers.setUserIds(Arrays.asList("02144054095224351571"));
// dingProcessInstanceVo.setApprovers(Arrays.asList(approvers));
dingProcessInstanceVo
.
setOriginatorUserId
(
"02144054095224351571"
);
dingProcessInstanceVo
.
setDeptId
(
896846044L
);
dingProcessInstanceVo
.
setProcessCode
(
"PROC-D907CDA3-F8C7-4E4F-8A8B-6A9E71287295"
);
dingProcessInstanceVo
.
setCcList
(
Arrays
.
asList
(
"02144054095224351571"
));
dingProcessInstanceVo
.
setCcPosition
(
"START"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestTargetSelectActioners
targetSelectActioners
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestTargetSelectActioners
();
targetSelectActioners
.
setActionerKey
(
"manual_1918_5cd3_de98_c68d"
);
targetSelectActioners
.
setActionerUserIds
(
Arrays
.
asList
(
"02144054095224351571"
));
dingProcessInstanceVo
.
setTargetSelectActioners
(
Arrays
.
asList
(
targetSelectActioners
));
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues1
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues1
.
setName
(
"请假类型"
);
componentValues1
.
setValue
(
"事假"
);
componentValues1
.
setComponentType
(
"DDSelectField"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues2
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues2
.
setName
(
"[\"开始时间\",\"结束时间\"]"
);
componentValues2
.
setValue
(
"[\"2023-09-20 08:00\",\"2019-09-20 18:00\"]"
);
componentValues2
.
setComponentType
(
"DDDateRangeField"
);
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
componentValues3
=
new
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
();
componentValues3
.
setName
(
"请假事由"
);
componentValues3
.
setValue
(
"有事"
);
componentValues3
.
setComponentType
(
"TextField"
);
dingProcessInstanceVo
.
setFormComponentValues
(
Arrays
.
asList
(
componentValues1
,
componentValues2
,
componentValues3
));
String
instanceId
=
instanceUtils
.
sendProcessInstance
(
dingProcessInstanceVo
);
ajaxResult
.
put
(
"instanceId"
,
instanceId
);
return
ajaxResult
;
}
/**
* 获取表单schema
*/
@GetMapping
(
"/getSchema"
)
public
AjaxResult
getSchema
(
String
processCode
){
QuerySchemaByProcessCodeResponseBody
.
QuerySchemaByProcessCodeResponseBodyResult
schema
=
instanceUtils
.
getSchema
(
processCode
);
return
AjaxResult
.
success
(
schema
);
}
/**
* 获取审批单流程中的节点信息
*/
@PostMapping
(
"/getForecast"
)
public
AjaxResult
getForecast
(
@RequestBody
DingProcessInstanceVo
instanceVo
){
ProcessForecastResponseBody
.
ProcessForecastResponseBodyResult
forecast
=
instanceUtils
.
getForecast
(
instanceVo
);
return
AjaxResult
.
success
(
forecast
);
}
/**
* 获取指定用户可见的审批表单列表
*/
@GetMapping
(
"/getTemplates"
)
public
AjaxResult
getTemplates
(
String
userId
,
Long
maxResults
,
Long
nextToken
){
return
AjaxResult
.
success
(
instanceUtils
.
getTemplates
(
userId
,
maxResults
,
nextToken
));
}
/**
* 获取当前企业所有可管理的表单
*/
@GetMapping
(
"/getManageTemplates"
)
public
AjaxResult
getManageTemplates
(
String
userId
){
return
AjaxResult
.
success
(
instanceUtils
.
getManageTemplates
(
userId
));
}
/**
* 获取单个审批实例详情
*/
@GetMapping
(
"/getProcessInstance"
)
public
AjaxResult
getProcessInstance
(
String
processInstanceId
){
return
AjaxResult
.
success
(
instanceUtils
.
getProcessInstance
(
processInstanceId
));
}
/**
* 撤销审批实例
*/
@GetMapping
(
"/terminate"
)
public
AjaxResult
terminate
(
String
processInstanceId
,
Boolean
isSystem
,
String
remark
,
String
operatingUserId
){
return
AjaxResult
.
success
(
instanceUtils
.
terminate
(
processInstanceId
,
isSystem
,
remark
,
operatingUserId
));
}
/**
* 同意或拒绝审批任务
*/
@PostMapping
(
"/handleProcessInstance"
)
public
AjaxResult
handleProcessInstance
(
DingHandleVo
handleVo
){
Map
<
String
,
Boolean
>
map
=
instanceUtils
.
handleProcessInstance
(
handleVo
);
return
AjaxResult
.
success
(
map
);
}
/**
* 转交审批任务
*/
@PostMapping
(
"/transferInstance"
)
public
AjaxResult
transferInstance
(
DingTransferVo
transferVo
){
Boolean
result
=
instanceUtils
.
transferInstance
(
transferVo
);
return
AjaxResult
.
success
(
result
);
}
/**
* 获取用户待审批数量
*/
@GetMapping
(
"/getUserTodoTasksNumbers"
)
public
AjaxResult
getUserTodoTasksNumbers
(
String
userId
){
Integer
userTodoTasksNumbers
=
instanceUtils
.
getUserTodoTasksNumbers
(
userId
);
return
AjaxResult
.
success
(
userTodoTasksNumbers
);
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/dingRole/DingRoleController.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
controller
.
dingRole
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/dd/school/role"
)
public
class
DingRoleController
{
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/controller/dingUser/DingUserController.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
controller
.
dingUser
;
import
com.ruoyi.common.core.controller.BaseController
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.page.TableDataInfo
;
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.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
yangtz.cs.liu.dingding.utils.DingUserUtils
;
/**
* 钉钉用户管理
*/
@RestController
@RequestMapping
(
"/dd/school/user"
)
public
class
DingUserController
extends
BaseController
{
@Autowired
private
DingUserUtils
dingUserUtils
;
/**
* 获取部门用户基础信息
*/
@GetMapping
(
"/getUserByDeptId"
)
public
TableDataInfo
getUserByDeptId
(
@RequestParam
(
"deptId"
)
Long
deptId
,
@RequestParam
(
"cursor"
)
Long
cursor
,
@RequestParam
(
"size"
)
Long
size
,
@RequestParam
(
"orderField"
)
String
orderField
,
@RequestParam
(
"containAccessLimit"
)
String
containAccessLimit
,
@RequestParam
(
"language"
)
String
language
)
{
return
getDataTable
(
dingUserUtils
.
getUserByDeptId
(
deptId
,
cursor
,
size
,
orderField
,
containAccessLimit
,
language
));
}
/**
* 获取部门用户完整信息
*/
@GetMapping
(
"/getUserInfoByDeptId"
)
public
TableDataInfo
getUserInfoByDeptId
(
@RequestParam
(
"deptId"
)
Long
deptId
,
@RequestParam
(
"cursor"
)
Long
cursor
,
@RequestParam
(
"size"
)
Long
size
,
@RequestParam
(
"orderField"
)
String
orderField
,
@RequestParam
(
"containAccessLimit"
)
String
containAccessLimit
,
@RequestParam
(
"language"
)
String
language
)
{
return
getDataTable
(
dingUserUtils
.
getUserInfoByDeptId
(
deptId
,
cursor
,
size
,
orderField
,
containAccessLimit
,
language
));
}
/**
* 获取用户详情
*/
@GetMapping
(
"/getUser"
)
public
AjaxResult
getUser
(
@RequestParam
(
"userId"
)
String
userId
){
return
AjaxResult
.
success
(
dingUserUtils
.
getUser
(
userId
));
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/AccessTokenUtils.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
utils
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.ruoyi.common.core.redis.RedisCache
;
import
com.ruoyi.common.utils.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.util.concurrent.TimeUnit
;
@Component
public
class
AccessTokenUtils
{
@Value
(
"${dd.access-token-uri}"
)
private
String
accessTokenUri
;
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
AccessTokenUtils
.
class
);
@Autowired
public
RedisCache
redisCache
;
/**
* 获取token
* @return
* @throws Exception
*/
public
String
getToken
(){
String
token
=
redisCache
.
getCacheObject
(
"dd_access_token"
);
if
(
StringUtils
.
isEmpty
(
token
)){
try
{
String
url
=
accessTokenUri
;
// 利用hutool的http工具类请求获取access_token
String
result
=
HttpUtil
.
get
(
url
);
// 将结果解析为json
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
result
);
// 获取access_token
String
accessToken
=
(
String
)
jsonObject
.
get
(
"access_token"
);
if
(!
StringUtils
.
isEmpty
(
accessToken
))
{
token
=
accessToken
;
log
.
info
(
accessToken
);
// 将access_token存入redis
redisCache
.
setCacheObject
(
"dd_access_token"
,
accessToken
,
7200
,
TimeUnit
.
MILLISECONDS
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
}
return
token
;
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingCallbackCrypto.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
utils
;
import
java.io.ByteArrayOutputStream
;
import
java.nio.charset.Charset
;
import
java.security.MessageDigest
;
import
java.security.Permission
;
import
java.security.PermissionCollection
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Random
;
import
java.security.Security
;
import
java.lang.reflect.Field
;
import
javax.crypto.Cipher
;
import
javax.crypto.spec.IvParameterSpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.codec.binary.Base64
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
yangtz.cs.liu.dingding.config.Constant
;
/**
* 钉钉开放平台加解密方法
* 在ORACLE官方网站下载JCE无限制权限策略文件
* JDK6的下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html
* JDK7的下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
* JDK8的下载地址 https://www.oracle.com/java/technologies/javase-jce8-downloads.html
*/
public
class
DingCallbackCrypto
{
private
static
final
Charset
CHARSET
=
Charset
.
forName
(
"utf-8"
);
private
static
final
Base64
base64
=
new
Base64
();
private
byte
[]
aesKey
;
private
String
token
;
private
String
corpId
;
/**
* ask getPaddingBytes key固定长度
**/
private
static
final
Integer
AES_ENCODE_KEY_LENGTH
=
43
;
/**
* 加密随机字符串字节长度
**/
private
static
final
Integer
RANDOM_LENGTH
=
16
;
/**
* 构造函数
*
* @param token 钉钉开放平台上,开发者设置的token
* @param encodingAesKey 钉钉开放台上,开发者设置的EncodingAESKey
* @param corpId 企业自建应用-事件订阅, 使用appKey
* 企业自建应用-注册回调地址, 使用corpId
* 第三方企业应用, 使用suiteKey
*
* @throws DingTalkEncryptException 执行失败,请查看该异常的错误码和具体的错误信息
*/
public
DingCallbackCrypto
(
String
token
,
String
encodingAesKey
,
String
corpId
)
throws
DingTalkEncryptException
{
if
(
null
==
encodingAesKey
||
encodingAesKey
.
length
()
!=
AES_ENCODE_KEY_LENGTH
)
{
throw
new
DingTalkEncryptException
(
DingTalkEncryptException
.
AES_KEY_ILLEGAL
);
}
this
.
token
=
token
;
this
.
corpId
=
corpId
;
aesKey
=
Base64
.
decodeBase64
(
encodingAesKey
+
"="
);
}
public
Map
<
String
,
String
>
getEncryptedMap
(
String
plaintext
)
throws
DingTalkEncryptException
{
return
getEncryptedMap
(
plaintext
,
System
.
currentTimeMillis
(),
Utils
.
getRandomStr
(
16
));
}
/**
* 将和钉钉开放平台同步的消息体加密,返回加密Map
*
* @param plaintext 传递的消息体明文
* @param timeStamp 时间戳
* @param nonce 随机字符串
* @return
* @throws DingTalkEncryptException
*/
public
Map
<
String
,
String
>
getEncryptedMap
(
String
plaintext
,
Long
timeStamp
,
String
nonce
)
throws
DingTalkEncryptException
{
if
(
null
==
plaintext
)
{
throw
new
DingTalkEncryptException
(
DingTalkEncryptException
.
ENCRYPTION_PLAINTEXT_ILLEGAL
);
}
if
(
null
==
timeStamp
)
{
throw
new
DingTalkEncryptException
(
DingTalkEncryptException
.
ENCRYPTION_TIMESTAMP_ILLEGAL
);
}
if
(
null
==
nonce
)
{
throw
new
DingTalkEncryptException
(
DingTalkEncryptException
.
ENCRYPTION_NONCE_ILLEGAL
);
}
// 加密
String
encrypt
=
encrypt
(
Utils
.
getRandomStr
(
RANDOM_LENGTH
),
plaintext
);
String
signature
=
getSignature
(
token
,
String
.
valueOf
(
timeStamp
),
nonce
,
encrypt
);
Map
<
String
,
String
>
resultMap
=
new
HashMap
<
String
,
String
>();
resultMap
.
put
(
"msg_signature"
,
signature
);
resultMap
.
put
(
"encrypt"
,
encrypt
);
resultMap
.
put
(
"timeStamp"
,
String
.
valueOf
(
timeStamp
));
resultMap
.
put
(
"nonce"
,
nonce
);
return
resultMap
;
}
/**
* 密文解密
*
* @param msgSignature 签名串
* @param timeStamp 时间戳
* @param nonce 随机串
* @param encryptMsg 密文
* @return 解密后的原文
* @throws DingTalkEncryptException
*/
public
String
getDecryptMsg
(
String
msgSignature
,
String
timeStamp
,
String
nonce
,
String
encryptMsg
)
throws
DingTalkEncryptException
{
//校验签名
String
signature
=
getSignature
(
token
,
timeStamp
,
nonce
,
encryptMsg
);
if
(!
signature
.
equals
(
msgSignature
))
{
throw
new
DingTalkEncryptException
(
DingTalkEncryptException
.
COMPUTE_SIGNATURE_ERROR
);
}
// 解密
String
result
=
decrypt
(
encryptMsg
);
return
result
;
}
/*
* 对明文加密.
* @param text 需要加密的明文
* @return 加密后base64编码的字符串
*/
private
String
encrypt
(
String
random
,
String
plaintext
)
throws
DingTalkEncryptException
{
try
{
byte
[]
randomBytes
=
random
.
getBytes
(
CHARSET
);
byte
[]
plainTextBytes
=
plaintext
.
getBytes
(
CHARSET
);
byte
[]
lengthByte
=
Utils
.
int2Bytes
(
plainTextBytes
.
length
);
byte
[]
corpidBytes
=
corpId
.
getBytes
(
CHARSET
);
ByteArrayOutputStream
byteStream
=
new
ByteArrayOutputStream
();
byteStream
.
write
(
randomBytes
);
byteStream
.
write
(
lengthByte
);
byteStream
.
write
(
plainTextBytes
);
byteStream
.
write
(
corpidBytes
);
byte
[]
padBytes
=
PKCS7Padding
.
getPaddingBytes
(
byteStream
.
size
());
byteStream
.
write
(
padBytes
);
byte
[]
unencrypted
=
byteStream
.
toByteArray
();
byteStream
.
close
();
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/CBC/NoPadding"
);
SecretKeySpec
keySpec
=
new
SecretKeySpec
(
aesKey
,
"AES"
);
IvParameterSpec
iv
=
new
IvParameterSpec
(
aesKey
,
0
,
16
);
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
keySpec
,
iv
);
byte
[]
encrypted
=
cipher
.
doFinal
(
unencrypted
);
String
result
=
base64
.
encodeToString
(
encrypted
);
return
result
;
}
catch
(
Exception
e
)
{
throw
new
DingTalkEncryptException
(
DingTalkEncryptException
.
COMPUTE_ENCRYPT_TEXT_ERROR
);
}
}
/*
* 对密文进行解密.
* @param text 需要解密的密文
* @return 解密得到的明文
*/
private
String
decrypt
(
String
text
)
throws
DingTalkEncryptException
{
byte
[]
originalArr
;
try
{
// 设置解密模式为AES的CBC模式
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/CBC/NoPadding"
);
SecretKeySpec
keySpec
=
new
SecretKeySpec
(
aesKey
,
"AES"
);
IvParameterSpec
iv
=
new
IvParameterSpec
(
Arrays
.
copyOfRange
(
aesKey
,
0
,
16
));
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
keySpec
,
iv
);
// 使用BASE64对密文进行解码
byte
[]
encrypted
=
Base64
.
decodeBase64
(
text
);
// 解密
originalArr
=
cipher
.
doFinal
(
encrypted
);
}
catch
(
Exception
e
)
{
throw
new
DingTalkEncryptException
(
DingTalkEncryptException
.
COMPUTE_DECRYPT_TEXT_ERROR
);
}
String
plainText
;
String
fromCorpid
;
try
{
// 去除补位字符
byte
[]
bytes
=
PKCS7Padding
.
removePaddingBytes
(
originalArr
);
// 分离16位随机字符串,网络字节序和corpId
byte
[]
networkOrder
=
Arrays
.
copyOfRange
(
bytes
,
16
,
20
);
int
plainTextLegth
=
Utils
.
bytes2int
(
networkOrder
);
plainText
=
new
String
(
Arrays
.
copyOfRange
(
bytes
,
20
,
20
+
plainTextLegth
),
CHARSET
);
fromCorpid
=
new
String
(
Arrays
.
copyOfRange
(
bytes
,
20
+
plainTextLegth
,
bytes
.
length
),
CHARSET
);
}
catch
(
Exception
e
)
{
throw
new
DingTalkEncryptException
(
DingTalkEncryptException
.
COMPUTE_DECRYPT_TEXT_LENGTH_ERROR
);
}
// corpid不相同的情况
if
(!
fromCorpid
.
equals
(
corpId
))
{
throw
new
DingTalkEncryptException
(
DingTalkEncryptException
.
COMPUTE_DECRYPT_TEXT_CORPID_ERROR
);
}
return
plainText
;
}
/**
* 数字签名
*
* @param token isv token
* @param timestamp 时间戳
* @param nonce 随机串
* @param encrypt 加密文本
* @return
* @throws DingTalkEncryptException
*/
public
String
getSignature
(
String
token
,
String
timestamp
,
String
nonce
,
String
encrypt
)
throws
DingTalkEncryptException
{
try
{
String
[]
array
=
new
String
[]
{
token
,
timestamp
,
nonce
,
encrypt
};
Arrays
.
sort
(
array
);
System
.
out
.
println
(
JSON
.
toJSONString
(
array
));
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
sb
.
append
(
array
[
i
]);
}
String
str
=
sb
.
toString
();
System
.
out
.
println
(
str
);
MessageDigest
md
=
MessageDigest
.
getInstance
(
"SHA-1"
);
md
.
update
(
str
.
getBytes
());
byte
[]
digest
=
md
.
digest
();
StringBuffer
hexstr
=
new
StringBuffer
();
String
shaHex
=
""
;
for
(
int
i
=
0
;
i
<
digest
.
length
;
i
++)
{
shaHex
=
Integer
.
toHexString
(
digest
[
i
]
&
0xFF
);
if
(
shaHex
.
length
()
<
2
)
{
hexstr
.
append
(
0
);
}
hexstr
.
append
(
shaHex
);
}
return
hexstr
.
toString
();
}
catch
(
Exception
e
)
{
throw
new
DingTalkEncryptException
(
DingTalkEncryptException
.
COMPUTE_SIGNATURE_ERROR
);
}
}
public
static
class
Utils
{
public
Utils
()
{
}
public
static
String
getRandomStr
(
int
count
)
{
String
base
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
;
Random
random
=
new
Random
();
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
int
number
=
random
.
nextInt
(
base
.
length
());
sb
.
append
(
base
.
charAt
(
number
));
}
return
sb
.
toString
();
}
public
static
byte
[]
int2Bytes
(
int
count
)
{
byte
[]
byteArr
=
new
byte
[]
{(
byte
)(
count
>>
24
&
255
),
(
byte
)(
count
>>
16
&
255
),
(
byte
)(
count
>>
8
&
255
),
(
byte
)(
count
&
255
)};
return
byteArr
;
}
public
static
int
bytes2int
(
byte
[]
byteArr
)
{
int
count
=
0
;
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
count
<<=
8
;
count
|=
byteArr
[
i
]
&
255
;
}
return
count
;
}
}
public
static
class
PKCS7Padding
{
private
static
final
Charset
CHARSET
=
Charset
.
forName
(
"utf-8"
);
private
static
final
int
BLOCK_SIZE
=
32
;
public
PKCS7Padding
()
{
}
public
static
byte
[]
getPaddingBytes
(
int
count
)
{
int
amountToPad
=
32
-
count
%
32
;
if
(
amountToPad
==
0
)
{
amountToPad
=
32
;
}
char
padChr
=
chr
(
amountToPad
);
String
tmp
=
new
String
();
for
(
int
index
=
0
;
index
<
amountToPad
;
++
index
)
{
tmp
=
tmp
+
padChr
;
}
return
tmp
.
getBytes
(
CHARSET
);
}
public
static
byte
[]
removePaddingBytes
(
byte
[]
decrypted
)
{
int
pad
=
decrypted
[
decrypted
.
length
-
1
];
if
(
pad
<
1
||
pad
>
32
)
{
pad
=
0
;
}
return
Arrays
.
copyOfRange
(
decrypted
,
0
,
decrypted
.
length
-
pad
);
}
private
static
char
chr
(
int
a
)
{
byte
target
=
(
byte
)(
a
&
255
);
return
(
char
)
target
;
}
}
public
static
class
DingTalkEncryptException
extends
Exception
{
public
static
final
int
SUCCESS
=
0
;
public
static
final
int
ENCRYPTION_PLAINTEXT_ILLEGAL
=
900001
;
public
static
final
int
ENCRYPTION_TIMESTAMP_ILLEGAL
=
900002
;
public
static
final
int
ENCRYPTION_NONCE_ILLEGAL
=
900003
;
public
static
final
int
AES_KEY_ILLEGAL
=
900004
;
public
static
final
int
SIGNATURE_NOT_MATCH
=
900005
;
public
static
final
int
COMPUTE_SIGNATURE_ERROR
=
900006
;
public
static
final
int
COMPUTE_ENCRYPT_TEXT_ERROR
=
900007
;
public
static
final
int
COMPUTE_DECRYPT_TEXT_ERROR
=
900008
;
public
static
final
int
COMPUTE_DECRYPT_TEXT_LENGTH_ERROR
=
900009
;
public
static
final
int
COMPUTE_DECRYPT_TEXT_CORPID_ERROR
=
900010
;
private
static
Map
<
Integer
,
String
>
msgMap
=
new
HashMap
();
private
Integer
code
;
static
{
msgMap
.
put
(
0
,
"成功"
);
msgMap
.
put
(
900001
,
"加密明文文本非法"
);
msgMap
.
put
(
900002
,
"加密时间戳参数非法"
);
msgMap
.
put
(
900003
,
"加密随机字符串参数非法"
);
msgMap
.
put
(
900005
,
"签名不匹配"
);
msgMap
.
put
(
900006
,
"签名计算失败"
);
msgMap
.
put
(
900004
,
"不合法的aes key"
);
msgMap
.
put
(
900007
,
"计算加密文字错误"
);
msgMap
.
put
(
900008
,
"计算解密文字错误"
);
msgMap
.
put
(
900009
,
"计算解密文字长度不匹配"
);
msgMap
.
put
(
900010
,
"计算解密文字corpid不匹配"
);
}
public
Integer
getCode
()
{
return
this
.
code
;
}
public
DingTalkEncryptException
(
Integer
exceptionCode
)
{
super
((
String
)
msgMap
.
get
(
exceptionCode
));
this
.
code
=
exceptionCode
;
}
}
static
{
try
{
Security
.
setProperty
(
"crypto.policy"
,
"limited"
);
RemoveCryptographyRestrictions
();
}
catch
(
Exception
var1
)
{
}
}
private
static
void
RemoveCryptographyRestrictions
()
throws
Exception
{
Class
<?>
jceSecurity
=
getClazz
(
"javax.crypto.JceSecurity"
);
Class
<?>
cryptoPermissions
=
getClazz
(
"javax.crypto.CryptoPermissions"
);
Class
<?>
cryptoAllPermission
=
getClazz
(
"javax.crypto.CryptoAllPermission"
);
if
(
jceSecurity
!=
null
)
{
setFinalStaticValue
(
jceSecurity
,
"isRestricted"
,
false
);
PermissionCollection
defaultPolicy
=
(
PermissionCollection
)
getFieldValue
(
jceSecurity
,
"defaultPolicy"
,
(
Object
)
null
,
PermissionCollection
.
class
);
if
(
cryptoPermissions
!=
null
)
{
Map
<?,
?>
map
=
(
Map
)
getFieldValue
(
cryptoPermissions
,
"perms"
,
defaultPolicy
,
Map
.
class
);
map
.
clear
();
}
if
(
cryptoAllPermission
!=
null
)
{
Permission
permission
=
(
Permission
)
getFieldValue
(
cryptoAllPermission
,
"INSTANCE"
,
(
Object
)
null
,
Permission
.
class
);
defaultPolicy
.
add
(
permission
);
}
}
}
private
static
Class
<?>
getClazz
(
String
className
)
{
Class
clazz
=
null
;
try
{
clazz
=
Class
.
forName
(
className
);
}
catch
(
Exception
var3
)
{
}
return
clazz
;
}
private
static
void
setFinalStaticValue
(
Class
<?>
srcClazz
,
String
fieldName
,
Object
newValue
)
throws
Exception
{
Field
field
=
srcClazz
.
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
Field
modifiersField
=
Field
.
class
.
getDeclaredField
(
"modifiers"
);
modifiersField
.
setAccessible
(
true
);
modifiersField
.
setInt
(
field
,
field
.
getModifiers
()
&
-
17
);
field
.
set
((
Object
)
null
,
newValue
);
}
private
static
<
T
>
T
getFieldValue
(
Class
<?>
srcClazz
,
String
fieldName
,
Object
owner
,
Class
<
T
>
dstClazz
)
throws
Exception
{
Field
field
=
srcClazz
.
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
return
dstClazz
.
cast
(
field
.
get
(
owner
));
}
}
\ No newline at end of file
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingDeptUtils.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
utils
;
import
com.dingtalk.api.DefaultDingTalkClient
;
import
com.dingtalk.api.DingTalkClient
;
import
com.dingtalk.api.request.*
;
import
com.dingtalk.api.response.*
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.taobao.api.ApiException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
yangtz.cs.liu.dingding.vo.DingSchoolDeptVo
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 部门管理
*/
@Component
public
class
DingDeptUtils
{
@Autowired
private
AccessTokenUtils
accessTokenUtils
;
/**
* 创建部门
*/
public
Long
createDept
(
DingSchoolDeptVo
deptVo
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/department/create"
);
OapiV2DepartmentCreateRequest
req
=
new
OapiV2DepartmentCreateRequest
();
req
.
setName
(
deptVo
.
getName
());
req
.
setParentId
(
deptVo
.
getParentId
());
if
(
StringUtils
.
isNotNull
(
deptVo
.
getHideDept
())){
req
.
setHideDept
(
deptVo
.
getHideDept
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getDeptPermits
())){
req
.
setDeptPermits
(
deptVo
.
getDeptPermits
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getUserPermits
())){
req
.
setUserPermits
(
deptVo
.
getUserPermits
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getOuterDept
())){
req
.
setOuterDept
(
deptVo
.
getOuterDept
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getOuterDeptOnlySelf
())){
req
.
setOuterDeptOnlySelf
(
deptVo
.
getOuterDeptOnlySelf
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getOuterPermitUsers
())){
req
.
setOuterPermitUsers
(
deptVo
.
getOuterPermitUsers
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getOuterPermitDepts
())){
req
.
setOuterPermitDepts
(
deptVo
.
getOuterPermitDepts
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getCreateDeptGroup
())){
req
.
setCreateDeptGroup
(
deptVo
.
getCreateDeptGroup
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getAutoApproveApply
())){
req
.
setAutoApproveApply
(
deptVo
.
getAutoApproveApply
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getOrder
())){
req
.
setOrder
(
deptVo
.
getOrder
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getSourceIdentifier
())){
req
.
setSourceIdentifier
(
deptVo
.
getSourceIdentifier
());
}
OapiV2DepartmentCreateResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
().
getDeptId
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
0L
;
}
/**
* 更新部门
*/
public
String
updateDept
(
DingSchoolDeptVo
deptVo
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/department/update"
);
OapiV2DepartmentUpdateRequest
req
=
new
OapiV2DepartmentUpdateRequest
();
req
.
setDeptId
(
deptVo
.
getDeptId
());
if
(
StringUtils
.
isNotNull
(
deptVo
.
getParentId
())){
req
.
setParentId
(
deptVo
.
getParentId
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getOuterDept
())){
req
.
setOuterDept
(
deptVo
.
getOuterDept
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getHideDept
())){
req
.
setHideDept
(
deptVo
.
getHideDept
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getCreateDeptGroup
())){
req
.
setCreateDeptGroup
(
deptVo
.
getCreateDeptGroup
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getOrder
())){
req
.
setOrder
(
deptVo
.
getOrder
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getName
())){
req
.
setName
(
deptVo
.
getName
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getSourceIdentifier
())){
req
.
setSourceIdentifier
(
deptVo
.
getSourceIdentifier
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getDeptPermits
())){
req
.
setDeptPermits
(
deptVo
.
getDeptPermits
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getUserPermits
())){
req
.
setUserPermits
(
deptVo
.
getUserPermits
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getOuterPermitUsers
())){
req
.
setOuterPermitUsers
(
deptVo
.
getOuterPermitUsers
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getOuterPermitDepts
())){
req
.
setOuterPermitDepts
(
deptVo
.
getOuterPermitDepts
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getOuterDeptOnlySelf
())){
req
.
setOuterDeptOnlySelf
(
deptVo
.
getOuterDeptOnlySelf
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getLanguage
())){
req
.
setLanguage
(
deptVo
.
getLanguage
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getAutoAddUser
())){
req
.
setAutoAddUser
(
deptVo
.
getAutoAddUser
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getDeptManagerUseridList
())){
req
.
setDeptManagerUseridList
(
deptVo
.
getDeptManagerUseridList
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getGroupContainSubDept
())){
req
.
setGroupContainSubDept
(
deptVo
.
getGroupContainSubDept
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getGroupContainOuterDept
())){
req
.
setGroupContainOuterDept
(
deptVo
.
getGroupContainOuterDept
());
}
if
(
StringUtils
.
isNotNull
(
deptVo
.
getGroupContainHiddenDept
())){
req
.
setGroupContainHiddenDept
(
deptVo
.
getGroupContainHiddenDept
());
}
if
(
StringUtils
.
isNotEmpty
(
deptVo
.
getOrgDeptOwner
())){
req
.
setOrgDeptOwner
(
deptVo
.
getOrgDeptOwner
());
}
OapiV2DepartmentUpdateResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getErrmsg
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 删除部门
* @param deptId 部门id
* @return
*/
public
Boolean
deleteDept
(
Long
deptId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/department/delete"
);
OapiV2DepartmentDeleteRequest
req
=
new
OapiV2DepartmentDeleteRequest
();
req
.
setDeptId
(
deptId
);
OapiV2DepartmentDeleteResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
isSuccess
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
false
;
}
/**
* 获取部门详情
* @param deptId 部门id
* @param language 通讯录语言: zh_CN(默认):中文 , en_US:英文
* @return
*/
public
OapiV2DepartmentGetResponse
.
DeptGetResponse
getDept
(
Long
deptId
,
String
language
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/department/get"
);
OapiV2DepartmentGetRequest
req
=
new
OapiV2DepartmentGetRequest
();
req
.
setDeptId
(
deptId
);
if
(
StringUtils
.
isNotEmpty
(
language
)){
req
.
setLanguage
(
language
);
}
OapiV2DepartmentGetResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiV2DepartmentGetResponse
.
DeptGetResponse
();
}
/**
* 获取部门列表
* @param deptId 部门id
* @param language 通讯录语言: zh_CN(默认):中文 , en_US:英文
* @return
*/
public
List
<
OapiV2DepartmentListsubResponse
.
DeptBaseResponse
>
getDeptList
(
Long
deptId
,
String
language
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/department/listsub"
);
OapiV2DepartmentListsubRequest
req
=
new
OapiV2DepartmentListsubRequest
();
req
.
setDeptId
(
deptId
);
if
(
StringUtils
.
isNotEmpty
(
language
)){
req
.
setLanguage
(
language
);
}
OapiV2DepartmentListsubResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
ArrayList
<>();
}
/**
* 获取子部门id列表
* @param deptId 部门id
* @return
*/
public
OapiV2DepartmentListsubidResponse
.
DeptListSubIdResponse
getDeptIdList
(
Long
deptId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/department/listsubid"
);
OapiV2DepartmentListsubidRequest
req
=
new
OapiV2DepartmentListsubidRequest
();
req
.
setDeptId
(
deptId
);
OapiV2DepartmentListsubidResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiV2DepartmentListsubidResponse
.
DeptListSubIdResponse
();
}
/**
* 获取指定部门的所有父部门列表
* @param deptId 部门id
* @return
*/
public
OapiV2DepartmentListparentbydeptResponse
.
DeptListParentByDeptIdResponse
getParentByDept
(
Long
deptId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/department/listparentbydept"
);
OapiV2DepartmentListparentbydeptRequest
req
=
new
OapiV2DepartmentListparentbydeptRequest
();
req
.
setDeptId
(
deptId
);
OapiV2DepartmentListparentbydeptResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiV2DepartmentListparentbydeptResponse
.
DeptListParentByDeptIdResponse
();
}
/**
* 获取指定用户的所有父部门列表
* @param userId 用户id
* @return
*/
public
OapiV2DepartmentListparentbyuserResponse
.
DeptListParentByUserResponse
getParentByUser
(
String
userId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/department/listparentbyuser"
);
OapiV2DepartmentListparentbyuserRequest
req
=
new
OapiV2DepartmentListparentbyuserRequest
();
req
.
setUserid
(
userId
);
OapiV2DepartmentListparentbyuserResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiV2DepartmentListparentbyuserResponse
.
DeptListParentByUserResponse
();
}
/**
* 获取通讯录权限范围
*/
public
Map
<
String
,
Object
>
getScopes
(){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/auth/scopes"
);
OapiAuthScopesRequest
req
=
new
OapiAuthScopesRequest
();
req
.
setHttpMethod
(
"GET"
);
OapiAuthScopesResponse
rsp
=
client
.
execute
(
req
,
token
);
OapiAuthScopesResponse
.
AuthOrgScopes
authOrgScopes
=
rsp
.
getAuthOrgScopes
();
List
<
String
>
authUserField
=
rsp
.
getAuthUserField
();
map
.
put
(
"authOrgScopes"
,
authOrgScopes
);
map
.
put
(
"authUserField"
,
authUserField
);
return
map
;
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
map
;
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingMessageUtils.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
utils
;
import
com.dingtalk.api.DefaultDingTalkClient
;
import
com.dingtalk.api.DingTalkClient
;
import
com.dingtalk.api.request.*
;
import
com.dingtalk.api.response.*
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.taobao.api.ApiException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
yangtz.cs.liu.dingding.vo.DingMessageVo
;
/**
* 消息通知
*/
@Component
public
class
DingMessageUtils
{
@Value
(
"${dd.agentId}"
)
private
Long
agentId
;
@Autowired
private
AccessTokenUtils
accessTokenUtils
;
/**
* 发送消息通知
* @param messageVo
* @return
*/
public
Long
sendMessage
(
DingMessageVo
messageVo
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2"
);
OapiMessageCorpconversationAsyncsendV2Request
req
=
new
OapiMessageCorpconversationAsyncsendV2Request
();
req
.
setAgentId
(
agentId
);
if
(
StringUtils
.
isNotEmpty
(
messageVo
.
getUseridList
())){
req
.
setUseridList
(
messageVo
.
getUseridList
());
}
if
(
StringUtils
.
isNotEmpty
(
messageVo
.
getDeptIdList
())){
req
.
setDeptIdList
(
messageVo
.
getDeptIdList
());
}
if
(
StringUtils
.
isNotNull
(
messageVo
.
getToAllUser
())){
req
.
setToAllUser
(
messageVo
.
getToAllUser
());
}
if
(
StringUtils
.
isNotNull
(
messageVo
.
getMsg
())){
req
.
setMsg
(
messageVo
.
getMsg
());
}
OapiMessageCorpconversationAsyncsendV2Response
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getTaskId
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 撤回工作通知消息
*/
public
String
recallMessage
(
Long
taskId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/message/corpconversation/recall"
);
OapiMessageCorpconversationRecallRequest
req
=
new
OapiMessageCorpconversationRecallRequest
();
req
.
setAgentId
(
agentId
);
req
.
setMsgTaskId
(
taskId
);
OapiMessageCorpconversationRecallResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getErrmsg
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 更新工作通知状态栏
*/
public
String
updateStatusBar
(
Long
taskId
,
String
statusValue
,
String
statusBg
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/message/corpconversation/status_bar/update"
);
OapiMessageCorpconversationStatusBarUpdateRequest
req
=
new
OapiMessageCorpconversationStatusBarUpdateRequest
();
req
.
setAgentId
(
agentId
);
req
.
setTaskId
(
taskId
);
req
.
setStatusValue
(
statusValue
);
req
.
setStatusBg
(
statusBg
);
OapiMessageCorpconversationStatusBarUpdateResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getErrmsg
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 获取工作通知消息的发送进度
*/
public
OapiMessageCorpconversationGetsendprogressResponse
.
AsyncSendProgress
getSendProgress
(
Long
taskId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/message/corpconversation/getsendprogress"
);
OapiMessageCorpconversationGetsendprogressRequest
req
=
new
OapiMessageCorpconversationGetsendprogressRequest
();
req
.
setAgentId
(
agentId
);
req
.
setTaskId
(
taskId
);
OapiMessageCorpconversationGetsendprogressResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getProgress
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiMessageCorpconversationGetsendprogressResponse
.
AsyncSendProgress
();
}
/**
* 获取工作通知消息的发送结果
*/
public
OapiMessageCorpconversationGetsendresultResponse
.
AsyncSendResult
getSendResult
(
Long
taskId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/message/corpconversation/getsendresult"
);
OapiMessageCorpconversationGetsendresultRequest
req
=
new
OapiMessageCorpconversationGetsendresultRequest
();
req
.
setAgentId
(
agentId
);
req
.
setTaskId
(
taskId
);
OapiMessageCorpconversationGetsendresultResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getSendResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiMessageCorpconversationGetsendresultResponse
.
AsyncSendResult
();
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingProcessInstanceUtils.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
utils
;
import
com.aliyun.dingtalkworkflow_1_0.models.*
;
import
com.aliyun.tea.TeaException
;
import
com.aliyun.teautil.models.RuntimeOptions
;
import
com.ruoyi.common.utils.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
yangtz.cs.liu.dingding.vo.DingHandleVo
;
import
yangtz.cs.liu.dingding.vo.DingProcessInstanceVo
;
import
yangtz.cs.liu.dingding.vo.DingTransferVo
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 审批实例
*/
@Component
public
class
DingProcessInstanceUtils
{
@Value
(
"${dd.agentId}"
)
private
Long
agentId
;
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
DingProcessInstanceUtils
.
class
);
@Autowired
private
AccessTokenUtils
accessTokenUtils
;
/**
* 使用 Token 初始化账号Client
* @return Client
* @throws Exception
*/
public
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
createClient
()
{
com
.
aliyun
.
teaopenapi
.
models
.
Config
config
=
new
com
.
aliyun
.
teaopenapi
.
models
.
Config
();
config
.
protocol
=
"https"
;
config
.
regionId
=
"central"
;
try
{
return
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
(
config
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 发送审批实例
*/
public
String
sendProcessInstance
(
DingProcessInstanceVo
instanceVo
)
{
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
client
=
createClient
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
StartProcessInstanceHeaders
startProcessInstanceHeaders
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
StartProcessInstanceHeaders
();
startProcessInstanceHeaders
.
xAcsDingtalkAccessToken
=
token
;
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
StartProcessInstanceRequest
startProcessInstanceRequest
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
StartProcessInstanceRequest
();
if
(
StringUtils
.
isNotEmpty
(
instanceVo
.
getCcPosition
())){
startProcessInstanceRequest
.
setCcPosition
(
instanceVo
.
getCcPosition
());
}
if
(
StringUtils
.
isNotEmpty
(
instanceVo
.
getOriginatorUserId
())){
startProcessInstanceRequest
.
setOriginatorUserId
(
instanceVo
.
getOriginatorUserId
());
}
if
(
StringUtils
.
isNotNull
(
instanceVo
.
getDeptId
())){
startProcessInstanceRequest
.
setDeptId
(
instanceVo
.
getDeptId
());
}
if
(
StringUtils
.
isNotNull
(
instanceVo
.
getApprovers
())){
startProcessInstanceRequest
.
setApprovers
(
instanceVo
.
getApprovers
());
}
if
(
StringUtils
.
isNotNull
(
instanceVo
.
getCcList
())){
startProcessInstanceRequest
.
setCcList
(
instanceVo
.
getCcList
());
}
if
(
StringUtils
.
isNotNull
(
instanceVo
.
getTargetSelectActioners
())){
startProcessInstanceRequest
.
setTargetSelectActioners
(
instanceVo
.
getTargetSelectActioners
());
}
if
(
StringUtils
.
isNotNull
(
instanceVo
.
getFormComponentValues
())){
startProcessInstanceRequest
.
setFormComponentValues
(
instanceVo
.
getFormComponentValues
());
}
if
(
StringUtils
.
isNotEmpty
(
instanceVo
.
getProcessCode
())){
startProcessInstanceRequest
.
setProcessCode
(
instanceVo
.
getProcessCode
());
}
startProcessInstanceRequest
.
setMicroappAgentId
(
agentId
);
try
{
StartProcessInstanceResponse
startProcessInstanceResponse
=
client
.
startProcessInstanceWithOptions
(
startProcessInstanceRequest
,
startProcessInstanceHeaders
,
new
RuntimeOptions
());
return
startProcessInstanceResponse
.
getBody
().
getInstanceId
();
}
catch
(
TeaException
err
)
{
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
catch
(
Exception
_err
)
{
TeaException
err
=
new
TeaException
(
_err
.
getMessage
(),
_err
);
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
return
""
;
}
/**
* 查询单个审批详情
*/
public
GetProcessInstanceResponseBody
.
GetProcessInstanceResponseBodyResult
getProcessInstance
(
String
processInstanceId
)
{
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
client
=
createClient
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetProcessInstanceHeaders
getProcessInstanceHeaders
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetProcessInstanceHeaders
();
getProcessInstanceHeaders
.
xAcsDingtalkAccessToken
=
token
;
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetProcessInstanceRequest
getProcessInstanceRequest
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetProcessInstanceRequest
()
.
setProcessInstanceId
(
processInstanceId
);
try
{
GetProcessInstanceResponse
processInstanceWithOptions
=
client
.
getProcessInstanceWithOptions
(
getProcessInstanceRequest
,
getProcessInstanceHeaders
,
new
RuntimeOptions
());
return
processInstanceWithOptions
.
getBody
().
getResult
();
}
catch
(
TeaException
err
)
{
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
catch
(
Exception
_err
)
{
TeaException
err
=
new
TeaException
(
_err
.
getMessage
(),
_err
);
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
return
new
GetProcessInstanceResponseBody
.
GetProcessInstanceResponseBodyResult
();
}
/**
* 撤销审批实例
*/
public
Boolean
terminate
(
String
processInstanceId
,
Boolean
isSystem
,
String
remark
,
String
operatingUserId
)
{
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
client
=
createClient
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
TerminateProcessInstanceHeaders
terminateProcessInstanceHeaders
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
TerminateProcessInstanceHeaders
();
terminateProcessInstanceHeaders
.
xAcsDingtalkAccessToken
=
token
;
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
TerminateProcessInstanceRequest
terminateProcessInstanceRequest
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
TerminateProcessInstanceRequest
();
if
(
StringUtils
.
isNotNull
(
isSystem
)){
terminateProcessInstanceRequest
.
setIsSystem
(
isSystem
);
}
if
(
StringUtils
.
isNotEmpty
(
processInstanceId
)){
terminateProcessInstanceRequest
.
setProcessInstanceId
(
processInstanceId
);
}
if
(
StringUtils
.
isNotEmpty
(
remark
)){
terminateProcessInstanceRequest
.
setRemark
(
remark
);
}
if
(
StringUtils
.
isNotEmpty
(
operatingUserId
)){
terminateProcessInstanceRequest
.
setOperatingUserId
(
operatingUserId
);
}
try
{
TerminateProcessInstanceResponse
terminateProcessInstanceResponse
=
client
.
terminateProcessInstanceWithOptions
(
terminateProcessInstanceRequest
,
terminateProcessInstanceHeaders
,
new
RuntimeOptions
());
return
terminateProcessInstanceResponse
.
getBody
().
getResult
();
}
catch
(
TeaException
err
)
{
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
catch
(
Exception
_err
)
{
TeaException
err
=
new
TeaException
(
_err
.
getMessage
(),
_err
);
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
return
false
;
}
/**
* 获取表单schema
*/
public
QuerySchemaByProcessCodeResponseBody
.
QuerySchemaByProcessCodeResponseBodyResult
getSchema
(
String
processCode
)
{
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
client
=
createClient
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
QuerySchemaByProcessCodeHeaders
querySchemaByProcessCodeHeaders
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
QuerySchemaByProcessCodeHeaders
();
querySchemaByProcessCodeHeaders
.
xAcsDingtalkAccessToken
=
token
;
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
QuerySchemaByProcessCodeRequest
querySchemaByProcessCodeRequest
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
QuerySchemaByProcessCodeRequest
()
.
setProcessCode
(
processCode
);
try
{
QuerySchemaByProcessCodeResponse
querySchemaByProcessCodeResponse
=
client
.
querySchemaByProcessCodeWithOptions
(
querySchemaByProcessCodeRequest
,
querySchemaByProcessCodeHeaders
,
new
RuntimeOptions
());
return
querySchemaByProcessCodeResponse
.
getBody
().
getResult
();
}
catch
(
TeaException
err
)
{
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
catch
(
Exception
_err
)
{
TeaException
err
=
new
TeaException
(
_err
.
getMessage
(),
_err
);
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
return
new
QuerySchemaByProcessCodeResponseBody
.
QuerySchemaByProcessCodeResponseBodyResult
();
}
/**
* 获取审批单流程中的节点信息
*/
public
ProcessForecastResponseBody
.
ProcessForecastResponseBodyResult
getForecast
(
DingProcessInstanceVo
instanceVo
)
{
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
client
=
createClient
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
ProcessForecastHeaders
processForecastHeaders
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
ProcessForecastHeaders
();
processForecastHeaders
.
xAcsDingtalkAccessToken
=
token
;
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
ProcessForecastRequest
processForecastRequest
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
ProcessForecastRequest
();
if
(
StringUtils
.
isNotNull
(
instanceVo
.
getDeptId
())){
processForecastRequest
.
setDeptId
(
instanceVo
.
getDeptId
().
intValue
());
}
if
(
StringUtils
.
isNotEmpty
(
instanceVo
.
getUserId
())){
processForecastRequest
.
setUserId
(
instanceVo
.
getUserId
());
}
if
(
StringUtils
.
isNotEmpty
(
instanceVo
.
getProcessCode
())){
processForecastRequest
.
setProcessCode
(
instanceVo
.
getProcessCode
());
}
if
(
StringUtils
.
isNotNull
(
instanceVo
.
getFormComponentValues1
())){
processForecastRequest
.
setFormComponentValues
(
instanceVo
.
getFormComponentValues1
());
}
try
{
ProcessForecastResponse
processForecastResponse
=
client
.
processForecastWithOptions
(
processForecastRequest
,
processForecastHeaders
,
new
RuntimeOptions
());
return
processForecastResponse
.
getBody
().
getResult
();
}
catch
(
TeaException
err
)
{
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
catch
(
Exception
_err
)
{
TeaException
err
=
new
TeaException
(
_err
.
getMessage
(),
_err
);
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
return
new
ProcessForecastResponseBody
.
ProcessForecastResponseBodyResult
();
}
/**
* 获取指定用户可见的审批表单列表
*/
public
ListUserVisibleBpmsProcessesResponseBody
.
ListUserVisibleBpmsProcessesResponseBodyResult
getTemplates
(
String
userId
,
Long
maxResults
,
Long
nextToken
)
{
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
client
=
createClient
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
ListUserVisibleBpmsProcessesHeaders
listUserVisibleBpmsProcessesHeaders
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
ListUserVisibleBpmsProcessesHeaders
();
listUserVisibleBpmsProcessesHeaders
.
xAcsDingtalkAccessToken
=
token
;
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
ListUserVisibleBpmsProcessesRequest
listUserVisibleBpmsProcessesRequest
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
ListUserVisibleBpmsProcessesRequest
()
.
setUserId
(
userId
)
.
setMaxResults
(
maxResults
)
.
setNextToken
(
nextToken
);
try
{
ListUserVisibleBpmsProcessesResponse
listUserVisibleBpmsProcessesResponse
=
client
.
listUserVisibleBpmsProcessesWithOptions
(
listUserVisibleBpmsProcessesRequest
,
listUserVisibleBpmsProcessesHeaders
,
new
RuntimeOptions
());
return
listUserVisibleBpmsProcessesResponse
.
getBody
().
getResult
();
}
catch
(
TeaException
err
)
{
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
catch
(
Exception
_err
)
{
TeaException
err
=
new
TeaException
(
_err
.
getMessage
(),
_err
);
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
return
new
ListUserVisibleBpmsProcessesResponseBody
.
ListUserVisibleBpmsProcessesResponseBodyResult
();
}
/**
* 获取当前企业所有可管理的表单
*/
public
List
<
GetManageProcessByStaffIdResponseBody
.
GetManageProcessByStaffIdResponseBodyResult
>
getManageTemplates
(
String
userId
)
{
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
client
=
createClient
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetManageProcessByStaffIdHeaders
getManageProcessByStaffIdHeaders
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetManageProcessByStaffIdHeaders
();
getManageProcessByStaffIdHeaders
.
xAcsDingtalkAccessToken
=
token
;
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetManageProcessByStaffIdRequest
getManageProcessByStaffIdRequest
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetManageProcessByStaffIdRequest
()
.
setUserId
(
userId
);
try
{
GetManageProcessByStaffIdResponse
manageProcessByStaffIdWithOptions
=
client
.
getManageProcessByStaffIdWithOptions
(
getManageProcessByStaffIdRequest
,
getManageProcessByStaffIdHeaders
,
new
RuntimeOptions
());
return
manageProcessByStaffIdWithOptions
.
getBody
().
getResult
();
}
catch
(
TeaException
err
)
{
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
catch
(
Exception
_err
)
{
TeaException
err
=
new
TeaException
(
_err
.
getMessage
(),
_err
);
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
return
new
ArrayList
<>();
}
/**
* 同意或拒绝审批任务
*/
public
Map
<
String
,
Boolean
>
handleProcessInstance
(
DingHandleVo
handleVo
)
{
Map
<
String
,
Boolean
>
map
=
new
HashMap
<>();
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
client
=
createClient
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
ExecuteProcessInstanceHeaders
executeProcessInstanceHeaders
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
ExecuteProcessInstanceHeaders
();
executeProcessInstanceHeaders
.
xAcsDingtalkAccessToken
=
token
;
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
ExecuteProcessInstanceRequest
executeProcessInstanceRequest
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
ExecuteProcessInstanceRequest
();
if
(
StringUtils
.
isNotEmpty
(
handleVo
.
getRemark
())){
executeProcessInstanceRequest
.
setRemark
(
handleVo
.
getRemark
());
}
if
(
StringUtils
.
isNotEmpty
(
handleVo
.
getResult
())){
executeProcessInstanceRequest
.
setResult
(
handleVo
.
getResult
());
}
if
(
StringUtils
.
isNotEmpty
(
handleVo
.
getProcessInstanceId
())){
executeProcessInstanceRequest
.
setProcessInstanceId
(
handleVo
.
getProcessInstanceId
());
}
if
(
StringUtils
.
isNotNull
(
handleVo
.
getTaskId
())){
executeProcessInstanceRequest
.
setTaskId
(
handleVo
.
getTaskId
());
}
if
(
StringUtils
.
isNotEmpty
(
handleVo
.
getActionerUserId
())){
executeProcessInstanceRequest
.
setActionerUserId
(
handleVo
.
getActionerUserId
());
}
try
{
ExecuteProcessInstanceResponse
executeProcessInstanceResponse
=
client
.
executeProcessInstanceWithOptions
(
executeProcessInstanceRequest
,
executeProcessInstanceHeaders
,
new
RuntimeOptions
());
Boolean
result
=
executeProcessInstanceResponse
.
getBody
().
getResult
();
Boolean
success
=
executeProcessInstanceResponse
.
getBody
().
getSuccess
();
map
.
put
(
"result"
,
result
);
map
.
put
(
"success"
,
success
);
return
map
;
}
catch
(
TeaException
err
)
{
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
catch
(
Exception
_err
)
{
TeaException
err
=
new
TeaException
(
_err
.
getMessage
(),
_err
);
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
return
map
;
}
/**
* 转交OA审批任务
*/
public
Boolean
transferInstance
(
DingTransferVo
transferVo
)
{
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
client
=
createClient
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
RedirectWorkflowTaskHeaders
redirectWorkflowTaskHeaders
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
RedirectWorkflowTaskHeaders
();
redirectWorkflowTaskHeaders
.
xAcsDingtalkAccessToken
=
token
;
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
RedirectWorkflowTaskRequest
redirectWorkflowTaskRequest
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
RedirectWorkflowTaskRequest
();
if
(
StringUtils
.
isNotEmpty
(
transferVo
.
getOperateUserId
())){
redirectWorkflowTaskRequest
.
setOperateUserId
(
transferVo
.
getOperateUserId
());
}
if
(
StringUtils
.
isNotEmpty
(
transferVo
.
getRemark
())){
redirectWorkflowTaskRequest
.
setRemark
(
transferVo
.
getRemark
());
}
if
(
StringUtils
.
isNotEmpty
(
transferVo
.
getToUserId
())){
redirectWorkflowTaskRequest
.
setToUserId
(
transferVo
.
getToUserId
());
}
if
(
StringUtils
.
isNotEmpty
(
transferVo
.
getActionName
())){
redirectWorkflowTaskRequest
.
setActionName
(
transferVo
.
getActionName
());
}
if
(
StringUtils
.
isNotNull
(
transferVo
.
getTaskId
())){
redirectWorkflowTaskRequest
.
setTaskId
(
transferVo
.
getTaskId
());
}
try
{
RedirectWorkflowTaskResponse
redirectWorkflowTaskResponse
=
client
.
redirectWorkflowTaskWithOptions
(
redirectWorkflowTaskRequest
,
redirectWorkflowTaskHeaders
,
new
RuntimeOptions
());
return
redirectWorkflowTaskResponse
.
getBody
().
getResult
();
}
catch
(
TeaException
err
)
{
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
catch
(
Exception
_err
)
{
TeaException
err
=
new
TeaException
(
_err
.
getMessage
(),
_err
);
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
return
false
;
}
/**
* 获取用户待审批数量
*/
public
Integer
getUserTodoTasksNumbers
(
String
userId
)
{
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
Client
client
=
createClient
();
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetUserTodoTaskSumHeaders
getUserTodoTaskSumHeaders
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetUserTodoTaskSumHeaders
();
getUserTodoTaskSumHeaders
.
xAcsDingtalkAccessToken
=
token
;
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetUserTodoTaskSumRequest
getUserTodoTaskSumRequest
=
new
com
.
aliyun
.
dingtalkworkflow_1_0
.
models
.
GetUserTodoTaskSumRequest
()
.
setUserId
(
userId
);
try
{
GetUserTodoTaskSumResponse
userTodoTaskSumWithOptions
=
client
.
getUserTodoTaskSumWithOptions
(
getUserTodoTaskSumRequest
,
getUserTodoTaskSumHeaders
,
new
RuntimeOptions
());
return
userTodoTaskSumWithOptions
.
getBody
().
getResult
();
}
catch
(
TeaException
err
)
{
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
catch
(
Exception
_err
)
{
TeaException
err
=
new
TeaException
(
_err
.
getMessage
(),
_err
);
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
return
0
;
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingRoleUtils.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
utils
;
import
com.dingtalk.api.DefaultDingTalkClient
;
import
com.dingtalk.api.DingTalkClient
;
import
com.dingtalk.api.request.*
;
import
com.dingtalk.api.response.*
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.taobao.api.ApiException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
yangtz.cs.liu.dingding.vo.DingSchoolRoleVo
;
/**
* 角色管理
*/
@Component
public
class
DingRoleUtils
{
@Autowired
private
AccessTokenUtils
accessTokenUtils
;
/**
* 创建角色
*/
public
String
createRole
(
DingSchoolRoleVo
roleVo
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/role/add_role"
);
OapiRoleAddRoleRequest
req
=
new
OapiRoleAddRoleRequest
();
req
.
setRoleName
(
roleVo
.
getRoleName
());
req
.
setGroupId
(
roleVo
.
getGroupId
());
OapiRoleAddRoleResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getErrmsg
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 创建角色组
*/
public
String
createRoleGroup
(
String
name
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/role/add_role_group"
);
OapiRoleAddrolegroupRequest
req
=
new
OapiRoleAddrolegroupRequest
();
req
.
setName
(
name
);
OapiRoleAddrolegroupResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getErrmsg
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 更新角色名称
* @param roleId 角色id
* @param roleName 角色名称
* @return
*/
public
String
updateRoleName
(
Long
roleId
,
String
roleName
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/role/update_role"
);
OapiRoleUpdateRoleRequest
req
=
new
OapiRoleUpdateRoleRequest
();
req
.
setRoleId
(
roleId
);
req
.
setRoleName
(
roleName
);
OapiRoleUpdateRoleResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getErrmsg
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 批量增加员工角色
*/
public
String
createRolesForemps
(
String
roleIds
,
String
userIds
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/role/addrolesforemps"
);
OapiRoleAddrolesforempsRequest
req
=
new
OapiRoleAddrolesforempsRequest
();
req
.
setRoleIds
(
roleIds
);
req
.
setUserIds
(
userIds
);
OapiRoleAddrolesforempsResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getErrmsg
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 删除角色
*/
public
String
deleteRole
(
Long
roleId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/role/deleterole"
);
OapiRoleDeleteroleRequest
req
=
new
OapiRoleDeleteroleRequest
();
req
.
setRoleId
(
roleId
);
OapiRoleDeleteroleResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getErrmsg
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 批量删除员工角色
*/
public
String
deleteRolesForemps
(
String
roleIds
,
String
userIds
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/role/removerolesforemps"
);
OapiRoleRemoverolesforempsRequest
req
=
new
OapiRoleRemoverolesforempsRequest
();
req
.
setRoleIds
(
roleIds
);
req
.
setUserIds
(
userIds
);
OapiRoleRemoverolesforempsResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getErrmsg
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 设定角色成员管理范围
* @param deptIds 部门ID列表,多个部门id之间使用逗号分隔。最多支持50个部门ID,不传则设置范围为所有人。
* @param roleId 角色ID
* @param userId 员工在企业中的userId
*/
public
String
updateRoleScope
(
String
deptIds
,
Long
roleId
,
String
userId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/role/scope/update"
);
OapiRoleScopeUpdateRequest
req
=
new
OapiRoleScopeUpdateRequest
();
req
.
setUserid
(
userId
);
req
.
setRoleId
(
roleId
);
if
(
StringUtils
.
isNotEmpty
(
deptIds
)){
req
.
setDeptIds
(
deptIds
);
}
OapiRoleScopeUpdateResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getErrmsg
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 获取角色组列表
*/
public
OapiRoleGetrolegroupResponse
.
OpenRoleGroup
getRoleGroupList
(
Long
groupId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/role/getrolegroup"
);
OapiRoleGetrolegroupRequest
req
=
new
OapiRoleGetrolegroupRequest
();
req
.
setGroupId
(
groupId
);
OapiRoleGetrolegroupResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getRoleGroup
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiRoleGetrolegroupResponse
.
OpenRoleGroup
();
}
/**
* 获取角色列表
*/
public
OapiRoleListResponse
.
PageVo
getRoleList
(
Long
size
,
Long
offset
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/role/list"
);
OapiRoleListRequest
req
=
new
OapiRoleListRequest
();
if
(
StringUtils
.
isNotNull
(
size
)){
req
.
setSize
(
size
);
}
if
(
StringUtils
.
isNotNull
(
offset
)){
req
.
setOffset
(
offset
);
}
OapiRoleListResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiRoleListResponse
.
PageVo
();
}
/**
* 获取角色详情
*/
public
OapiRoleGetroleResponse
.
OpenRole
getRole
(
Long
roleId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/role/getrole"
);
OapiRoleGetroleRequest
req
=
new
OapiRoleGetroleRequest
();
req
.
setRoleId
(
roleId
);
OapiRoleGetroleResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getRole
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiRoleGetroleResponse
.
OpenRole
();
}
/**
* 获取指定角色的员工列表
*/
public
OapiRoleSimplelistResponse
.
PageVo
getRoleSimpleList
(
Long
roleId
,
Long
offset
,
Long
size
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/role/simplelist"
);
OapiRoleSimplelistRequest
req
=
new
OapiRoleSimplelistRequest
();
req
.
setRoleId
(
roleId
);
if
(
StringUtils
.
isNotNull
(
size
)){
req
.
setSize
(
size
);
}
if
(
StringUtils
.
isNotNull
(
offset
)){
req
.
setOffset
(
offset
);
}
OapiRoleSimplelistResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiRoleSimplelistResponse
.
PageVo
();
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingTaskUtils.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
utils
;
import
com.aliyun.tea.TeaException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
yangtz.cs.liu.dingding.vo.DingSchoolTaskVo
;
/**
* 待办已办任务
*/
@Component
public
class
DingTaskUtils
{
@Autowired
private
AccessTokenUtils
accessTokenUtils
;
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
DingTaskUtils
.
class
);
/**
* 使用 Token 初始化账号Client
* @return Client
* @throws Exception
*/
public
com
.
aliyun
.
dingtalktodo_1_0
.
Client
createClient
()
{
com
.
aliyun
.
teaopenapi
.
models
.
Config
config
=
new
com
.
aliyun
.
teaopenapi
.
models
.
Config
();
config
.
protocol
=
"https"
;
config
.
regionId
=
"central"
;
try
{
return
new
com
.
aliyun
.
dingtalktodo_1_0
.
Client
(
config
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 创建待办任务
*/
public
void
createTask
(
DingSchoolTaskVo
taskVo
)
{
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
com
.
aliyun
.
dingtalktodo_1_0
.
Client
client
=
createClient
();
com
.
aliyun
.
dingtalktodo_1_0
.
models
.
CreateTodoTaskHeaders
createTodoTaskHeaders
=
new
com
.
aliyun
.
dingtalktodo_1_0
.
models
.
CreateTodoTaskHeaders
();
createTodoTaskHeaders
.
xAcsDingtalkAccessToken
=
token
;
com
.
aliyun
.
dingtalktodo_1_0
.
models
.
CreateTodoTaskRequest
createTodoTaskRequest
=
new
com
.
aliyun
.
dingtalktodo_1_0
.
models
.
CreateTodoTaskRequest
()
.
setSourceId
(
taskVo
.
getSourceId
())
.
setSubject
(
taskVo
.
getSubject
())
.
setCreatorId
(
taskVo
.
getCreatorId
())
.
setDescription
(
taskVo
.
getDescription
())
.
setDueTime
(
taskVo
.
getDueTime
())
.
setExecutorIds
(
taskVo
.
getExecutorIds
())
.
setParticipantIds
(
taskVo
.
getParticipantIds
())
.
setDetailUrl
(
taskVo
.
getDetailUrl
())
.
setIsOnlyShowExecutor
(
taskVo
.
getIsOnlyShowExecutor
())
.
setPriority
(
taskVo
.
getPriority
())
.
setNotifyConfigs
(
taskVo
.
getNotifyConfigs
())
.
setOperatorId
(
taskVo
.
getOperatorId
());
try
{
client
.
createTodoTaskWithOptions
(
taskVo
.
getCreatorId
(),
createTodoTaskRequest
,
createTodoTaskHeaders
,
new
com
.
aliyun
.
teautil
.
models
.
RuntimeOptions
());
}
catch
(
TeaException
err
)
{
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
catch
(
Exception
_err
)
{
TeaException
err
=
new
TeaException
(
_err
.
getMessage
(),
_err
);
if
(!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
code
)
&&
!
com
.
aliyun
.
teautil
.
Common
.
empty
(
err
.
message
))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
log
.
info
(
err
.
code
);
log
.
info
(
err
.
message
);
}
}
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/utils/DingUserUtils.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
utils
;
import
com.dingtalk.api.DefaultDingTalkClient
;
import
com.dingtalk.api.DingTalkClient
;
import
com.dingtalk.api.request.*
;
import
com.dingtalk.api.response.*
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.taobao.api.ApiException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
yangtz.cs.liu.dingding.vo.DingSchoolUserVo
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 用户管理
*/
@Component
public
class
DingUserUtils
{
@Autowired
private
AccessTokenUtils
accessTokenUtils
;
/**
* 创建用户
*/
public
OapiV2UserCreateResponse
.
UserCreateResponse
createUser
(
DingSchoolUserVo
userVo
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/user/create"
);
OapiV2UserCreateRequest
req
=
new
OapiV2UserCreateRequest
();
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getUserid
())){
req
.
setUserid
(
userVo
.
getUserid
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getName
())){
req
.
setName
(
userVo
.
getName
());
}
if
(
StringUtils
.
isNotNull
(
userVo
.
getSeniorMode
())){
req
.
setSeniorMode
(
userVo
.
getSeniorMode
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getMobile
())){
req
.
setMobile
(
userVo
.
getMobile
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getTitle
())){
req
.
setTitle
(
userVo
.
getTitle
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getEmail
())){
req
.
setEmail
(
userVo
.
getEmail
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getOrgEmail
())){
req
.
setOrgEmail
(
userVo
.
getOrgEmail
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getOrgEmailType
())){
req
.
setOrgEmailType
(
userVo
.
getOrgEmailType
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getDeptTitleList
())){
req
.
setDeptTitleList
(
userVo
.
getDeptTitleList
());
}
if
(
StringUtils
.
isNotNull
(
userVo
.
getHideMobile
())){
req
.
setHideMobile
(
userVo
.
getHideMobile
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getTelephone
())){
req
.
setTelephone
(
userVo
.
getTelephone
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getJobNumber
())){
req
.
setJobNumber
(
userVo
.
getJobNumber
());
}
if
(
StringUtils
.
isNotNull
(
userVo
.
getHiredDate
())){
req
.
setHiredDate
(
userVo
.
getHiredDate
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getWorkPlace
())){
req
.
setWorkPlace
(
userVo
.
getWorkPlace
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getRemark
())){
req
.
setRemark
(
userVo
.
getRemark
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getDeptIdList
())){
req
.
setDeptIdList
(
userVo
.
getDeptIdList
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getDeptOrderList
())){
req
.
setDeptOrderList
(
userVo
.
getDeptOrderList
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getExtension
())){
req
.
setExtension
(
userVo
.
getExtension
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getManagerUserid
())){
req
.
setManagerUserid
(
userVo
.
getManagerUserid
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getLoginEmail
())){
req
.
setLoginEmail
(
userVo
.
getLoginEmail
());
}
OapiV2UserCreateResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiV2UserCreateResponse
.
UserCreateResponse
();
}
/**
* 更新用户信息
*/
public
String
updateUser
(
DingSchoolUserVo
userVo
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/user/update"
);
OapiV2UserUpdateRequest
req
=
new
OapiV2UserUpdateRequest
();
req
.
setUserid
(
userVo
.
getUserid
());
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getName
())){
req
.
setName
(
userVo
.
getName
());
}
if
(
StringUtils
.
isNotNull
(
userVo
.
getHideMobile
())){
req
.
setHideMobile
(
userVo
.
getHideMobile
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getTelephone
())){
req
.
setTelephone
(
userVo
.
getTelephone
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getJobNumber
())){
req
.
setJobNumber
(
userVo
.
getJobNumber
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getManagerUserid
())){
req
.
setManagerUserid
(
userVo
.
getManagerUserid
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getTitle
())){
req
.
setTitle
(
userVo
.
getTitle
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getEmail
())){
req
.
setEmail
(
userVo
.
getEmail
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getOrgEmail
())){
req
.
setOrgEmail
(
userVo
.
getOrgEmail
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getWorkPlace
())){
req
.
setWorkPlace
(
userVo
.
getWorkPlace
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getRemark
())){
req
.
setRemark
(
userVo
.
getRemark
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getDeptIdList
())){
req
.
setDeptIdList
(
userVo
.
getDeptIdList
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getDeptOrderList
())){
req
.
setDeptOrderList
(
userVo
.
getDeptOrderList
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getDeptTitleList
())){
req
.
setDeptTitleList
(
userVo
.
getDeptTitleList
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getExtension
())){
req
.
setExtension
(
userVo
.
getExtension
());
}
if
(
StringUtils
.
isNotNull
(
userVo
.
getSeniorMode
())){
req
.
setSeniorMode
(
userVo
.
getSeniorMode
());
}
if
(
StringUtils
.
isNotNull
(
userVo
.
getHiredDate
())){
req
.
setHiredDate
(
userVo
.
getHiredDate
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getLanguage
())){
req
.
setLanguage
(
userVo
.
getLanguage
());
}
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getForceUpdateFields
())){
req
.
setForceUpdateFields
(
userVo
.
getForceUpdateFields
());
}
OapiV2UserUpdateResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getErrmsg
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 删除用户信息
*/
public
String
deleteUser
(
String
userId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/user/delete"
);
OapiV2UserDeleteRequest
req
=
new
OapiV2UserDeleteRequest
();
req
.
setUserid
(
userId
);
OapiV2UserDeleteResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getErrmsg
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 获取用户详情
*/
public
OapiV2UserGetResponse
.
UserGetResponse
getUser
(
String
userId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/user/get"
);
OapiV2UserGetRequest
req
=
new
OapiV2UserGetRequest
();
req
.
setUserid
(
userId
);
OapiV2UserGetResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiV2UserGetResponse
.
UserGetResponse
();
}
/**
* 获取部门用户基础信息
* @param deptId 部门ID,如果是根部门,该参数传1。
* @param cursor 分页查询的游标,最开始传0,后续传返回参数中的next_cursor值。
* @param size 分页长度,最大值100。
* @param orderField 部门成员的排序规则。默认值,custom。
* entry_asc:代表按照进入部门的时间升序。
* entry_desc:代表按照进入部门的时间降序。
* modify_asc:代表按照部门信息修改时间升序。
* modify_desc:代表按照部门信息修改时间降序。
* custom:代表用户定义(未定义时按照拼音)排序。
* @param containAccessLimit 是否返回访问受限的员工。 true:是 false:否
* @param language 通讯录语言,取值。 zh_CN:中文(默认值)。 en_US:英文。
* @return List<Map<String,String>>
*/
public
List
<
Map
<
String
,
String
>>
getUserByDeptId
(
Long
deptId
,
Long
cursor
,
Long
size
,
String
orderField
,
String
containAccessLimit
,
String
language
)
{
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
List
<
Map
<
String
,
String
>>
maps
=
new
ArrayList
<>();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/user/listsimple"
);
OapiUserListsimpleRequest
req
=
new
OapiUserListsimpleRequest
();
req
.
setDeptId
(
deptId
);
req
.
setCursor
(
cursor
);
req
.
setSize
(
size
);
if
(
StringUtils
.
isNotEmpty
(
orderField
)){
req
.
setOrderField
(
orderField
);
}
if
(
StringUtils
.
isNotEmpty
(
containAccessLimit
)){
req
.
setContainAccessLimit
(
Boolean
.
valueOf
(
containAccessLimit
));
}
if
(
StringUtils
.
isNotEmpty
(
language
)){
req
.
setLanguage
(
language
);
}
OapiUserListsimpleResponse
rsp
=
client
.
execute
(
req
,
token
);
OapiUserListsimpleResponse
.
PageResult
result
=
rsp
.
getResult
();
List
<
OapiUserListsimpleResponse
.
ListUserSimpleResponse
>
list
=
result
.
getList
();
for
(
OapiUserListsimpleResponse
.
ListUserSimpleResponse
listUserSimpleResponse
:
list
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
String
name
=
listUserSimpleResponse
.
getName
();
String
userid
=
listUserSimpleResponse
.
getUserid
();
map
.
put
(
"name"
,
name
);
map
.
put
(
"userId"
,
userid
);
maps
.
add
(
map
);
}
return
maps
;
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
maps
;
}
/**
* 获取部门用户userId列表
*/
public
OapiUserListidResponse
.
ListUserByDeptResponse
getuserIdByDept
(
Long
deptId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/user/listid"
);
OapiUserListidRequest
req
=
new
OapiUserListidRequest
();
req
.
setDeptId
(
deptId
);
OapiUserListidResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiUserListidResponse
.
ListUserByDeptResponse
();
}
/**
* 查询部门用户详情
*/
public
List
<
OapiV2UserListResponse
.
ListUserResponse
>
getUserInfoByDeptId
(
Long
deptId
,
Long
cursor
,
Long
size
,
String
orderField
,
String
containAccessLimit
,
String
language
)
{
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/user/list"
);
OapiV2UserListRequest
req
=
new
OapiV2UserListRequest
();
req
.
setDeptId
(
deptId
);
req
.
setCursor
(
cursor
);
req
.
setSize
(
size
);
if
(
StringUtils
.
isNotEmpty
(
orderField
)){
req
.
setOrderField
(
orderField
);
}
if
(
StringUtils
.
isNotEmpty
(
containAccessLimit
)){
req
.
setContainAccessLimit
(
Boolean
.
valueOf
(
containAccessLimit
));
}
if
(
StringUtils
.
isNotEmpty
(
language
)){
req
.
setLanguage
(
language
);
}
OapiV2UserListResponse
rsp
=
client
.
execute
(
req
,
token
);
OapiV2UserListResponse
.
PageResult
result
=
rsp
.
getResult
();
return
result
.
getList
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
ArrayList
<>();
}
/**
* 获取员工人数
*/
public
Long
getUserCount
(
Boolean
onlyActive
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/user/count"
);
OapiUserCountRequest
req
=
new
OapiUserCountRequest
();
req
.
setOnlyActive
(
onlyActive
);
OapiUserCountResponse
rsp
=
client
.
execute
(
req
,
token
);
OapiUserCountResponse
.
CountUserResponse
result
=
rsp
.
getResult
();
return
result
.
getCount
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
0L
;
}
/**
* 根据手机号查询企业账号用户
*/
public
OapiV2UserGetbymobileResponse
.
UserGetByMobileResponse
getbymobile
(
String
mobile
,
Boolean
supportExclusiveAccountSearch
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/v2/user/getbymobile"
);
OapiV2UserGetbymobileRequest
req
=
new
OapiV2UserGetbymobileRequest
();
req
.
setMobile
(
mobile
);
req
.
setSupportExclusiveAccountSearch
(
supportExclusiveAccountSearch
);
OapiV2UserGetbymobileResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiV2UserGetbymobileResponse
.
UserGetByMobileResponse
();
}
/**
* 根据unionid查询用户
*/
public
OapiUserGetbyunionidResponse
.
UserGetByUnionIdResponse
getbyunionid
(
String
unionId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/user/getbyunionid"
);
OapiUserGetbyunionidRequest
req
=
new
OapiUserGetbyunionidRequest
();
req
.
setUnionid
(
unionId
);
OapiUserGetbyunionidResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
OapiUserGetbyunionidResponse
.
UserGetByUnionIdResponse
();
}
/**
* 获取管理员列表
*/
public
List
<
OapiUserListadminResponse
.
ListAdminResponse
>
getAdminList
(){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/user/listadmin"
);
OapiUserListadminRequest
req
=
new
OapiUserListadminRequest
();
OapiUserListadminResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getResult
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
ArrayList
<>();
}
/**
* 获取管理员通讯录权限范围
*/
public
List
<
Long
>
getAdminScope
(
String
userId
){
//获取access_token
String
token
=
accessTokenUtils
.
getToken
();
try
{
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/topapi/user/get_admin_scope"
);
OapiUserGetAdminScopeRequest
req
=
new
OapiUserGetAdminScopeRequest
();
req
.
setUserid
(
userId
);
OapiUserGetAdminScopeResponse
rsp
=
client
.
execute
(
req
,
token
);
return
rsp
.
getDeptIds
();
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
();
}
return
new
ArrayList
<>();
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingHandleVo.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
vo
;
import
com.aliyun.dingtalkworkflow_1_0.models.ExecuteProcessInstanceRequest
;
import
com.aliyun.tea.NameInMap
;
import
lombok.Data
;
/**
* 审批处理vo
*/
@Data
public
class
DingHandleVo
{
/** 审批实例ID */
@NameInMap
(
"processInstanceId"
)
public
String
processInstanceId
;
/** 审批意见 */
@NameInMap
(
"remark"
)
public
String
remark
;
/** 审批操作: 取值:agree 同意 refuse 拒绝 */
@NameInMap
(
"result"
)
public
String
result
;
/** 操作人的userId */
@NameInMap
(
"actionerUserId"
)
public
String
actionerUserId
;
/** 任务id */
@NameInMap
(
"taskId"
)
public
Long
taskId
;
/** 文件 */
@NameInMap
(
"file"
)
public
ExecuteProcessInstanceRequest
.
ExecuteProcessInstanceRequestFile
file
;
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingMessageVo.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
vo
;
import
com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request
;
import
com.taobao.api.internal.util.json.JSONWriter
;
import
lombok.Data
;
/**
* 消息通知
*/
@Data
public
class
DingMessageVo
{
/** 发送消息时使用的微应用的AgentID */
private
Long
agentId
;
/** 接收者的部门id列表,最大列表长度20 接收者是部门ID时,包括子部门下的所有用户 */
private
String
deptIdList
;
/** 消息内容,最长不超过2048个字节 支持以下工作通知类型(文本消息,图片消息,语音消息,文件消息,链接消息,OA消息,Markdown消息,卡片消息) */
private
String
msg
;
/** 是否发送给企业全部用户 */
private
Boolean
toAllUser
;
/** 接收者的userid列表,最大用户列表长度100 */
private
String
useridList
;
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
public
void
setMsg
(
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
msg
)
{
this
.
msg
=
(
new
JSONWriter
(
false
,
false
,
true
)).
write
(
msg
);
}
public
String
getMsg
()
{
return
this
.
msg
;
}
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingProcessInstanceVo.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
vo
;
import
com.aliyun.dingtalkworkflow_1_0.models.ProcessForecastRequest
;
import
com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceRequest
;
import
com.aliyun.tea.NameInMap
;
import
lombok.Data
;
import
java.util.List
;
/**
* 审批实例
*/
@Data
public
class
DingProcessInstanceVo
{
/** 不使用审批流模板时,直接指定的审批人列表,最大列表长度:20 */
@NameInMap
(
"approvers"
)
public
List
<
StartProcessInstanceRequest
.
StartProcessInstanceRequestApprovers
>
approvers
;
/** 抄送人 userId */
@NameInMap
(
"ccList"
)
public
List
<
String
>
ccList
;
/** 抄送时间点,取值 START:开始时抄送 FINISH:结束时抄送 START_FINISH:开始和结束时都抄送 */
@NameInMap
(
"ccPosition"
)
public
String
ccPosition
;
/** 审批发起人所在的部门ID */
@NameInMap
(
"deptId"
)
public
Long
deptId
;
/** 创建审批实例 : 表单数据内容,控件列表,最大列表长度:150 */
@NameInMap
(
"formComponentValues"
)
public
List
<
StartProcessInstanceRequest
.
StartProcessInstanceRequestFormComponentValues
>
formComponentValues
;
/** 获取审批单流程中的节点信息 : 表单数据内容,控件列表,最大列表长度:150 */
public
List
<
ProcessForecastRequest
.
ProcessForecastRequestFormComponentValues
>
formComponentValues1
;
/** 应用标识AgentId */
@NameInMap
(
"microappAgentId"
)
public
Long
microappAgentId
;
/** 审批发起人的userId */
@NameInMap
(
"originatorUserId"
)
public
String
originatorUserId
;
/** 即将发起审批单的员工userId值 */
public
String
userId
;
/** 审批流的唯一码 */
@NameInMap
(
"processCode"
)
public
String
processCode
;
/** 使用审批流模板时,流程预测结果中节点规则上必填的自选操作人列表,最大列表长度:20 */
@NameInMap
(
"targetSelectActioners"
)
public
List
<
StartProcessInstanceRequest
.
StartProcessInstanceRequestTargetSelectActioners
>
targetSelectActioners
;
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingSchoolDeptVo.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
vo
;
import
lombok.Data
;
/**
* 部门管理
*/
@Data
public
class
DingSchoolDeptVo
{
/** 部门id */
private
Long
deptId
;
/** 部门名称 长度限制为1~64个字符,不允许包含字符"-"","以及"," */
private
String
name
;
/** 父部门ID,根部门ID为1 */
private
Long
parentId
;
/** 是否隐藏部门 */
private
Boolean
hideDept
;
/** 指定可以查看本部门的其他部门列表,总数不能超过50 当hide_dept为true时,则此值生效 */
private
String
deptPermits
;
/** 指定可以查看本部门的人员userId列表,总数不能超过50 当hide_dept为true时,则此值生效 */
private
String
userPermits
;
/** 是否限制本部门成员查看通讯录 */
private
Boolean
outerDept
;
/** 本部门成员是否只能看到所在部门及下级部门通讯录 当outer_dept为true时,此参数生效 */
private
Boolean
outerDeptOnlySelf
;
/** 指定本部门成员可查看的通讯录用户userId列表,总数不能超过50 当outer_dept为true时,此参数生效 */
private
String
outerPermitUsers
;
/** 指定本部门成员可查看的通讯录部门ID列表,总数不能超过50 当outer_dept为true时,此参数生效 */
private
String
outerPermitDepts
;
/** 是否创建一个关联此部门的企业群,默认为false即不创建 */
private
Boolean
createDeptGroup
;
/** 是否默认同意加入该部门的申请 */
private
Boolean
autoApproveApply
;
/** 在父部门中的排序值,order值小的排序靠前 */
private
Long
order
;
/** 通讯录语言 zh_CN:中文 en_US:英文 */
private
String
language
;
/** 当部门群已经创建后,有新人加入部门时是否会自动加入该群 */
private
Boolean
autoAddUser
;
/** 部门的主管userId列表,多个userid之间使用英文逗号分隔 */
private
String
deptManagerUseridList
;
/** 部门群是否包含子部门 */
private
Boolean
groupContainSubDept
;
/** 部门群是否包含外包部门 */
private
Boolean
groupContainOuterDept
;
/** 部门群是否包含隐藏部门 */
private
Boolean
groupContainHiddenDept
;
/** 企业群群主的userId */
private
String
orgDeptOwner
;
/** 强制更新的字段,支持清空指定的字段,多个字段之间使用英文逗号分隔。目前支持字段: dept_manager_userid_list */
private
String
forceUpdateFields
;
/** 部门标识字段 */
private
String
sourceIdentifier
;
/** 部门简介 */
private
String
brief
;
/** 部门联系方式 */
private
String
telephone
;
/** 扩展字段,JSON格式 */
private
String
extension
;
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingSchoolRoleVo.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
vo
;
import
lombok.Data
;
/**
* 角色管理
*/
@Data
public
class
DingSchoolRoleVo
{
/** 角色组id */
private
Long
groupId
;
/** 角色名称 */
private
String
roleName
;
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingSchoolTaskVo.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
vo
;
import
com.aliyun.dingtalktodo_1_0.models.CreateTodoTaskRequest
;
import
com.aliyun.tea.NameInMap
;
import
lombok.Data
;
import
java.util.List
;
/**
* 任务管理
*/
@Data
public
class
DingSchoolTaskVo
{
/** 当前操作者用户的unionId */
@NameInMap
(
"operatorId"
)
public
String
operatorId
;
/** 业务系统侧的唯一标识ID,即业务ID */
@NameInMap
(
"sourceId"
)
public
String
sourceId
;
/** 待办标题,最大长度1024 */
@NameInMap
(
"subject"
)
public
String
subject
;
/** 创建者的unionId */
@NameInMap
(
"creatorId"
)
public
String
creatorId
;
/** 待办备注描述,最大长度4096 */
@NameInMap
(
"description"
)
public
String
description
;
/** 截止时间,Unix时间戳,单位毫秒 */
@NameInMap
(
"dueTime"
)
public
Long
dueTime
;
/** 执行者的unionId,最大数量1000 */
@NameInMap
(
"executorIds"
)
public
List
<
String
>
executorIds
;
/** 参与者的unionId,最大数量1000 */
@NameInMap
(
"participantIds"
)
public
List
<
String
>
participantIds
;
/** 详情页url跳转地址 */
@NameInMap
(
"detailUrl"
)
public
CreateTodoTaskRequest
.
CreateTodoTaskRequestDetailUrl
detailUrl
;
/** 生成的待办是否仅展示在执行者的待办列表中 */
@NameInMap
(
"isOnlyShowExecutor"
)
public
Boolean
isOnlyShowExecutor
;
/** 优先级,取值: 10:较低 20:普通 30:紧急 40:非常紧急 */
@NameInMap
(
"priority"
)
public
Integer
priority
;
/** 待办通知配置 */
@NameInMap
(
"notifyConfigs"
)
public
CreateTodoTaskRequest
.
CreateTodoTaskRequestNotifyConfigs
notifyConfigs
;
@NameInMap
(
"actionList"
)
public
List
<
CreateTodoTaskRequest
.
CreateTodoTaskRequestActionList
>
actionList
;
@NameInMap
(
"bizCategoryId"
)
public
String
bizCategoryId
;
@NameInMap
(
"contentFieldList"
)
public
List
<
CreateTodoTaskRequest
.
CreateTodoTaskRequestContentFieldList
>
contentFieldList
;
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingSchoolUserVo.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
vo
;
import
lombok.Data
;
/**
* 用户管理
*/
@Data
public
class
DingSchoolUserVo
{
/** 员工唯一标识ID(不可修改),企业内必须唯一 */
private
String
userid
;
/** 员工在当前开发者企业账号范围内的唯一标识 */
private
String
unionid
;
/** 头像 */
private
String
avatar
;
/** 员工名称,长度最大80个字符 */
private
String
name
;
/** 手机号码,企业内必须唯一,不可重复 */
private
String
mobile
;
/** 是否号码隐藏 */
private
Boolean
hideMobile
;
/** 分机号,长度最大50个字符 */
private
String
telephone
;
/** 员工工号,长度最大为50个字符 */
private
String
jobNumber
;
/** 职位,长度最大为200个字符 */
private
String
title
;
/** 员工个人邮箱,长度最大50个字符 */
private
String
email
;
/** 员工的企业邮箱,长度最大100个字符 */
private
String
orgEmail
;
/** 员工的企业邮箱类型 profession: 标准版 base:基础版 */
private
String
orgEmailType
;
/** 办公地点,长度最大100个字符 */
private
String
workPlace
;
/** 备注,长度最大2000个字符 */
private
String
remark
;
/** 所属部门id列表,每次调用最多传100个部门ID */
private
String
deptIdList
;
/** 员工在对应的部门中的排序 */
private
String
deptOrderList
;
/** 员工在对应的部门中的职位 */
private
String
deptTitleList
;
/** 扩展属性,可以设置多种属性,最大长度2000个字符 */
private
String
extension
;
/** 是否开启高管模式,默认值false */
private
Boolean
seniorMode
;
/** 入职时间,Unix时间戳,单位毫秒 */
private
Long
hiredDate
;
/** 直属主管的userId */
private
String
managerUserid
;
/** 登录邮箱 */
private
String
loginEmail
;
/** 是否为企业账号 */
private
Boolean
exclusiveAccount
;
/** 是否激活了钉钉 */
private
Boolean
active
;
/** 部门内任职 */
private
String
deptPositionList
;
/** 专属账号类型 sso:企业自建专属账号 dingtalk:钉钉自建专属账号 */
private
String
exclusiveAccountType
;
/** 专属账号手机号 */
private
String
exclusiveMobile
;
/** 手机号验证状态 */
private
String
exclusiveMobileVerifyStatus
;
/** 强制更新的字段,支持清空指定的字段,多个字段之间使用逗号分隔。目前支持字段: manager_userid */
private
String
forceUpdateFields
;
/** 重置专属账号密码 */
private
String
initPassword
;
/** 语言 */
private
String
language
;
/** 修改专属账号登录名 */
private
String
loginId
;
/** 需要添加的专属账号所属corpid */
private
String
outerExclusiveCorpid
;
/** 需要添加的专属账号所属userid */
private
String
outerExclusiveUserid
;
}
smart-campus/src/main/java/yangtz/cs/liu/dingding/vo/DingTransferVo.java
0 → 100644
View file @
9837e388
package
yangtz
.
cs
.
liu
.
dingding
.
vo
;
import
com.aliyun.dingtalkworkflow_1_0.models.RedirectWorkflowTaskRequest
;
import
com.aliyun.tea.NameInMap
;
import
lombok.Data
;
/**
* 转交审批任务
*/
@Data
public
class
DingTransferVo
{
/** 操作节点名 */
@NameInMap
(
"actionName"
)
public
String
actionName
;
/** 文件 */
@NameInMap
(
"file"
)
public
RedirectWorkflowTaskRequest
.
RedirectWorkflowTaskRequestFile
file
;
/** 操作人userId,需要跟任务的当前执行人保持一致,否则无法通过校验 */
@NameInMap
(
"operateUserId"
)
public
String
operateUserId
;
/** 转交备注信息 */
@NameInMap
(
"remark"
)
public
String
remark
;
/** OA审批任务ID */
@NameInMap
(
"taskId"
)
public
Long
taskId
;
/** OA审批任务被转交对象的用户userId */
@NameInMap
(
"toUserId"
)
public
String
toUserId
;
}
smart-campus/src/main/resources/mapper/auditorium/SchoolAuditoriumMapper.xml
View file @
9837e388
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
<resultMap
type=
"SchoolAuditoriumVo"
id=
"SchoolAuditoriumResult"
>
<resultMap
type=
"SchoolAuditoriumVo"
id=
"SchoolAuditoriumResult"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"id"
column=
"id"
/>
<result
property=
"instanceId"
column=
"instance_id"
/>
<result
property=
"instanceId"
column=
"instance_id"
/>
<result
property=
"ddInstanceId"
column=
"dd_instance_id"
/>
<result
property=
"activityName"
column=
"activity_name"
/>
<result
property=
"activityName"
column=
"activity_name"
/>
<result
property=
"activityArea"
column=
"activity_area"
/>
<result
property=
"activityArea"
column=
"activity_area"
/>
<result
property=
"activityTime"
column=
"activity_time"
/>
<result
property=
"activityTime"
column=
"activity_time"
/>
...
@@ -31,6 +32,7 @@
...
@@ -31,6 +32,7 @@
<result
property=
"applyDept"
column=
"apply_dept"
/>
<result
property=
"applyDept"
column=
"apply_dept"
/>
<result
property=
"fjlj"
column=
"fjlj"
/>
<result
property=
"fjlj"
column=
"fjlj"
/>
<result
property=
"fjmc"
column=
"fjmc"
/>
<result
property=
"fjmc"
column=
"fjmc"
/>
<result
property=
"ddTaskId"
column=
"dd_task_id"
/>
<result
property=
"createById"
column=
"create_by_id"
/>
<result
property=
"createById"
column=
"create_by_id"
/>
<result
property=
"createBy"
column=
"create_by"
/>
<result
property=
"createBy"
column=
"create_by"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"createTime"
column=
"create_time"
/>
...
@@ -40,7 +42,7 @@
...
@@ -40,7 +42,7 @@
</resultMap>
</resultMap>
<sql
id=
"selectSchoolAuditoriumVo"
>
<sql
id=
"selectSchoolAuditoriumVo"
>
select id, instance_id,
activity_name, activity_area, activity_time, ht_number, specific_user_id, specific_user_name, activity_number, duration, is_rehearsal, is_video, is_live, is_big_screen, other_requirements, leadership_id, leadership_name, state, opinion, apply_id, apply_name, apply_time, apply_dept, apply_dept_id, fjlj, fjmc
, create_by_id, create_by, create_time, update_by_id, update_by, update_time from school_auditorium
select id, instance_id,
dd_instance_id, activity_name, activity_area, activity_time, ht_number, specific_user_id, specific_user_name, activity_number, duration, is_rehearsal, is_video, is_live, is_big_screen, other_requirements, leadership_id, leadership_name, state, opinion, apply_id, apply_name, apply_time, apply_dept, apply_dept_id, fjlj, fjmc, dd_task_id
, create_by_id, create_by, create_time, update_by_id, update_by, update_time from school_auditorium
</sql>
</sql>
<select
id=
"selectSchoolAuditoriumList"
parameterType=
"SchoolAuditoriumVo"
resultMap=
"SchoolAuditoriumResult"
>
<select
id=
"selectSchoolAuditoriumList"
parameterType=
"SchoolAuditoriumVo"
resultMap=
"SchoolAuditoriumResult"
>
...
@@ -125,6 +127,7 @@
...
@@ -125,6 +127,7 @@
insert into school_auditorium
insert into school_auditorium
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"instanceId != null and instanceId != ''"
>
instance_id,
</if>
<if
test=
"instanceId != null and instanceId != ''"
>
instance_id,
</if>
<if
test=
"ddInstanceId != null and ddInstanceId != ''"
>
dd_instance_id,
</if>
<if
test=
"activityName != null and activityName != ''"
>
activity_name,
</if>
<if
test=
"activityName != null and activityName != ''"
>
activity_name,
</if>
<if
test=
"activityArea != null and activityArea != ''"
>
activity_area,
</if>
<if
test=
"activityArea != null and activityArea != ''"
>
activity_area,
</if>
<if
test=
"activityTime != null"
>
activity_time,
</if>
<if
test=
"activityTime != null"
>
activity_time,
</if>
...
@@ -146,6 +149,7 @@
...
@@ -146,6 +149,7 @@
<if
test=
"applyDeptId != null"
>
apply_dept_id,apply_dept,
</if>
<if
test=
"applyDeptId != null"
>
apply_dept_id,apply_dept,
</if>
<if
test=
"fjlj != null"
>
fjlj,
</if>
<if
test=
"fjlj != null"
>
fjlj,
</if>
<if
test=
"fjmc != null"
>
fjmc,
</if>
<if
test=
"fjmc != null"
>
fjmc,
</if>
<if
test=
"ddTaskId != null"
>
dd_task_id,
</if>
<if
test=
"createById != null"
>
create_by_id,create_by,
</if>
<if
test=
"createById != null"
>
create_by_id,create_by,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateById != null"
>
update_by_id,update_by,
</if>
<if
test=
"updateById != null"
>
update_by_id,update_by,
</if>
...
@@ -153,6 +157,7 @@
...
@@ -153,6 +157,7 @@
</trim>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"instanceId != null and instanceId != ''"
>
#{instanceId},
</if>
<if
test=
"instanceId != null and instanceId != ''"
>
#{instanceId},
</if>
<if
test=
"ddInstanceId != null and ddInstanceId != ''"
>
#{ddInstanceId},
</if>
<if
test=
"activityName != null and activityName != ''"
>
#{activityName},
</if>
<if
test=
"activityName != null and activityName != ''"
>
#{activityName},
</if>
<if
test=
"activityArea != null and activityArea != ''"
>
#{activityArea},
</if>
<if
test=
"activityArea != null and activityArea != ''"
>
#{activityArea},
</if>
<if
test=
"activityTime != null"
>
#{activityTime},
</if>
<if
test=
"activityTime != null"
>
#{activityTime},
</if>
...
@@ -174,6 +179,7 @@
...
@@ -174,6 +179,7 @@
<if
test=
"applyDeptId != null"
>
#{applyDeptId},(select dept_name from sys_dept where dept_id = #{applyDeptId}),
</if>
<if
test=
"applyDeptId != null"
>
#{applyDeptId},(select dept_name from sys_dept where dept_id = #{applyDeptId}),
</if>
<if
test=
"fjlj != null"
>
#{fjlj},
</if>
<if
test=
"fjlj != null"
>
#{fjlj},
</if>
<if
test=
"fjmc != null"
>
#{fjmc},
</if>
<if
test=
"fjmc != null"
>
#{fjmc},
</if>
<if
test=
"ddTaskId != null"
>
#{ddTaskId},
</if>
<if
test=
"createById != null"
>
#{createById},(select user_name from sys_user where user_id = #{createById}),
</if>
<if
test=
"createById != null"
>
#{createById},(select user_name from sys_user where user_id = #{createById}),
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
<if
test=
"updateById != null"
>
#{updateById},(select user_name from sys_user where user_id = #{updateById}),
</if>
<if
test=
"updateById != null"
>
#{updateById},(select user_name from sys_user where user_id = #{updateById}),
</if>
...
@@ -185,6 +191,7 @@
...
@@ -185,6 +191,7 @@
update school_auditorium
update school_auditorium
<trim
prefix=
"SET"
suffixOverrides=
","
>
<trim
prefix=
"SET"
suffixOverrides=
","
>
<if
test=
"instanceId != null and instanceId != ''"
>
instance_id = #{instanceId},
</if>
<if
test=
"instanceId != null and instanceId != ''"
>
instance_id = #{instanceId},
</if>
<if
test=
"ddInstanceId != null and ddInstanceId != ''"
>
dd_instance_id = #{ddInstanceId},
</if>
<if
test=
"activityName != null and activityName != ''"
>
activity_name = #{activityName},
</if>
<if
test=
"activityName != null and activityName != ''"
>
activity_name = #{activityName},
</if>
<if
test=
"activityArea != null and activityArea != ''"
>
activity_area = #{activityArea},
</if>
<if
test=
"activityArea != null and activityArea != ''"
>
activity_area = #{activityArea},
</if>
<if
test=
"activityTime != null"
>
activity_time = #{activityTime},
</if>
<if
test=
"activityTime != null"
>
activity_time = #{activityTime},
</if>
...
@@ -206,6 +213,7 @@
...
@@ -206,6 +213,7 @@
<if
test=
"applyDeptId != null"
>
apply_dept_id = #{applyDeptId},apply_dept = (select dept_name from sys_dept where dept_id = #{applyDeptId}),
</if>
<if
test=
"applyDeptId != null"
>
apply_dept_id = #{applyDeptId},apply_dept = (select dept_name from sys_dept where dept_id = #{applyDeptId}),
</if>
<if
test=
"fjlj != null"
>
fjlj = #{fjlj},
</if>
<if
test=
"fjlj != null"
>
fjlj = #{fjlj},
</if>
<if
test=
"fjmc != null"
>
fjmc = #{fjmc},
</if>
<if
test=
"fjmc != null"
>
fjmc = #{fjmc},
</if>
<if
test=
"ddTaskId != null"
>
dd_task_id = #{ddTaskId},
</if>
<if
test=
"createById != null"
>
create_by_id = #{createById},create_by = (select user_name from sys_user where user_id = #{createById}),
</if>
<if
test=
"createById != null"
>
create_by_id = #{createById},create_by = (select user_name from sys_user where user_id = #{createById}),
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
<if
test=
"updateById != null"
>
update_by_id = #{updateById},update_by = (select user_name from sys_user where user_id = #{updateById}),
</if>
<if
test=
"updateById != null"
>
update_by_id = #{updateById},update_by = (select user_name from sys_user where user_id = #{updateById}),
</if>
...
@@ -224,4 +232,4 @@
...
@@ -224,4 +232,4 @@
#{id}
#{id}
</foreach>
</foreach>
</delete>
</delete>
</mapper>
</mapper>
\ No newline at end of file
smart-campus/src/main/resources/mapper/teacher/SchoolTeacherMapper.xml
View file @
9837e388
...
@@ -19,6 +19,8 @@
...
@@ -19,6 +19,8 @@
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"openId"
column=
"open_id"
/>
<result
property=
"openId"
column=
"open_id"
/>
<result
property=
"ddUserId"
column=
"dd_user_id"
/>
<result
property=
"unionId"
column=
"union_id"
/>
<result
property=
"delFlag"
column=
"del_flag"
/>
<result
property=
"delFlag"
column=
"del_flag"
/>
</resultMap>
</resultMap>
...
@@ -39,7 +41,9 @@
...
@@ -39,7 +41,9 @@
create_time,
create_time,
update_by,
update_by,
update_time,
update_time,
open_id
open_id,
dd_user_id,
union_id
from school_teacher
from school_teacher
</sql>
</sql>
...
@@ -99,6 +103,8 @@
...
@@ -99,6 +103,8 @@
<if
test=
"updateBy != null"
>
update_by,
</if>
<if
test=
"updateBy != null"
>
update_by,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"openId != null"
>
open_id,
</if>
<if
test=
"openId != null"
>
open_id,
</if>
<if
test=
"ddUserId != null"
>
dd_user_id,
</if>
<if
test=
"unionId != null"
>
union_id,
</if>
<if
test=
"delFlag != null and delFlag != ''"
>
del_flag,
</if>
<if
test=
"delFlag != null and delFlag != ''"
>
del_flag,
</if>
<if
test=
"deviceNum != null"
>
device_num,
</if>
<if
test=
"deviceNum != null"
>
device_num,
</if>
</trim>
</trim>
...
@@ -118,6 +124,8 @@
...
@@ -118,6 +124,8 @@
<if
test=
"updateBy != null"
>
#{updateBy},
</if>
<if
test=
"updateBy != null"
>
#{updateBy},
</if>
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
<if
test=
"openId != null"
>
#{openId},
</if>
<if
test=
"openId != null"
>
#{openId},
</if>
<if
test=
"ddUserId != null"
>
#{ddUserId},
</if>
<if
test=
"unionId != null"
>
#{unionId},
</if>
<if
test=
"delFlag != null and delFlag != ''"
>
#{delFlag},
</if>
<if
test=
"delFlag != null and delFlag != ''"
>
#{delFlag},
</if>
<if
test=
"deviceNum != null"
>
#{deviceNum},
</if>
<if
test=
"deviceNum != null"
>
#{deviceNum},
</if>
</trim>
</trim>
...
@@ -139,6 +147,8 @@
...
@@ -139,6 +147,8 @@
<if
test=
"education != null"
>
education,
</if>
<if
test=
"education != null"
>
education,
</if>
<if
test=
"sex != null and sex != ''"
>
sex,
</if>
<if
test=
"sex != null and sex != ''"
>
sex,
</if>
<if
test=
"openId != null"
>
open_id,
</if>
<if
test=
"openId != null"
>
open_id,
</if>
<if
test=
"ddUserId != null"
>
dd_user_id,
</if>
<if
test=
"unionId != null"
>
union_id,
</if>
<if
test=
"createBy != null"
>
create_by,
</if>
<if
test=
"createBy != null"
>
create_by,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateBy != null"
>
update_by,
</if>
<if
test=
"updateBy != null"
>
update_by,
</if>
...
@@ -159,6 +169,8 @@
...
@@ -159,6 +169,8 @@
<if
test=
"education != null"
>
#{education},
</if>
<if
test=
"education != null"
>
#{education},
</if>
<if
test=
"sex != null and sex != ''"
>
#{sex},
</if>
<if
test=
"sex != null and sex != ''"
>
#{sex},
</if>
<if
test=
"openId != null"
>
#{openId},
</if>
<if
test=
"openId != null"
>
#{openId},
</if>
<if
test=
"ddUserId != null"
>
#{ddUserId},
</if>
<if
test=
"unionId != null"
>
#{unionId},
</if>
<if
test=
"createBy != null"
>
#{createBy},
</if>
<if
test=
"createBy != null"
>
#{createBy},
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
<if
test=
"updateBy != null"
>
#{updateBy},
</if>
<if
test=
"updateBy != null"
>
#{updateBy},
</if>
...
@@ -202,6 +214,8 @@
...
@@ -202,6 +214,8 @@
<if
test=
"updateBy != null"
>
update_by = #{updateBy},
</if>
<if
test=
"updateBy != null"
>
update_by = #{updateBy},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"openId != null"
>
open_id = #{openId}
</if>
<if
test=
"openId != null"
>
open_id = #{openId}
</if>
<if
test=
"ddUserId != null"
>
dd_user_id = #{ddUserId}
</if>
<if
test=
"unionId != null"
>
union_id = #{unionId}
</if>
</trim>
</trim>
where id = #{id}
where id = #{id}
</update>
</update>
...
@@ -221,6 +235,8 @@
...
@@ -221,6 +235,8 @@
<if
test=
"education != null"
>
education = #{education},
</if>
<if
test=
"education != null"
>
education = #{education},
</if>
<if
test=
"sex != null and sex != ''"
>
sex = #{sex},
</if>
<if
test=
"sex != null and sex != ''"
>
sex = #{sex},
</if>
<if
test=
"openId != null"
>
open_id = #{openId},
</if>
<if
test=
"openId != null"
>
open_id = #{openId},
</if>
<if
test=
"ddUserId != null"
>
dd_user_id = #{ddUserId},
</if>
<if
test=
"unionId != null"
>
union_id = #{unionId},
</if>
<if
test=
"createBy != null"
>
create_by = #{createBy},
</if>
<if
test=
"createBy != null"
>
create_by = #{createBy},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
<if
test=
"updateBy != null"
>
update_by = #{updateBy},
</if>
<if
test=
"updateBy != null"
>
update_by = #{updateBy},
</if>
...
@@ -414,5 +430,13 @@
...
@@ -414,5 +430,13 @@
select open_id from school_teacher where id = #{userId} and del_flag = '0'
select open_id from school_teacher where id = #{userId} and del_flag = '0'
</select>
</select>
<select
id=
"getDdUserIdByUserId"
resultType=
"java.lang.String"
>
select dd_user_id from school_teacher where id = #{userId} and del_flag = '0'
</select>
<select
id=
"getUnionIdByUserId"
resultType=
"java.lang.String"
>
select union_id from school_teacher where id = #{userId} and del_flag = '0'
</select>
</mapper>
</mapper>
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