fix: fix错误

This commit is contained in:
2025-02-26 01:59:46 +08:00
parent 69721f3944
commit 3477d098b7
14 changed files with 71 additions and 75 deletions

View File

@@ -128,7 +128,7 @@ export class User extends Model {
}
const cache = await redis.get(`user:${id}:orgs`);
if (cache) {
return JSON.parse(cache);
return JSON.parse(cache) as string[];
}
const orgs = await Org.findAll({
order: [['updatedAt', 'DESC']],
@@ -229,9 +229,8 @@ User.sync({ alter: true, logging: false })
const letter = 'abcdefghijklmnopqrstuvwxyz';
const custom = customAlphabet(letter, 6);
export const initializeUser = async (pwd = custom()) => {
const w = await User.findAndCountAll();
console.info('[User count]', w.count);
if (w.count < 1) {
const w = await User.findOne({ where: { username: 'root' }, logging: false });
if (!w) {
const root = await User.createUser('root', pwd, '系统管理员');
const org = await User.createOrg('admin', root.id, '管理员');
console.info(' new Users name', root.username, org.username);
@@ -250,10 +249,6 @@ export const initializeUser = async (pwd = custom()) => {
}
};
export const createDemoUser = async (username = 'demo', pwd = custom()) => {
const w = await User.findAndCountAll({
logging: false,
});
console.info('[User count]', w.count);
const u = await User.findOne({ where: { username }, logging: false });
if (!u) {
const user = await User.createUser(username, pwd, 'demo');