人员新增并赋予全功能用户原创
9人赞赏了该文章
1,842次浏览
编辑于2021年11月01日 15:06:27
人员操作需要调用kd.bos.servicehelper.user.UserServiceHelper
新增:UserServiceHelper.add(List<UserParam> userList)
其中UserParam为人员参数说明:
public class UserParam { private long id; private long customUserId; private Map<String, Object> dataMap; private boolean success = true; private String msg; public UserParam() { } public long getId() { return this.id; } public void setId(long id) { this.id = id; } public long getCustomUserId() { return this.customUserId; } public void setCustomUserId(long customUserId) { this.customUserId = customUserId; } public Map<String, Object> getDataMap() { return this.dataMap; } public void setDataMap(Map<String, Object> dataMap) { this.dataMap = dataMap; } public boolean isSuccess() { return this.success; } public void setSuccess(boolean isSuccess) { this.success = isSuccess; } public String getMsg() { return this.msg; } public void setMsg(String msg) { this.msg = msg; } }
dataMap对应人员表的数据,例如:人员编码,姓名,手机号等信息
其中add接口调用规范如下:
1) 调用方可以自定义人员ID:设置参数customUserId
2) dataMap参数为人员属性,包括职位分录信息
3) 新增人员默认为已启用、已审核状态
4) 新增人员的类型都是职员
启用接口:人员新增之后需要调用UserServiceHelper. enable (List<UserParam> userList)来启用接口
默认密码:人员创建成功,可以给人员赋予一个默认密码
授权:可以对人员进行指定授权,参考上一篇文章,也可以对赋予全功能用户权限
案例代码如下:
Map<String, Object> userdata = new HashMap<String, Object>(); userdata.put("name", name); userdata.put("number", phone); userdata.put("usertype", 1); userdata.put("phone", phone); userdata.put("fuid", uid); ArrayList<LinkedHashMap<String, Object>> entryentity = new ArrayList<>(); LinkedHashMap<String, Object> entryentitydata = new LinkedHashMap<>(); entryentitydata.put("dpt", 100000); entryentitydata.put("position", companyname); entryentity.add(entryentitydata); userdata.put("entryentity", entryentity); // 创建一个人员 List<UserParam> userList = new ArrayList<>(); UserParam uParam = new UserParam(); uParam.setDataMap(userdata); userList.add(uParam); // 新增人员 UserServiceHelper.addOrUpdate(userList); String msg = uParam.getMsg(); UserServiceHelper.enable(userList); /** * 拼接SQL语句字符串 修改密码为1234567 ; */ String ss = "UPDATE t_sec_user_u SET FPASSWORD = '8HrquJnZfyOkmmHkpGLXfg==',FIsRegisted = '1',fisactived = '1' WHERE FID = (SELECT FID FROM t_sec_user WHERE FPHONE = '"; ss += params.get("phone"); ss += "')"; DB.execute(DBRoute.basedata, ss); /** * 全功能用户保存 */ DynamicObject superuser = BusinessDataServiceHelper.newDynamicObject("perm_superuser"); QFilter filter = new QFilter("phone", "=", params.get("phone")); DynamicObject user = orm.queryOne("bos_user", new QFilter[] { filter }); //获取人员id--userId superuser.set("user", userId); SaveServiceHelper.save(new DynamicObject[] { superuser });
赞 9
9人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读