0


快速集成钉钉免登组件

1.依赖

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
            <version>3.0.1</version>
        </dependency>

2.接口

package com.ciih.forward.server;

import com.ciih.forward.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * RPC调用钉钉免登接口
 *
 * @author Lenovo
 */
@Component
@FeignClient(name = "AuthDingDingServer", url = "https://oapi.dingtalk.com")
public interface AuthDingDingServer {
    @GetMapping("/gettoken")
    GetTokenDto gettoken(@RequestParam String appkey, @RequestParam String appsecret);

    @GetMapping("/user/getuserinfo")
    GetUserInfoDto getuserinfo(@RequestParam String access_token, @RequestParam String code);

    @PostMapping("/topapi/v2/user/get")
    UserGetDto userget(@RequestParam String access_token, @RequestBody UserGetParam param);
}

3.实体类

import lombok.Data;

@Data
public class GetTokenDto {

    /**
     * errcode : 0
     * access_token : 7a43305840f0387083ef6a462a9c59bb
     * errmsg : ok
     * expires_in : 7200
     */

    private int errcode;
    private String access_token;
    private String errmsg;
    private int expires_in;
}
import lombok.Data;

@Data
public class GetUserInfoDto {

    private int errcode;
    private int sys_level;
    private boolean is_sys;
    private String name;
    private String errmsg;
    private String deviceId;
    private String userid;
}
package com.ciih.forward.dto;

import java.util.List;

public class UserGetDto {

    /**
     * errcode : 0
     * errmsg : ok
     * result : {"extension":"{\"爱好\":\"旅游\",\"年龄\":\"24\"}","unionid":"xBnhjgjmofhhsLxxx","boss":false,"unionEmpExt":{"corpId":"ding1c417cfd9e3142d1acaaa37764f9xxxx","userid":"45694432-1019596262","unionEmpMapList":[{"corpId":"ding1c417cfd9e3142d1acaaa37764f9xxxx","userid":"45694432-1019596262"}]},"role_list":[{"group_name":"默认","id":1507113578,"name":"主管理员"}],"admin":true,"remark":"杨XX","title":"服务经理","hired_date":1598457600000,"userid":"manager4220","work_place":"杭州","dept_order_list":[{"dept_id":1,"order":176318669012199520},{"dept_id":379661095,"order":176318556766960500}],"real_authed":true,"dept_id_list":[1,379661095],"job_number":"10001","email":"[email protected]","leader_in_dept":[{"dept_id":379661095,"leader":false},{"dept_id":1,"leader":false}],"manager_userid":"user01","mobile":"188xxxx1234","active":true,"telephone":"010-8xxxx6-2345","avatar":"","hide_mobile":false,"senior":false,"name":"杨xxx","state_code":"86"}
     * request_id : 51jql88tpa6g
     */

    private int errcode;
    private String errmsg;
    private ResultBean result;
    private String request_id;

    public int getErrcode() {
        return errcode;
    }

    public void setErrcode(int errcode) {
        this.errcode = errcode;
    }

    public String getErrmsg() {
        return errmsg;
    }

    public void setErrmsg(String errmsg) {
        this.errmsg = errmsg;
    }

    public ResultBean getResult() {
        return result;
    }

    public void setResult(ResultBean result) {
        this.result = result;
    }

    public String getRequest_id() {
        return request_id;
    }

    public void setRequest_id(String request_id) {
        this.request_id = request_id;
    }

    public static class ResultBean {
        /**
         * extension : {"爱好":"旅游","年龄":"24"}
         * unionid : xBnhjgjmofhhsLxxx
         * boss : false
         * unionEmpExt : {"corpId":"ding1c417cfd9e3142d1acaaa37764f9xxxx","userid":"45694432-1019596262","unionEmpMapList":[{"corpId":"ding1c417cfd9e3142d1acaaa37764f9xxxx","userid":"45694432-1019596262"}]}
         * role_list : [{"group_name":"默认","id":1507113578,"name":"主管理员"}]
         * admin : true
         * remark : 杨XX
         * title : 服务经理
         * hired_date : 1598457600000
         * userid : manager4220
         * work_place : 杭州
         * dept_order_list : [{"dept_id":1,"order":176318669012199520},{"dept_id":379661095,"order":176318556766960500}]
         * real_authed : true
         * dept_id_list : [1,379661095]
         * job_number : 10001
         * email : [email protected]
         * leader_in_dept : [{"dept_id":379661095,"leader":false},{"dept_id":1,"leader":false}]
         * manager_userid : user01
         * mobile : 188xxxx1234
         * active : true
         * telephone : 010-8xxxx6-2345
         * avatar :
         * hide_mobile : false
         * senior : false
         * name : 杨xxx
         * state_code : 86
         */

        private String extension;
        private String unionid;
        private boolean boss;
        private UnionEmpExtBean unionEmpExt;
        private boolean admin;
        private String remark;
        private String title;
        private long hired_date;
        private String userid;
        private String work_place;
        private boolean real_authed;
        private String job_number;
        private String email;
        private String manager_userid;
        private String mobile;
        private boolean active;
        private String telephone;
        private String avatar;
        private boolean hide_mobile;
        private boolean senior;
        private String name;
        private String state_code;
        private List<RoleListBean> role_list;
        private List<DeptOrderListBean> dept_order_list;
        private List<Integer> dept_id_list;
        private List<LeaderInDeptBean> leader_in_dept;

        public String getExtension() {
            return extension;
        }

        public void setExtension(String extension) {
            this.extension = extension;
        }

        public String getUnionid() {
            return unionid;
        }

        public void setUnionid(String unionid) {
            this.unionid = unionid;
        }

        public boolean isBoss() {
            return boss;
        }

        public void setBoss(boolean boss) {
            this.boss = boss;
        }

        public UnionEmpExtBean getUnionEmpExt() {
            return unionEmpExt;
        }

        public void setUnionEmpExt(UnionEmpExtBean unionEmpExt) {
            this.unionEmpExt = unionEmpExt;
        }

        public boolean isAdmin() {
            return admin;
        }

        public void setAdmin(boolean admin) {
            this.admin = admin;
        }

        public String getRemark() {
            return remark;
        }

        public void setRemark(String remark) {
            this.remark = remark;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public long getHired_date() {
            return hired_date;
        }

        public void setHired_date(long hired_date) {
            this.hired_date = hired_date;
        }

        public String getUserid() {
            return userid;
        }

        public void setUserid(String userid) {
            this.userid = userid;
        }

        public String getWork_place() {
            return work_place;
        }

        public void setWork_place(String work_place) {
            this.work_place = work_place;
        }

        public boolean isReal_authed() {
            return real_authed;
        }

        public void setReal_authed(boolean real_authed) {
            this.real_authed = real_authed;
        }

        public String getJob_number() {
            return job_number;
        }

        public void setJob_number(String job_number) {
            this.job_number = job_number;
        }

        public String getEmail() {
            return email;
        }

        public void setEmail(String email) {
            this.email = email;
        }

        public String getManager_userid() {
            return manager_userid;
        }

        public void setManager_userid(String manager_userid) {
            this.manager_userid = manager_userid;
        }

        public String getMobile() {
            return mobile;
        }

        public void setMobile(String mobile) {
            this.mobile = mobile;
        }

        public boolean isActive() {
            return active;
        }

        public void setActive(boolean active) {
            this.active = active;
        }

        public String getTelephone() {
            return telephone;
        }

        public void setTelephone(String telephone) {
            this.telephone = telephone;
        }

        public String getAvatar() {
            return avatar;
        }

        public void setAvatar(String avatar) {
            this.avatar = avatar;
        }

        public boolean isHide_mobile() {
            return hide_mobile;
        }

        public void setHide_mobile(boolean hide_mobile) {
            this.hide_mobile = hide_mobile;
        }

        public boolean isSenior() {
            return senior;
        }

        public void setSenior(boolean senior) {
            this.senior = senior;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getState_code() {
            return state_code;
        }

        public void setState_code(String state_code) {
            this.state_code = state_code;
        }

        public List<RoleListBean> getRole_list() {
            return role_list;
        }

        public void setRole_list(List<RoleListBean> role_list) {
            this.role_list = role_list;
        }

        public List<DeptOrderListBean> getDept_order_list() {
            return dept_order_list;
        }

        public void setDept_order_list(List<DeptOrderListBean> dept_order_list) {
            this.dept_order_list = dept_order_list;
        }

        public List<Integer> getDept_id_list() {
            return dept_id_list;
        }

        public void setDept_id_list(List<Integer> dept_id_list) {
            this.dept_id_list = dept_id_list;
        }

        public List<LeaderInDeptBean> getLeader_in_dept() {
            return leader_in_dept;
        }

        public void setLeader_in_dept(List<LeaderInDeptBean> leader_in_dept) {
            this.leader_in_dept = leader_in_dept;
        }

        public static class UnionEmpExtBean {
            /**
             * corpId : ding1c417cfd9e3142d1acaaa37764f9xxxx
             * userid : 45694432-1019596262
             * unionEmpMapList : [{"corpId":"ding1c417cfd9e3142d1acaaa37764f9xxxx","userid":"45694432-1019596262"}]
             */

            private String corpId;
            private String userid;
            private List<UnionEmpMapListBean> unionEmpMapList;

            public String getCorpId() {
                return corpId;
            }

            public void setCorpId(String corpId) {
                this.corpId = corpId;
            }

            public String getUserid() {
                return userid;
            }

            public void setUserid(String userid) {
                this.userid = userid;
            }

            public List<UnionEmpMapListBean> getUnionEmpMapList() {
                return unionEmpMapList;
            }

            public void setUnionEmpMapList(List<UnionEmpMapListBean> unionEmpMapList) {
                this.unionEmpMapList = unionEmpMapList;
            }

            public static class UnionEmpMapListBean {
                /**
                 * corpId : ding1c417cfd9e3142d1acaaa37764f9xxxx
                 * userid : 45694432-1019596262
                 */

                private String corpId;
                private String userid;

                public String getCorpId() {
                    return corpId;
                }

                public void setCorpId(String corpId) {
                    this.corpId = corpId;
                }

                public String getUserid() {
                    return userid;
                }

                public void setUserid(String userid) {
                    this.userid = userid;
                }
            }
        }

        public static class RoleListBean {
            /**
             * group_name : 默认
             * id : 1507113578
             * name : 主管理员
             */

            private String group_name;
            private int id;
            private String name;

            public String getGroup_name() {
                return group_name;
            }

            public void setGroup_name(String group_name) {
                this.group_name = group_name;
            }

            public int getId() {
                return id;
            }

            public void setId(int id) {
                this.id = id;
            }

            public String getName() {
                return name;
            }

            public void setName(String name) {
                this.name = name;
            }
        }

        public static class DeptOrderListBean {
            /**
             * dept_id : 1
             * order : 176318669012199520
             */

            private int dept_id;
            private long order;

            public int getDept_id() {
                return dept_id;
            }

            public void setDept_id(int dept_id) {
                this.dept_id = dept_id;
            }

            public long getOrder() {
                return order;
            }

            public void setOrder(long order) {
                this.order = order;
            }
        }

        public static class LeaderInDeptBean {
            /**
             * dept_id : 379661095
             * leader : false
             */

            private int dept_id;
            private boolean leader;

            public int getDept_id() {
                return dept_id;
            }

            public void setDept_id(int dept_id) {
                this.dept_id = dept_id;
            }

            public boolean isLeader() {
                return leader;
            }

            public void setLeader(boolean leader) {
                this.leader = leader;
            }
        }
    }
}
标签: eureka java postman

本文转载自: https://blog.csdn.net/wenxingchen/article/details/125271611
版权归原作者 苍穹之跃 所有, 如有侵权,请联系我们删除。

“快速集成钉钉免登组件”的评论:

还没有评论