更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -1,22 +1,3 @@
|
||||
// 老数据补齐:为「人员管理里有、用户管理里没有」的老员工补建登录账号。
|
||||
//
|
||||
// 背景:早期人员是直接在 OA 人员管理里手工录入的(离线导入),没有对应的登录账号,
|
||||
// 于是「基础设置 → 用户管理」人少、「OA → 人员管理」人多,两边对不上。
|
||||
//
|
||||
// 本脚本走的是和「用户管理 → 添加用户」完全相同的服务链路:
|
||||
// authsvc.SyncTenantUserAndGetIdentity(建/取统一身份,返回 identity_id)
|
||||
// → services.BindTenantUser(写 yz_system_tenant_user,uid = identity_id)
|
||||
// 员工档案已存在,按 (tid, account) 自动关联,不会重复建档、也不会丢部门/职位/排班。
|
||||
//
|
||||
// 用法(在 go/ 目录下运行,读取 conf/app.conf):
|
||||
//
|
||||
// go run scripts/syncemployeeusers/main.go -tid 2 预演:只列出会建哪些账号
|
||||
// go run scripts/syncemployeeusers/main.go -tid 2 -apply 真正创建账号并打印初始密码
|
||||
// go run scripts/syncemployeeusers/main.go -tid 2 -apply -password "Abc@123456"
|
||||
//
|
||||
// 安全提示:
|
||||
// - 未指定 -password 时每个账号生成随机初始密码,执行完请立即转告本人并让其修改;
|
||||
// - 若员工手机号/邮箱已属于另一个身份,脚本会跳过并提示,避免把两个人错误合并。
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -62,7 +43,6 @@ func main() {
|
||||
status int64
|
||||
}
|
||||
|
||||
// 员工侧:所有未删除员工
|
||||
empQuery := models.Orm.QueryTable(new(models.BackendEmployee)).Filter("delete_time__isnull", true)
|
||||
if *tid > 0 {
|
||||
empQuery = empQuery.Filter("tid", *tid)
|
||||
@@ -73,7 +53,6 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// 用户侧:(tid, account) 已有的账号
|
||||
userQuery := models.Orm.QueryTable(new(models.SystemTenantUser)).Filter("delete_time__isnull", true)
|
||||
if *tid > 0 {
|
||||
userQuery = userQuery.Filter("tid", *tid)
|
||||
@@ -208,7 +187,6 @@ func main() {
|
||||
fmt.Printf(" 跳过 %s:写入租户用户失败 %v\n", item.account, err)
|
||||
continue
|
||||
}
|
||||
// 部门:与员工档案保持一致(用户管理表单里的所属部门)
|
||||
if deptID := parseUint(item.dept); deptID > 0 {
|
||||
_, _ = models.Orm.QueryTable(new(models.SystemTenantUser)).
|
||||
Filter("id", id).
|
||||
@@ -222,7 +200,6 @@ func main() {
|
||||
fmt.Printf("\n完成:新建 %d 个账号,跳过 %d 个\n", created, len(todo)-created)
|
||||
}
|
||||
|
||||
// identityConflict 手机号/邮箱已被其他账号占用时返回原因,避免错误合并两个自然人
|
||||
func identityConflict(account, phone, email string) string {
|
||||
if phone != "" {
|
||||
var rows []models.AuthIdentity
|
||||
@@ -255,7 +232,6 @@ func parseUint(v string) uint64 {
|
||||
return n
|
||||
}
|
||||
|
||||
// randomPassword 生成 12 位含大小写与数字的随机初始密码
|
||||
func randomPassword() string {
|
||||
const lower = "abcdefghijkmnpqrstuvwxyz"
|
||||
const upper = "ABCDEFGHJKLMNPQRSTUVWXYZ"
|
||||
@@ -270,7 +246,6 @@ func randomPassword() string {
|
||||
}
|
||||
buf[i] = pool[n.Int64()]
|
||||
}
|
||||
// 保证至少各含一位,避免被前端复杂度校验拦住
|
||||
buf[0] = upper[randIdx(len(upper))]
|
||||
buf[1] = lower[randIdx(len(lower))]
|
||||
buf[2] = digits[randIdx(len(digits))]
|
||||
|
||||
Reference in new issue
Block a user