user

package
v1.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

* @Author: SpenserCai * @Date: 2023-08-30 20:38:24 * @version: * @LastEditors: SpenserCai * @LastEditTime: 2023-10-19 14:20:09 * @Description: file content

Index

Constants

This section is empty.

Variables

View Source
var PermissionTable = map[string][]string{
	"admin": {"user_info", "cluster_status"},
}

权限表,如果命令出现再某个role中,则代表只有这个role的用户才能使用这个命令,key是role,value是命令

Functions

This section is empty.

Types

type StableConfig

type StableConfig struct {
	Model          string  `json:"sd_model_checkpoint"`
	Vae            string  `json:"sd_vae"`
	Height         int64   `json:"height"`
	Width          int64   `json:"width"`
	Steps          int64   `json:"steps"`
	CfgScale       float64 `json:"cfg_scale"`
	NegativePrompt string  `json:"negative_prompt"`
	Sampler        string  `json:"sampler"`
	ClipSkip       int64   `json:"CLIP_stop_at_last_layers"`
}

type UserCenterService

type UserCenterService struct {
	Db *db.BotDb
}

func NewUserCenterService

func NewUserCenterService(ucsCfg *config.UserCenter) (*UserCenterService, error)

func (*UserCenterService) BanUser

func (ucs *UserCenterService) BanUser(id string) error

func (*UserCenterService) CheckUserPermission added in v0.6.5

func (ucs *UserCenterService) CheckUserPermission(id string, cmd string) bool

func (*UserCenterService) DeleteUserHistory added in v1.0.1

func (ucs *UserCenterService) DeleteUserHistory(messageId string, userId string) error

删除历史记录(软删除)

func (*UserCenterService) GetUserCount added in v0.9.4

func (ucs *UserCenterService) GetUserCount() (int64, error)

获取用户总数

func (*UserCenterService) GetUserHistoryList added in v1.0.1

func (ucs *UserCenterService) GetUserHistoryList(userId string, cmd string, page int, pageSize int, excludePrivate bool) ([]*db_backend.History, int, error)

获取用户历史记录列表分页获取 TODO:加上参数:excludePrivate

func (*UserCenterService) GetUserHistoryOptWithMessageId added in v0.8.4

func (ucs *UserCenterService) GetUserHistoryOptWithMessageId(messageId string, commandName string) (string, error)

获取历史记录

func (*UserCenterService) GetUserImageTotal added in v1.1.4

func (ucs *UserCenterService) GetUserImageTotal(id string) (int64, error)

func (*UserCenterService) GetUserInfo

func (ucs *UserCenterService) GetUserInfo(id string) (*UserInfo, error)

func (*UserCenterService) GetUserInfoList added in v1.1.3

func (ucs *UserCenterService) GetUserInfoList(ids []string) ([]*UserInfo, error)

func (*UserCenterService) GetUserList added in v0.9.4

func (ucs *UserCenterService) GetUserList(id string) ([]*UserInfo, error)

获取用户列表 判断当前用户是否为管理员,如果是管理员则返回所有用户,如果不是管理员则返回当前用户

func (*UserCenterService) GetUserStableConfigItem

func (ucs *UserCenterService) GetUserStableConfigItem(id string, key string, defaultValue interface{}) (interface{}, error)

func (*UserCenterService) GetUsersImageTotal added in v1.2.2

func (ucs *UserCenterService) GetUsersImageTotal(ids []string) (map[string]int, error)

func (*UserCenterService) IsAdmin added in v0.9.4

func (ucs *UserCenterService) IsAdmin(id string) (bool, error)

判断当前用户是否为管理员

func (*UserCenterService) IsBaned added in v0.9.5

func (ucs *UserCenterService) IsBaned(id string) (bool, error)

func (*UserCenterService) IsPrivate added in v1.3.2

func (ucs *UserCenterService) IsPrivate(id string) (bool, error)

获取用户是否是Private

func (*UserCenterService) IsRegistered added in v0.10.0

func (ucs *UserCenterService) IsRegistered(id string) bool

func (*UserCenterService) RegisterUser

func (ucs *UserCenterService) RegisterUser(user *UserInfo) (string, error)

func (*UserCenterService) SearchUserInfoList added in v1.2.1

func (ucs *UserCenterService) SearchUserInfoList(page int, pageSize int, query map[string]interface{}) ([]*UserInfo, int, error)

func (*UserCenterService) SetUserEnable added in v1.3.3

func (ucs *UserCenterService) SetUserEnable(id string, enable bool) error

func (*UserCenterService) SetUserPrivate added in v1.3.3

func (ucs *UserCenterService) SetUserPrivate(id string, isPrivate bool) error

设置用户是否是Private

func (*UserCenterService) UnBanUser added in v0.9.5

func (ucs *UserCenterService) UnBanUser(id string) error

func (*UserCenterService) UpdateStableConfig

func (ucs *UserCenterService) UpdateStableConfig(user *UserInfo) error

func (*UserCenterService) UpdateUserInfo

func (ucs *UserCenterService) UpdateUserInfo(user *UserInfo) error

func (*UserCenterService) WriteUserHistory added in v0.8.4

func (ucs *UserCenterService) WriteUserHistory(messageId string, userId string, commandName string, optionJson string) error

写入用户历史记录

func (*UserCenterService) WriteUserHistoryImages added in v0.10.3

func (ucs *UserCenterService) WriteUserHistoryImages(messageId string, userId string, images string, imagesBlurHash string) error

写入图片信息

type UserInfo

type UserInfo struct {
	Enable             bool         `json:"enable"`
	IsPrivate          bool         `json:"is_private"`
	Avatar             string       `json:"avatar"`
	Name               string       `json:"name"`
	Id                 string       `json:"id"`
	Roles              string       `json:"roles"`
	Created            string       `json:"created"`
	StableConfig       StableConfig `json:"stable_config"`
	CycleCredit        int          `json:"cycle_credit"`         // 周期credit
	CreditUpdateCycle  string       `json:"credit_update_cycle"`  // credit更新周期 格式 1|H 1|D 1|W 1|M
	CycleCreditUpdated string       `json:"cycle_credit_updated"` // 周期credit更新时间,用于判断是否需要更新credit
	PlusCredit         int          `json:"plus_credit"`          // 充值的credit
}

Directories

Path Synopsis
db
* @Author: SpenserCai * @Date: 2023-08-30 21:21:40 * @version: * @LastEditors: SpenserCai * @LastEditTime: 2023-10-14 14:55:00 * @Description: file content
* @Author: SpenserCai * @Date: 2023-08-30 21:21:40 * @version: * @LastEditors: SpenserCai * @LastEditTime: 2023-10-14 14:55:00 * @Description: file content
db_backend
* @Author: SpenserCai * @Date: 2023-08-31 00:44:10 * @version: * @LastEditors: SpenserCai * @LastEditTime: 2023-10-18 21:43:21 * @Description: file content
* @Author: SpenserCai * @Date: 2023-08-31 00:44:10 * @version: * @LastEditors: SpenserCai * @LastEditTime: 2023-10-18 21:43:21 * @Description: file content

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL