Commit 819d199c by xuwenhao

拉取钉钉用户、部门、级部成员信息

parent a9f5d1ff
......@@ -12,7 +12,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
/**
* 部门表 sys_dept
*
*
* @author ruoyi
*/
public class SysDept extends BaseEntity
......@@ -32,7 +32,7 @@ public class SysDept extends BaseEntity
private String deptName;
/** 显示顺序 */
private Integer orderNum;
private Long orderNum;
/** 负责人 */
private String leader;
......@@ -51,7 +51,7 @@ public class SysDept extends BaseEntity
/** 父部门名称 */
private String parentName;
/** 子部门 */
private List<SysDept> children = new ArrayList<SysDept>();
......@@ -98,12 +98,12 @@ public class SysDept extends BaseEntity
}
@NotNull(message = "显示顺序不能为空")
public Integer getOrderNum()
public Long getOrderNum()
{
return orderNum;
}
public void setOrderNum(Integer orderNum)
public void setOrderNum(Long orderNum)
{
this.orderNum = orderNum;
}
......
......@@ -116,6 +116,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/dd/user/login").permitAll()
.antMatchers( "/common/**").permitAll()
.antMatchers( "/dd/school/**").permitAll()
//打印下载接口放行
.antMatchers("/school/student/queryOne/**","/school/studentStatus/proofStatus/**").permitAll()
//网页注册登录接口放行
.antMatchers( "/web/artStudent/register","/web/artStudent/login").permitAll()
// 静态资源,可匿名访问
......
......@@ -6,8 +6,10 @@ 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.request.OapiV2UserGetuserinfoRequest;
import com.dingtalk.api.response.OapiUserGetuserinfoResponse;
import com.dingtalk.api.response.OapiV2UserGetResponse;
import com.dingtalk.api.response.OapiV2UserGetuserinfoResponse;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SchoolTeacher;
......@@ -55,40 +57,40 @@ public class DdLoginController {
@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");
SchoolTeacher schoolTeacher = schoolTeacherService.selectTeacherByPhone("15888888888");
// 获取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");
SchoolTeacher schoolTeacher = schoolTeacherService.selectTeacherByPhone(phone);
if (StringUtils.isNull(schoolTeacher)){
throw new ServiceException("未查询到该用户信息");
}
Long userId = schoolTeacher.getId();
SysUser sysUser = sysUserService.selectUserById(userId);
Long userId1 = schoolTeacher.getId();
SysUser sysUser = sysUserService.selectUserById(userId1);
//更新钉钉用户iid和unionId
// sysUser.setUnionId(unionId);
// schoolTeacherService.updateDdUserId(sysUser, userId);
sysUser.setUnionId(unionId);
schoolTeacherService.updateDdUserId(sysUser, userId);
String token = loginService.loginNew(sysUser);
ajaxResult.put(Constants.TOKEN, token);
return ajaxResult;
......
package yangtz.cs.liu.dingding.controller.dingDept;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import yangtz.cs.liu.dingding.service.impl.dingDept.DdDeptServcieImpl;
@RestController
@RequestMapping("/dd/school/dept")
public class DdDeptController extends BaseController {
@Autowired
private DdDeptServcieImpl ddDeptServcie;
/**
* 获取钉钉全部部门列表
*/
@GetMapping("/getDeptList")
public TableDataInfo getDeptList(){
return getDataTable(ddDeptServcie.getDeptList());
}
/**
* 下拉钉钉部门列表到系统
*/
@PostMapping("/addDdDept")
public AjaxResult addDdDept(){
return toAjax(ddDeptServcie.addDdDept());
}
/**
* 同步钉钉部门列表
*/
@GetMapping("/syncDdDept")
public AjaxResult syncDdDept(){
return AjaxResult.success(ddDeptServcie.syncDdDept());
}
}
......@@ -4,9 +4,11 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.service.impl.dingDept.DdDeptServcieImpl;
import yangtz.cs.liu.dingding.service.impl.dingUser.DdUserServiceImpl;
import yangtz.cs.liu.dingding.utils.DingCallbackCrypto;
import java.util.Map;
......@@ -20,6 +22,11 @@ public class DingEventController {
private static Logger log = LoggerFactory.getLogger(DingEventController.class);
@Autowired
private DdDeptServcieImpl ddDeptServcie;
@Autowired
private DdUserServiceImpl ddUserService;
@PostMapping("/callBack")
public Map<String, String> callBack(
@RequestParam(value = "msg_signature", required = false) String msg_signature,
......@@ -47,12 +54,26 @@ public class DingEventController {
// 测试回调url的正确性
log.info("测试回调url的正确性");
} else if ("user_add_org".equals(eventType)) {
// 处理通讯录用户增加事件
log.info("发生了:" + eventType + "事件");
// 处理通讯录用户增加
ddUserService.addUser(eventJson);
} else if ("user_modify_org".equals(eventType)) {
// 处理通讯录用户修改
ddUserService.updateUser(eventJson);
} else if ("user_leave_org".equals(eventType)) {
// 处理通讯录用户离职
ddUserService.leaveUser(eventJson);
} else if ("org_dept_create".equals(eventType)){
// 处理通讯录企业部门创建
ddDeptServcie.ddDeptCreate(eventJson);
} else if ("org_dept_modify".equals(eventType)){
// 处理通讯录企业部门修改
ddDeptServcie.ddDeptUpdate(eventJson);
} else if ("org_dept_remove".equals(eventType)){
// 处理通讯录企业部门删除
ddDeptServcie.ddDeptDelete(eventJson);
} else if ("bpms_instance_change".equals(eventType)){
// 处理审批实例事件
processInstance(eventJson);
log.info("发生了:" + eventType + "事件");
} else if ("bpms_task_change".equals(eventType)){
// 处理审批任务事件
eventJson.get("");
......@@ -70,16 +91,4 @@ public class DingEventController {
}
return null;
}
/**
* 处理审批实例事件
*/
public void processInstance(JSONObject eventJson){
//获取审批类型
String type = eventJson.getString("type");
//判断审批实例是否正常结束
if ("finish".equals(type)){
}
}
}
......@@ -4,10 +4,8 @@ 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 org.springframework.web.bind.annotation.*;
import yangtz.cs.liu.dingding.service.impl.dingUser.DdUserServiceImpl;
import yangtz.cs.liu.dingding.utils.DingUserUtils;
/**
......@@ -18,42 +16,38 @@ import yangtz.cs.liu.dingding.utils.DingUserUtils;
public class DingUserController extends BaseController {
@Autowired
private DingUserUtils dingUserUtils;
private DdUserServiceImpl ddUserService;
/**
* 获取部门用户基础信息
* 获取钉钉所有用户id
*/
@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("/getDdUserListAll")
public TableDataInfo getDdUserListAll(){
return getDataTable(ddUserService.getDdUserListAll());
}
/**
* 获取部门用户完整信息
* 下拉钉钉用户到系统
*/
@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));
@PostMapping("/addDdUser")
public AjaxResult addDdUser(){
return toAjax(ddUserService.addDdUser());
}
/**
* 获取用户详情
* 用户表数据同步到教师表
* @return
*/
@GetMapping("/getUser")
public AjaxResult getUser(@RequestParam("userId") String userId){
return AjaxResult.success(dingUserUtils.getUser(userId));
@PostMapping("/addDdTeacher")
public AjaxResult addDdTeacher(){
return toAjax(ddUserService.addDdTeacher());
}
/**
* 同步钉钉用户列表
*/
@GetMapping("/syncDdUser")
public AjaxResult syncDdUser(){
return AjaxResult.success(ddUserService.syncDdUser());
}
}
package yangtz.cs.liu.dingding.domain.dingDept;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;
public class SysDdDept extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 部门ID */
private Long deptId;
/** 父部门ID */
private Long parentId;
/** 祖级列表 */
private String ancestors;
/** 部门名称 */
private String deptName;
/** 显示顺序 */
private Long orderNum;
/** 负责人 */
private String leader;
/** 联系电话 */
private String phone;
/** 邮箱 */
private String email;
/** 部门状态:0正常,1停用 */
private String status;
/** 钉钉部门id */
private Long ddDeptId;
/** 钉钉父部门id */
private Long ddParentId;
/** 删除标志(0代表存在 2代表删除) */
private String delFlag;
/** 父部门名称 */
private String parentName;
/** 子部门 */
private List<SysDdDept> children = new ArrayList<SysDdDept>();
public Long getDdDeptId() {
return ddDeptId;
}
public void setDdDeptId(Long ddDeptId) {
this.ddDeptId = ddDeptId;
}
public Long getDdParentId() {
return ddParentId;
}
public void setDdParentId(Long ddParentId) {
this.ddParentId = ddParentId;
}
public Long getDeptId()
{
return deptId;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public Long getParentId()
{
return parentId;
}
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
public String getAncestors()
{
return ancestors;
}
public void setAncestors(String ancestors)
{
this.ancestors = ancestors;
}
@NotBlank(message = "部门名称不能为空")
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
public String getDeptName()
{
return deptName;
}
public void setDeptName(String deptName)
{
this.deptName = deptName;
}
@NotNull(message = "显示顺序不能为空")
public Long getOrderNum() {
return orderNum;
}
public void setOrderNum(Long orderNum) {
this.orderNum = orderNum;
}
public String getLeader()
{
return leader;
}
public void setLeader(String leader)
{
this.leader = leader;
}
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
public String getPhone()
{
return phone;
}
public void setPhone(String phone)
{
this.phone = phone;
}
@Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
public String getEmail()
{
return email;
}
public void setEmail(String email)
{
this.email = email;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
public String getDelFlag()
{
return delFlag;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getParentName()
{
return parentName;
}
public void setParentName(String parentName)
{
this.parentName = parentName;
}
public List<SysDdDept> getChildren() {
return children;
}
public void setChildren(List<SysDdDept> children) {
this.children = children;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("deptId", getDeptId())
.append("parentId", getParentId())
.append("ancestors", getAncestors())
.append("deptName", getDeptName())
.append("orderNum", getOrderNum())
.append("leader", getLeader())
.append("phone", getPhone())
.append("email", getEmail())
.append("status", getStatus())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}
package yangtz.cs.liu.dingding.domain.dingGrade;
import com.core.domain.OurBaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
@Data
public class SchoolGradeMentorCopy extends OurBaseEntity {
/** 老师主键 */
@NotNull(message = "级部教师不能为空")
private Long teacherId;
/** 年级级部主键 */
private Long gradeId;
/** 教师任职开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date startTime;
/** 教师任职结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date endTime;
/** 类型(1年级部,2学科组长) */
private String type;
/** 职务 */
private String teacherPost;
/** 学科组(1物理学科组,2化学学科组,3生物学科组) */
private String subGroup;
}
package yangtz.cs.liu.dingding.domain.dingUser;
import lombok.Data;
@Data
public class SysDdUserDept {
private Long userId;
private Long deptId;
}
package yangtz.cs.liu.dingding.domain.schoolTeacher;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.Date;
@Data
public class SysDdTeacher extends BaseEntity
{
private static final long serialVersionUID = 1L;
private Long id;
/**
* 照片路径
*/
@Excel(name = "照片", cellType = Excel.ColumnType.IMAGE, height = 55, type = Excel.Type.EXPORT)
private String picUrl;
/**
* 老师名称
*/
@Excel(name = "老师名称")
@NotBlank(message = "老师名字不能为空")
private String teacherName;
/**
* 性别
*/
@Excel(name = "性别", readConverterExp = "0=男,1=女")
@NotBlank(message = "性别不能为空")
private String sex;
/**
* 民族
*/
@Excel(name = "民族")
private String nation;
/**
* 工作编号
*/
@Excel(name = "工作编号")
private String teacherCode;
/*
* 系统表 用户id
* */
@TableField(exist = false)
private Long userId;
/**
* 生日
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "生日", width = 25, dateFormat = "yyyy-MM-dd")
private Date birthday;
/**
* 学历
*/
@Excel(name = "学历", readConverterExp = "0=高中,1=专科,2=本科,3=研究生,4=硕士,5=博士",combo = {"高中","专科","本科","研究生","硕士","博士"})
private String education;
/**
* 老师电话
*/
@Excel(name = "老师电话")
@NotBlank(message = "老师电话不能为空")
private String teacherTel;
/**
* 身份证号
*/
@Excel(name = "身份证号", width = 30)
@NotBlank(message = "身份证号不能为空")
private String idCard;
/**
* 家庭住址
*/
@Excel(name = "家庭住址", width = 35)
private String homeAddress;
/*
* 微信openid
* */
private String openId;
/*
* 钉钉用户unionId
* */
private String unionId;
/*
* 钉钉用户id
* */
private String ddUserId;
//设备工号
private String deviceNum;
/**部门id**/
@TableField(exist = false)
private Long deptId;
/**部门名称**/
@TableField(exist = false)
private String deptName;
/** 密码 */
@TableField(exist = false)
private String password;
/** 帐号状态(0正常 1停用) */
//@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
@TableField(exist = false)
private String status;
/**签名路径*/
@TableField(exist = false)
private String sign;
/**头像**/
@TableField(exist = false)
private String avatar;
/*职工类型**/
@TableField(exist = false)
private String employeeType;
@TableField(exist = false)
private String email;
/** 父部门ID */
@TableField(exist = false)
private Long parentId;
/** 父部门名称 */
@TableField(exist = false)
private String parentName;
}
package yangtz.cs.liu.dingding.mapper.dingDept;
import yangtz.cs.liu.dingding.domain.dingDept.SysDdDept;
import java.util.List;
import java.util.Map;
public interface DdDeptMapper {
/**
* 查询系统部门列表
* @param sysDdDept
* @return
*/
List<SysDdDept> selectDdDeptList(SysDdDept sysDdDept);
/**
* 根据钉钉部门id查询系统部门信息
*/
SysDdDept selectDeptByDdDeptId(Long ddDeptId);
/**
* 根据部门id查询系统部门信息
*/
SysDdDept selectDeptByDeptId(Long deptId);
/**
* 查询级部信息
*/
List<Map<String,Object>> selectGradeList();
/**
* 新增钉钉部门
* @return
*/
int insertDdDept(SysDdDept sysDdDept);
/**
* 更新钉钉部门
* @param sysDdDept
* @return
*/
int updateDdDeptByDdDeptId(SysDdDept sysDdDept);
/**
* 删除部门
* @param deptId
* @return
*/
int deleteDdDeptById(Long deptId);
/**
* 根据钉钉部门id删除部门
* @param ddDeptId
* @return
*/
int deleteDdDeptByDdDeptId(Long ddDeptId);
}
package yangtz.cs.liu.dingding.mapper.dingUser;
import org.apache.ibatis.annotations.Param;
import yangtz.cs.liu.dingding.domain.dingGrade.SchoolGradeMentorCopy;
import yangtz.cs.liu.dingding.domain.dingUser.SysDdUser;
import yangtz.cs.liu.dingding.domain.dingUser.SysDdUserDept;
import java.util.List;
public interface DdUserMapper {
/**
* 批量新增钉钉用户
*/
int batchInsertDdUser(@Param("list") List<SysDdUser> list);
/**
* 新增用户
*/
int insertDdUser(SysDdUser sysDdUser);
/**
* 更新用户
*/
int updateDdUser(SysDdUser sysDdUser);
/**
* 查询全部用户
*/
List<SysDdUser> selectDdUserList(SysDdUser sysDdUser);
/**
* 新增用户部门关系
*/
int insertDdUserDept(SysDdUserDept sysDdUserDept);
/**
* 删除用户
*/
int deleteDdUser(Long userId);
/**
* 删除用户和部门关系
*/
int deleteDdUserDept(Long userId);
/**
* 删除教师
*/
int deleteDdTeacher(Long userId);
/**
* 根据用户id查询用户部门id列表
*/
List<Long> selectDeptIdByUserId(Long userId);
/**
* 根据钉钉用户id查询用户信息
* @param ddUserId
* @return
*/
SysDdUser selectDdUserByDdUserId(String ddUserId);
/**
* 新增级部成员
* @param schoolGradeMentorCopy
* @return
*/
int insertGradeMentor(SchoolGradeMentorCopy schoolGradeMentorCopy);
/**
* 删除级部成员
* @param userId
* @return
*/
int deleteGradeMentor(Long userId);
}
package yangtz.cs.liu.dingding.mapper.schoolTeacher;
import org.apache.ibatis.annotations.Param;
import yangtz.cs.liu.dingding.domain.schoolTeacher.SysDdTeacher;
import java.util.List;
public interface DdTeacherMapper {
/**
* 批量新增教师
*/
int batchInsertTeacher(@Param("list") List<SysDdTeacher> list);
/**
* 新增教师
*/
int addTeacherList(SysDdTeacher sysDdTeacher);
/**
* 更新教师信息
*/
int updateDdTeacher(SysDdTeacher sysDdTeacher);
}
package yangtz.cs.liu.dingding.service.dingDept;
import com.alibaba.fastjson.JSONObject;
import com.dingtalk.api.response.OapiV2DepartmentListsubResponse;
import java.util.List;
public interface IDdDeptService {
/**
* 获取钉钉全部部门列表
* @return
*/
List<OapiV2DepartmentListsubResponse.DeptBaseResponse> getDeptList();
/**
* 下拉钉钉部门列表到系统
* @return
*/
int addDdDept();
/**
* 同步钉钉部门列表
* @return
*/
String syncDdDept();
/**
* 钉钉部门创建
*/
int ddDeptCreate(JSONObject eventJson);
/**
* 钉钉部门修改
*/
int ddDeptUpdate(JSONObject eventJson);
/**
* 钉钉部门删除
*/
int ddDeptDelete(JSONObject eventJson);
}
package yangtz.cs.liu.dingding.service.dingUser;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
public interface IDdUserService {
/**
* 获取钉钉全部用户id
*/
List<String> getDdUserListAll();
/**
* 下拉钉钉用户到系统
*/
int addDdUser();
/**
* 用户表数据同步到教师表
* @return
*/
int addDdTeacher();
/**
* 同步钉钉用户
*/
String syncDdUser();
/**
* 处理通讯录用户增加
*/
int addUser(JSONObject eventJson);
/**
* 处理通讯录用户修改
*/
int updateUser(JSONObject eventJson);
/**
* 处理通讯录用户离职
*/
int leaveUser(JSONObject eventJson);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="yangtz.cs.liu.dingding.mapper.dingDept.DdDeptMapper">
<resultMap type="SysDdDept" id="SysDdDeptResult">
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="deptName" column="dept_name" />
<result property="orderNum" column="order_num" />
<result property="leader" column="leader" />
<result property="phone" column="phone" />
<result property="email" column="email" />
<result property="status" column="status" />
<result property="ddDeptId" column="dd_dept_id" />
<result property="ddParentId" column="dd_parent_id" />
<result property="delFlag" column="del_flag" />
<result property="parentName" column="parent_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDdDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.dd_dept_id, d.dd_parent_id, d.del_flag, d.create_by, d.create_time
from sys_dd_dept d
</sql>
<select id="selectDdDeptList" parameterType="SysDdDept" resultMap="SysDdDeptResult">
<include refid="selectDdDeptVo"/>
where d.del_flag = '0'
<if test="deptId != null and deptId != 0">
AND dept_id = #{deptId}
</if>
<if test="parentId != null and parentId != 0">
AND parent_id = #{parentId}
</if>
<if test="deptName != null and deptName != ''">
AND dept_name like concat('%', #{deptName}, '%')
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
order by d.parent_id, d.order_num
</select>
<select id="selectDeptByDdDeptId" parameterType="Long" resultMap="SysDdDeptResult">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.dd_dept_id, d.dd_parent_id, d.del_flag, d.create_by, d.create_time
from sys_dd_dept d
where d.dd_dept_id = #{ddDeptId}
</select>
<select id="selectDeptByDeptId" parameterType="Long" resultMap="SysDdDeptResult">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.dd_dept_id, d.dd_parent_id, d.del_flag, d.create_by, d.create_time
from sys_dd_dept d
where d.dept_id = #{deptId}
</select>
<select id="selectGradeList" resultType="Map">
select id as gradeId, grade_year as gradeYear from school_grade_copy where del_flag = "0" order by grade_value ASC
</select>
<insert id="insertDdDept" parameterType="SysDdDept" useGeneratedKeys="true" keyProperty="deptId">
insert into sys_dd_dept(
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null ">parent_id,</if>
<if test="deptName != null and deptName != ''">dept_name,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="orderNum != null">order_num,</if>
<if test="leader != null and leader != ''">leader,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if>
<if test="ddDeptId != null">dd_dept_id,</if>
<if test="ddParentId != null">dd_parent_id,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="deptId != null and deptId != 0">#{deptId},</if>
<if test="parentId != null">#{parentId},</if>
<if test="deptName != null and deptName != ''">#{deptName},</if>
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="leader != null and leader != ''">#{leader},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if>
<if test="ddDeptId != null">#{ddDeptId},</if>
<if test="ddParentId != null">#{ddParentId},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateDdDept" parameterType="SysDdDept">
update sys_dd_dept
<set>
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="leader != null">leader = #{leader},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="email != null">email = #{email},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="ddDeptId != null ">dd_dept_id = #{ddDeptId},</if>
<if test="ddParentId != null">dd_parent_id = #{ddParentId},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where dept_id = #{deptId}
</update>
<update id="updateDdDeptByDdDeptId" parameterType="SysDdDept">
update sys_dd_dept
<set>
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="leader != null">leader = #{leader},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="email != null">email = #{email},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="ddParentId != null">dd_parent_id = #{ddParentId},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where dd_dept_id = #{ddDeptId}
</update>
<delete id="deleteDdDeptById" parameterType="Long">
update sys_dd_dept set del_flag = '2' where dept_id = #{deptId} and dept_id != 100
</delete>
<delete id="deleteDdDeptByDdDeptId" parameterType="Long">
update sys_dd_dept set del_flag = '2' where dd_dept_id = #{ddDeptId}
</delete>
</mapper>
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="yangtz.cs.liu.dingding.mapper.schoolTeacher.DdTeacherMapper">
<resultMap type="SysDdTeacher" id="SysDdTeacherResult">
<result property="id" column="id"/>
<result property="teacherName" column="teacher_name"/>
<result property="teacherTel" column="teacher_tel"/>
<result property="teacherCode" column="teacher_code"/>
<result property="idCard" column="id_card"/>
<result property="deviceNum" column="device_num"/>
<result property="homeAddress" column="home_address"/>
<result property="nation" column="nation"/>
<result property="picUrl" column="pic_url"/>
<result property="birthday" column="birthday"/>
<result property="education" column="education"/>
<result property="sex" column="sex"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<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"/>
</resultMap>
<insert id="addTeacherList" parameterType="SysDdTeacher" useGeneratedKeys="true" keyProperty="id">
insert into sys_dd_teacher
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="teacherName != null">teacher_name,</if>
<if test="teacherTel != null">teacher_tel,</if>
<if test="teacherCode != null">teacher_code,</if>
<if test="idCard != null">id_card,</if>
<if test="homeAddress != null">home_address,</if>
<if test="nation != null">nation,</if>
<if test="picUrl != null">pic_url,</if>
<if test="birthday != null">birthday,</if>
<if test="education != null">education,</if>
<if test="sex != null">sex,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</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="deviceNum != null">device_num,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="teacherName != null">#{teacherName},</if>
<if test="teacherTel != null">#{teacherTel},</if>
<if test="teacherCode != null">#{teacherCode},</if>
<if test="idCard != null">#{idCard},</if>
<if test="homeAddress != null">#{homeAddress},</if>
<if test="nation != null">#{nation},</if>
<if test="picUrl != null">#{picUrl},</if>
<if test="birthday != null">#{birthday},</if>
<if test="education != null">#{education},</if>
<if test="sex != null">#{sex},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</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="deviceNum != null">#{deviceNum},</if>
</trim>
</insert>
<update id="updateDdTeacher" parameterType="SysDdTeacher">
update sys_dd_teacher
<trim prefix="SET" suffixOverrides=",">
<if test="teacherName != null">teacher_name = #{teacherName},</if>
<if test="teacherTel != null">teacher_tel = #{teacherTel},</if>
<if test="teacherCode != null">teacher_code = #{teacherCode},</if>
<if test="idCard != null">id_card = #{idCard},</if>
<if test="homeAddress != null">home_address = #{homeAddress},</if>
<if test="nation != null">nation = #{nation},</if>
<if test="picUrl != null">pic_url = #{picUrl},</if>
<if test="birthday != null">birthday = #{birthday},</if>
<if test="education != null">education = #{education},</if>
<if test="sex != null">sex = #{sex},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</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>
where id = #{id}
</update>
<!--批量新增教师-->
<insert id="batchInsertTeacher" parameterType="SysDdTeacher" useGeneratedKeys="true" keyProperty="id">
<foreach collection="list" item="data" separator=";">
insert into sys_dd_teacher
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="data.id != null">id,</if>
<if test="data.teacherName != null">teacher_name,</if>
<if test="data.teacherTel != null">teacher_tel,</if>
<if test="data.teacherCode != null">teacher_code,</if>
<if test="data.idCard != null">id_card,</if>
<if test="data.homeAddress != null">home_address,</if>
<if test="data.nation != null">nation,</if>
<if test="data.picUrl != null">pic_url,</if>
<if test="data.birthday != null">birthday,</if>
<if test="data.education != null">education,</if>
<if test="data.sex != null">sex,</if>
<if test="data.createBy != null">create_by,</if>
<if test="data.createTime != null">create_time,</if>
<if test="data.updateBy != null">update_by,</if>
<if test="data.updateTime != null">update_time,</if>
<if test="data.openId != null">open_id,</if>
<if test="data.ddUserId != null">dd_user_id,</if>
<if test="data.unionId != null">union_id,</if>
<if test="data.delFlag != null and data.delFlag != ''">del_flag,</if>
<if test="data.deviceNum != null">device_num,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="data.id != null">#{data.id},</if>
<if test="data.teacherName != null">#{data.teacherName},</if>
<if test="data.teacherTel != null">#{data.teacherTel},</if>
<if test="data.teacherCode != null">#{data.teacherCode},</if>
<if test="data.idCard != null">#{data.idCard},</if>
<if test="data.homeAddress != null">#{data.homeAddress},</if>
<if test="data.nation != null">#{data.nation},</if>
<if test="data.picUrl != null">#{data.picUrl},</if>
<if test="data.birthday != null">#{data.birthday},</if>
<if test="data.education != null">#{data.education},</if>
<if test="data.sex != null">#{data.sex},</if>
<if test="data.createBy != null">#{data.createBy},</if>
<if test="data.createTime != null">#{data.createTime},</if>
<if test="data.updateBy != null">#{data.updateBy},</if>
<if test="data.updateTime != null">#{data.updateTime},</if>
<if test="data.openId != null">#{data.openId},</if>
<if test="data.ddUserId != null">#{data.ddUserId},</if>
<if test="data.unionId != null">#{data.unionId},</if>
<if test="data.delFlag != null and data.delFlag != ''">#{data.delFlag},</if>
<if test="data.deviceNum != null">#{data.deviceNum},</if>
</trim>
</foreach>
</insert>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment