| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- package com.usoftchina.qywx.sdk.dto;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * @author yingp
- */
- public class CreateUserReq {
- /**
- * 成员UserID。对应管理端的帐号,企业内必须唯一。不区分大小写,长度为1~64个字节。只能由数字、字母和“_-@.”四种字符组成,且第一个字符必须是数字或字母。
- */
- private String userId;
- /**
- * 成员名称。长度为1~64个utf8字符
- */
- private String name;
- /**
- * 成员别名。长度1~32个utf8字符
- */
- private String alias;
- /**
- * 手机号码。企业内必须唯一,mobile/email二者不能同时为空
- */
- private String mobile;
- /**
- * 成员所属部门列表,不超过20个
- */
- private List<Department> department;
- /**
- * 职务信息。长度为0~128个字符
- */
- private String position;
- /**
- * 对外职务,如果设置了该值,则以此作为对外展示的职务,否则以position来展示。长度12个汉字内
- */
- private String externalPosition;
- /**
- * 性别。1表示男性,2表示女性
- */
- private Gender gender;
- /**
- * 邮箱。长度6~64个字节,且为有效的email格式。企业内必须唯一,mobile/email二者不能同时为空
- */
- private String email;
- /**
- * 座机。32字节以内,由纯数字或’-‘号组成
- */
- private String telephone;
- /**
- * 成员头像的mediaid,通过素材管理接口上传图片获得的mediaid
- */
- private String avatarMediaId;
- /**
- * 启用/禁用成员。1表示启用成员,0表示禁用成员
- */
- private Boolean enable;
- /**
- * 地址。长度最大128个字符
- */
- private String address;
- /**
- * 是否邀请该成员使用企业微信(将通过微信服务通知或短信或邮件下发邀请,每天自动下发一次,最多持续3个工作日),默认值为true。
- */
- private Boolean toInvite;
- public CreateUserReq userId(String userId) {
- this.userId = userId;
- return this;
- }
- public CreateUserReq name(String name) {
- this.name = name;
- return this;
- }
- public CreateUserReq alias(String alias) {
- this.alias = alias;
- return this;
- }
- public CreateUserReq mobile(String mobile) {
- this.mobile = mobile;
- return this;
- }
- public CreateUserReq email(String email) {
- this.email = email;
- return this;
- }
- public CreateUserReq department(List<Department> department) {
- this.department = department;
- return this;
- }
- public CreateUserReq position(String position) {
- this.position = position;
- return this;
- }
- public CreateUserReq externalPosition(String externalPosition) {
- this.externalPosition = externalPosition;
- return this;
- }
- public CreateUserReq gender(Gender gender) {
- this.gender = gender;
- return this;
- }
- public CreateUserReq telephone(String telephone) {
- this.telephone = telephone;
- return this;
- }
- public CreateUserReq avatar(String avatarMediaId) {
- this.avatarMediaId = avatarMediaId;
- return this;
- }
- public CreateUserReq address(String address) {
- this.address = address;
- return this;
- }
- public CreateUserReq toInvite(boolean toInvite) {
- this.toInvite = toInvite;
- return this;
- }
- public CreateUserReq enable(boolean enable) {
- this.enable = enable;
- return this;
- }
- public Map<String, Object> build() {
- Map<String, Object> data = new HashMap<>(8);
- data.put("userid", userId);
- data.put("name", name);
- if (null != alias) {
- data.put("alias", alias);
- }
- if (null != mobile) {
- data.put("mobile", mobile);
- }
- if (null != email) {
- data.put("email", email);
- }
- if (null != department) {
- List<Integer> idList = new ArrayList<>(department.size());
- List<Integer> orderList = new ArrayList<>(department.size());
- List<Integer> leaderList = new ArrayList<>(department.size());
- department.forEach(dept -> {
- idList.add(dept.id);
- orderList.add(dept.order);
- leaderList.add(dept.leader ? 1 : 0);
- });
- data.put("department", idList);
- data.put("order", orderList);
- data.put("is_leader_in_dept", leaderList);
- }
- if (null != gender) {
- data.put("gender", gender.code);
- }
- if (null != telephone) {
- data.put("telephone", telephone);
- }
- if (null != avatarMediaId) {
- data.put("avatar_mediaid", avatarMediaId);
- }
- if (null != enable) {
- data.put("enable", enable ? 1 : 0);
- }
- if (null != toInvite) {
- data.put("to_invite", toInvite);
- }
- if (null != address) {
- data.put("address", address);
- }
- if (null != position) {
- data.put("position", position);
- }
- if (null != externalPosition) {
- data.put("external_position", externalPosition);
- }
- return data;
- }
- public enum Gender {
- MALE("1"), FEMALE("2");
- private final String code;
- Gender(String code) {
- this.code = code;
- }
- }
- public static class Department {
- /**
- * 成员所属部门id
- */
- private Integer id;
- /**
- * 部门内的排序值,默认为0,成员次序以创建时间从小到大排列,数值越大排序越前面。有效的值范围是[0, 2^32)
- */
- private Integer order;
- /**
- * 表示在所在的部门内是否为上级。1表示为上级,0表示非上级。在审批等应用里可以用来标识上级审批人
- */
- private boolean leader;
- public Department(Integer id, Integer order, boolean leader) {
- this.id = id;
- this.order = order;
- this.leader = leader;
- }
- }
- }
|