Commit d95c443d authored by 黄智's avatar 黄智

推送登录模块

parent 395b624a
...@@ -3,6 +3,7 @@ module gitlab.wodcloud.com/smart-operation/so-operation-api ...@@ -3,6 +3,7 @@ module gitlab.wodcloud.com/smart-operation/so-operation-api
go 1.19 go 1.19
require ( require (
github.com/Luzifer/go-openssl/v4 v4.1.0
github.com/bytedance/go-tagexpr v2.7.4+incompatible github.com/bytedance/go-tagexpr v2.7.4+incompatible
github.com/gin-gonic/gin v1.9.0 github.com/gin-gonic/gin v1.9.0
github.com/go-playground/locales v0.14.1 github.com/go-playground/locales v0.14.1
...@@ -13,13 +14,16 @@ require ( ...@@ -13,13 +14,16 @@ require (
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
github.com/lib/pq v1.10.9 github.com/lib/pq v1.10.9
github.com/minio/minio-go/v7 v7.0.58 github.com/minio/minio-go/v7 v7.0.58
github.com/mojocn/base64Captcha v1.3.5
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/satori/go.uuid v1.2.0
github.com/spf13/cast v1.5.0 github.com/spf13/cast v1.5.0
github.com/spf13/pflag v1.0.5 github.com/spf13/pflag v1.0.5
github.com/thoas/go-funk v0.9.3 github.com/thoas/go-funk v0.9.3
github.com/valyala/fasthttp v1.47.0 github.com/valyala/fasthttp v1.47.0
go.uber.org/zap v1.24.0 go.uber.org/zap v1.24.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1 gopkg.in/natefinch/lumberjack.v2 v2.2.1
k8s.io/apimachinery v0.27.3
xorm.io/xorm v1.3.2 xorm.io/xorm v1.3.2
) )
...@@ -31,7 +35,8 @@ require ( ...@@ -31,7 +35,8 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect github.com/gin-contrib/sse v0.1.0 // indirect
github.com/goccy/go-json v0.10.0 // indirect github.com/goccy/go-json v0.10.0 // indirect
github.com/golang/protobuf v1.5.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect github.com/golang/snappy v0.0.4 // indirect
github.com/henrylee2cn/ameda v1.5.0 // indirect github.com/henrylee2cn/ameda v1.5.0 // indirect
github.com/henrylee2cn/goutil v0.0.0-20220704075712-42f2ec55fe8d // indirect github.com/henrylee2cn/goutil v0.0.0-20220704075712-42f2ec55fe8d // indirect
...@@ -57,11 +62,13 @@ require ( ...@@ -57,11 +62,13 @@ require (
go.uber.org/multierr v1.6.0 // indirect go.uber.org/multierr v1.6.0 // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.9.0 // indirect golang.org/x/crypto v0.9.0 // indirect
golang.org/x/image v0.0.0-20190501045829-6d32002ffd75 // indirect
golang.org/x/net v0.10.0 // indirect golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect golang.org/x/text v0.9.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 // indirect xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 // indirect
) )
This diff is collapsed.
package entity
import "time"
//系统组织表
type SystemOrganization struct {
Id int64 `json:"id" xorm:"pk autoincr"` //id
OrganizationId string `json:"organization_id"` //组织id
Name string `json:"name"` //组织名称or目录名称
POrganizationId string `json:"p_organization_id"` //父级组织id
Description string `json:"description"` //组织介绍
OrganizationCode string `json:"organization_code"` //组织机构代码
Attachment string `json:"attachment"` //组织附件
Sort int64 `json:"sort"` //排序
DataType int64 `json:"data_type"` //数据类型(0目录 1组织)
CreatedTime time.Time `json:"created_time" xorm:"created"` //创建时间
UpdatedTime time.Time `json:"updated_time" xorm:"updated"` //更新时间
IsDeleted int64 `json:"is_deleted"` //是否删除0未删除 1已删除
CreatedBy string `json:"created_by"` //创建者
UpdatedBy string `json:"updated_by"` //更新者
Level int64 `json:"level"` //组织节点层级
}
package entity
import (
"time"
)
type SystemUser struct {
Id int `json:"id" xorm:"pk autoincr" ` // id
Name string `json:"name" ` // 名称
SystemAccount string `json:"system_account" ` // 账号
OrganizationId string `json:"organization_id" xorm:"organization_id"` // 所属组织
Password string `json:"password"` // 密码
State int `json:"state" xorm:"state"` // 状态0禁用1启用
Logo string `json:"logo" xorm:"logo"` // 头像logo
CreatedBy int `json:"created_by" ` // 创建者
CreatedTime time.Time `json:"created_time" xorm:"created" ` // 创建时间
UpdatedBy int `json:"updated_by" ` // 更新者
UpdatedTime time.Time `json:"updated_time" xorm:"updated" ` // 更新时间
IsDeleted int `json:"is_deleted" xorm:"is_deleted"` // 是否删除
}
type SystemUserInfo struct {
Id int `json:"id" xorm:"pk autoincr" ` // id
Name string `json:"name" ` // 名称
SystemAccount string `json:"system_account" ` // 账号
OrganizationId string `json:"organization_id" xorm:"organization_id"` // 所属组织
Password string `json:"password,omitempty"` // 密码
State int `json:"state" xorm:"state"` // 状态0禁用1启用
Logo string `json:"logo" xorm:"logo"` // 头像logo
IsDeleted int `json:"is_deleted" xorm:"is_deleted"` // 是否删除
}
package entity
type User struct {
Id string `json:"id" xorm:"id"` //uuid
UserId string `json:"user_id" xorm:"user_id"` //用户id
UserName string `json:"user_name" xorm:"user_name"` //用户名称
UserType int `json:"user_type" xorm:"user_type"` //用户类型
Phone string `json:"phone" xorm:"phone"` //联系电话
Email string `json:"email" xorm:"email"` //邮箱
UnitName string `json:"unit_name" xorm:"unit_name"` //迁移单位名称
CreatedBy string `json:"created_by" xorm:"created_by"` //创建人
CreatedAt string `json:"created_at" xorm:"created_at"` //创建时间
UpdatedBy string `json:"updated_by" xorm:"updated_by"` //更新人
UpdatedAt string `json:"updated_at" xorm:"updated_at"` //更新时间
Status int `json:"status" xorm:"status"` //状态 1 正常 2 禁用 3 删除
}
package request
import "time"
type UserReq struct {
SystemAccount string `json:"system_account" vd:"len($)>0;msg:'请填写系统账号'"`
Password string `json:"password" vd:"len($)>0;msg:'请填写密码'"`
}
type UserOrgInfo struct {
Id int32 `json:"id" xorm:"pk autoincr" ` //id
OrganizationId string `json:"organization_id" xorm:"organization_id"` //所属组织
OrganizationName string `json:"organization_name" xorm:"organization_name"` //所属组织id
BusinessCode string `json:"business_code" xorm:"business_code"` //业务系统编码
BusinessName string `json:"business_name" xorm:"business_name"` //业务系统名称
SystemAccount string `json:"system_account" xorm:"system_account"` //系统账号
SystemRoleId string `json:"system_role_id" xorm:"system_role_id"` //系统角色id
Password string `json:"password"` //密码
AccessAddress string `json:"access_address" xorm:"access_address"` //访问地址
DevelopId string `json:"develop_id" xorm:"develop_id"` //开发厂商uuid
BusinessDesc string `json:"business_desc" xorm:"business_desc"` //业务系统描述
State int `json:"state" xorm:"state"` //状态0禁用1启用
Logo string `json:"logo" xorm:"logo"` //头像logo
ContactName string `json:"contact_name" xorm:"contact_name"` //联系人姓名
ContactPhone string `json:"contact_phone" xorm:"contact_phone"` //联系人电话
ContactEmail string `json:"contact_email" xorm:"contact_email"` //联系人邮箱
Remark string `json:"remark" xorm:"remark"` //备注
CreatedBy string `json:"created_by" ` //创建者
CreatedTime time.Time `json:"created_time" xorm:"created" ` //创建时间
UpdatedBy string `json:"updated_by" ` //更新者
UpdatedTime time.Time `json:"updated_time" xorm:"updated" ` //更新时间
IsDeleted int `json:"is_deleted" xorm:"is_deleted"` //是否删除
SystemId string `json:"system_id" xorm:"system_id"` //系统账号id
IsAdmin int `json:"is_admin" xorm:"is_admin"` //用户类型
}
package request
//添加组织入参
type OrgInput struct {
POrganizationId string `json:"p_organization_id"` //父级组织id或者目录id
Name string `json:"name"` //组织名称or目录名称
OrganizationCode string `json:"organization_code"` //组织机构代码
Description string `json:"description"` //组织介绍
Attachment string `json:"attachment"` //组织附件
DataType int64 `json:"data_type"` //数据类型(0目录 1组织)
}
//组织排序参数
type OrgSortInput struct {
Id int64 `json:"id" xorm:"pk autoincr"` //id
Sort int64 `json:"sort"` //排序
}
//查询组织详情参数
type QueryOrgDetailInput struct {
OrganizationId string `form:"organization_id"` // 组织id
State string `form:"state" xorm:"state"` // 状态0禁用 1启用
KeyWord string `form:"key_word"` // 关键字(账号或者手机号)
Limit int `form:"limit"` // 页条
Page int `form:"page"` // 页码
DataType string `form:"data_type"` // 数据类型(0目录 1组织 2平台用户组织)
}
//查询业务系统信息
type GetBusinessMsgInput struct {
Limit int `form:"limit"` // 页条
Page int `form:"page"` // 页码
OrganizationId string `form:"organization_id"` // 所属组织
}
//新增用户
type OrgUserInput struct {
Logo string `json:"logo"` // 头像logo
SystemAccount string `json:"system_account" vd:"len($)>1;msg:'请输入账号'"` // 系统账号
ContactPhone string `json:"contact_phone" vd:"phone($)"` // 联系人电话
Password string `json:"password" vd:"len($)>1;msg:'请输入密码'"` // 密码
SelectRole []string `json:"select_role"` // 选择角色
State int `json:"state"` // 状态0禁用1启用
ContactName string `json:"contact_name"` // 联系人姓名
ContactEmail string `json:"contact_email"` // 联系人邮箱
Remark string `json:"remark"` // 备注
OrganizationId string `json:"organization_id" vd:"len($)>1;msg:'请选择所属组织'"` // 所属组织
DocumentType int64 `json:"document_type"` //证件类型 1 身份证
DocumentNumber string `json:"document_number"` //证件号
IsAdmin int `json:"is_admin"` // 用户类型(1.业务系统账号 2.组织管理员账号 3.平台用户账号)
}
//编辑用户
type UpdateOrgUserInput struct {
Logo string `json:"logo"` // 头像logo
SystemAccount string `json:"system_account" vd:"len($)>1;msg:'请输入账号'"` // 系统账号
ContactPhone string `json:"contact_phone" vd:"phone($)"` // 联系人电话
// SelectRole []string `json:"select_role"` // 选择角色
State int `json:"state"` // 状态0禁用1启用
ContactName string `json:"contact_name"` // 联系人姓名
ContactEmail string `json:"contact_email" vd:"email($)"` // 联系人邮箱
Remark string `json:"remark"` // 备注
DocumentType int64 `json:"document_type"` //证件类型 1 身份证
DocumentNumber string `json:"document_number"` //证件号
}
//删除用户
type DelOrgUser struct {
Ids []int `json:"ids" xorm:"pk autoincr"` //id
}
//去重校验
type CheckRepetition struct {
Id int `form:"id" json:"id"`
ContactPhone string `form:"contact_phone" json:"contact_phone"`
}
package request
type CreateSystemUserReq struct {
OrganizationId string `json:"organization_id" vd:"len($)>1;msg:'请选择所属组织'"` // 所属组织
BusinessName string `json:"business_name" vd:"len($)>1;msg:'请输入业务系统名称'"` // 业务系统名称
SystemAccount string `json:"system_account" vd:"len($)>1;msg:'请输入账号'"` // 系统账号
Password string `json:"password" vd:"len($)>1;msg:'请输入密码'"` // 密码
SystemRoleId string `json:"system_role_id"`
AccessAddress string `json:"access_address"` // 访问地址
DevelopId string `json:"develop_id"` // 开发厂商uuid
BusinessDesc string `json:"business_desc"` // 业务系统描述
State int `json:"state"` // 状态0禁用1启用
Logo string `json:"logo"` // 头像logo
ContactName string `json:"contact_name"` // 联系人姓名
ContactPhone string `json:"contact_phone"` // 联系人电话
ContactEmail string `json:"contact_email"` // 联系人邮箱
Remark string `json:"remark"` // 备注
CreatedBy string `json:"created_by"` // 用户创建人
UpdatedBy string `json:"updated_by"` // 用户更新人
IsAdmin int `json:"is_admin"` // 用户类型
}
type UpdateSystemUserReq struct {
Id int `json:"id" form:"id" vd:"$>0;msg:'请输入id'"` // id
BusinessName string `json:"business_name" vd:"len($)>1;msg:'请输入业务系统名称'"` // 业务系统名称
SystemAccount string `json:"system_account" vd:"len($)>1;msg:'请输入账号'"` // 系统账号
AccessAddress string `json:"access_address"` // 访问地址
DevelopId string `json:"develop_id"` // 开发厂商uuid
BusinessDesc string `json:"business_desc"` // 业务系统描述
State int `json:"state"` // 状态0禁用1启用
Logo string `json:"logo"` // 头像logo
ContactName string `json:"contact_name"` // 联系人姓名
ContactPhone string `json:"contact_phone"` // 联系人电话
ContactEmail string `json:"contact_email"` // 联系人邮箱
Remark string `json:"remark"` // 备注
UpdatedBy string `json:"updated_by"` // 用户更新人
}
type SystemUserListReq struct {
Pagination
OrganizationId int64 `json:"organization_id" form:"organization_id"` // 所属组织
}
type SystemUserDetailReq struct {
Id string `json:"id" form:"id" vd:"len($)>0;msg:'请输入id'"` // id
}
type SystemUserStateReq struct {
Id string `json:"id" form:"id" vd:"len($)>0;msg:'请输入id'"` // id
State string `json:"state" vd:"len($)>0;msg:'请填写状态'"` // Id
}
type SystemUserEditPasswordReq struct {
Id int `json:"id" form:"id" vd:"$>0;msg:'请输入id'"` // id
Password string `json:"password"` // 密码
}
type DeleteSystemUserReq struct {
Ids []int `json:"ids" form:"ids" vd:"len($)>0;msg:'请输入id'"` // ids
}
type ResetSystemUserPasswordReq struct {
Ids []int `json:"ids" form:"ids" vd:"len($)>0;msg:'请输入id'"` // ids
}
type ResetSecretReq struct {
Id int `json:"id" form:"id" vd:"$>0;msg:'请输入id'"` // ids
}
type CheckBusinessNameReq struct {
Id int `json:"id" form:"id" ` // id
OrganizationId string `json:"organization_id" vd:"len($)>1;msg:'请选择所属组织'"` // 所属组织
BusinessName string `json:"business_name" vd:"len($)>1;msg:'请输入业务系统名称'"` // 业务系统名称
}
type CheckAccountReq struct {
Id int `json:"id" form:"id" ` // id
SystemAccount string `json:"system_account" vd:"len($)>1;msg:'请输入账号'"` // 系统账号
}
package request
type UserAddReq struct {
UserType int `json:"user_type" form:"user_type" binding:"required,oneof=2 3 4"` //用户类型
UserId string `json:"user_id" form:"user_id" binding:"required"` //账号
UserName string `json:"user_name" form:"user_name" binding:"required"` //负责人
Email string `json:"email" form:"email" binding:"email"` //邮箱
Password string `json:"password" form:"password" binding:"required,gte=6"` //密码
PassWordRepeat string `json:"password_repeat" form:"password_repeat" binding:"required,gte=6,eqfield=password"` //重复密码
//普通用户、租户 独有字段
UnitName string `json:"unit_name" form:"unit_name" binding:"omitempty"` //单位名称
Phone string `json:"phone" form:"phone" binding:"omitempty"` //联系方式
Id string `json:"id" form:"id" binding:"omitempty"` //用户唯一标识
}
type UserListReq struct {
Keyword string `json:"keyword" form:"keyword" binding:"omitempty"` //搜索关键词
UserType int `json:"user_type" form:"user_type" binding:"omitempty,oneof=1 2 3 4"` //用户类型
UserId string `json:"user_id" form:"user_id" binding:"omitempty"` //账号
Id string `json:"id" form:"id" binding:"omitempty"` //用户唯一标识
OrderBy string `json:"order_by" form:"order_by" binding:"omitempty"` //排序
Pagination
}
type UserDelReq struct {
UserIds []string `json:"user_ids" form:"user_ids[]" binding:"required"` //用户账号集合
}
type UserUpdateReq struct {
OptType string `json:"opt_type" form:"opt_type" binding:"required,oneof=change_pass reset_pass change_info"`
UserId string `json:"user_id" form:"user_id" binding:"required"` //账号
//基础信息
UserName string `json:"user_name" form:"user_name" binding:"omitempty,required_if=opt_type change_info"` //负责人
Email string `json:"email" form:"email" binding:"omitempty,required_if=opt_type change_info,email"` //邮箱
//迁移人员 独有字段
UnitName string `json:"unit_name" form:"unit_name" binding:"omitempty,required_if=opt_type change_info"` //迁移单位名称
Phone string `json:"phone" form:"phone" binding:"omitempty,required_if=opt_type change_info"` //联系方式
//修改密码、重置密码
OriginalPassword string `json:"original_password" form:"original_password" binding:"required_if=opt_type change_pass,omitempty,gte=6"` //原始密码
Password string `json:"password" form:"password" binding:"required_if=opt_type change_pass,required_if=opt_type reset_pass,omitempty,gte=6"` //新密码
PassWordRepeat string `json:"password_repeat" form:"password_repeat" binding:"required_if=opt_type change_pass,required_if=opt_type reset_pass,omitempty,gte=6,eqfield=password"` //重复密码
}
package response
type Captcha struct {
Id string `json:"id"`
Captcha string `json:"captcha"`
}
package response
import (
"time"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
)
// 系统组织表
type SystemOrganizationTree struct {
Id int64 `json:"id" xorm:"pk autoincr"` //id
OrganizationId string `json:"organization_id"` //组织id
Name string `json:"name"` //组织名称or目录名称
POrganizationId string `json:"p_organization_id"` //父级组织id
Description string `json:"description"` //组织介绍
OrganizationCode string `json:"organization_code"` //组织机构代码
Attachment string `json:"attachment"` //组织附件
Sort int64 `json:"sort"` //排序
DataType int64 `json:"data_type"` //数据类型(0目录 1组织)
CreatedTime time.Time `json:"created_time" xorm:"created"` //创建时间
UpdatedTime time.Time `json:"updated_time" xorm:"updated"` //更新时间
CreatedBy string `json:"created_by"` //创建者
UpdatedBy string `json:"updated_by"` //更新者
Level int64 `json:"level"` //组织节点层级
Child []SystemOrganizationTree `xorm:"-"`
}
// 组织管理员列表
type OrgAdminUser struct {
Id int32 `json:"id" xorm:"pk autoincr" ` // id
SystemAccount string `json:"system_account" xorm:"system_account"` // 系统账号
ContactPhone string `json:"contact_phone" xorm:"contact_phone"` // 联系人电话
SystemRole []string `json:"system_role" xorm:"-"` // 系统角色
CreatedTime jsontime.Time `json:"created_time" xorm:"created" ` // 创建时间
State int `json:"state" xorm:"state"` // 状态0禁用1启用
SystemId string `json:"system_id" xorm:"system_id"` // 系统账号id
}
// 账号详情
type OrgUserDetail struct {
Id int32 `json:"id" xorm:"pk autoincr" ` // id
ContactPhone string `json:"contact_phone" xorm:"contact_phone"` // 联系人电话
SystemAccount string `json:"system_account" xorm:"system_account"` // 系统账号
SystemRole []string `json:"system_role" xorm:"-"` // 系统角色id
Organization string `json:"organization" xorm:"organization"` // 所属组织
OrganizationId string `json:"organization_id"` // 所属组织
CreatedBy string `json:"created_by"` // 创建者
CreatedByAccount string `json:"created_by_account"` // 创建账号
UpdatedTime jsontime.Time `json:"updated_time" xorm:"updated" ` // 更新时间
CreatedTime jsontime.Time `json:"created_time" xorm:"created" ` // 创建时间
ContactName string `json:"contact_name" xorm:"contact_name"` // 联系人姓名
ContactEmail string `json:"contact_email" xorm:"contact_email"` // 联系人邮箱
DocumentType int64 `json:"document_type"` // 证件类型
DocumentNumber string `json:"document_number"` // 证件号
Remark string `json:"remark" xorm:"remark"` // 备注
Logo string `json:"logo"` // 头像logo
State int `json:"state"` // 状态0禁用1启用
SystemId string `json:"-" xorm:"system_id"` // 系统账号id
IsAdmin int `json:"is_admin"` // 用户类型(1.业务系统账号 2.组织管理员账号 3.平台用户账号)
}
// 编辑组织账号
type UpdateOrgUser struct {
ContactPhone string `json:"contact_phone" xorm:"contact_phone"` // 联系人电话
SystemAccount string `json:"system_account" xorm:"system_account"` // 系统账号
ContactName string `json:"contact_name" xorm:"contact_name"` // 联系人姓名
ContactEmail string `json:"contact_email" xorm:"contact_email"` // 联系人邮箱
DocumentType int64 `json:"document_type"` // 证件类型
DocumentNumber string `json:"document_number"` // 证件号
Remark string `json:"remark" xorm:"remark"` // 备注
Logo string `json:"logo"` // 头像logo
State int `json:"state"` // 状态0禁用1启用
}
// 机构详情
type OrgDetail struct {
OrganizationType string `json:"organization_type"` //机构类型
OrganizationCode string `json:"organization_code"` //组织机构代码
Name string `json:"name"` //机构名称
CreatedTime jsontime.Time `json:"created_time" xorm:"created"` //创建时间
OrgAdminNumber int64 `json:"org_admin_number"` //组织管理员数
BusinessSystemNumber int64 `json:"business_system_number"` //业务系统数
Attachment string `json:"attachment"` //组织附件
Description string `json:"description"` //组织介绍
PlatformUsersNumber int64 `json:"platform_users_number"` //平台用户数
}
type BusinessSystem struct {
BusinessName string `json:"business_name" xorm:"business_name"` // 业务系统名称
SystemAccount string `json:"system_account" xorm:"system_account"` // 系统账号
State int `json:"state"` // 状态0禁用1启用
}
package response
import (
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
"time"
)
type SystemUserList struct {
Id int32 `json:"id" ` // id
OrganizationId string `json:"organization_id" xorm:"organization_id"` // 所属组织
OrganizationName string `json:"organization_name" xorm:"name"` // 所属组织
BusinessCode string `json:"business_code" xorm:"business_code"` // 业务系统编码
BusinessName string `json:"business_name" xorm:"business_name"` // 业务系统名称
SystemAccount string `json:"system_account" xorm:"system_account"` // 系统账号
State int `json:"state" xorm:"state"` // 状态0禁用1启用
CreatedTime time.Time `json:"created_time" xorm:"created" ` // 创建时间
SystemId string `json:"system_id" xorm:"system_id"` // 系统账号id
}
type SystemUserDetailRes struct {
BusinessCode string `json:"business_code"` // 业务系统编码
BusinessName string `json:"business_name"` // 业务系统名称
OrganizationId string `json:"organization_id"` // 所属组织
OrganizationName string `json:"organization_name"` // 所属组织名称
SystemAccount string `json:"system_account"` // 系统账号
AppId string `json:"app_id"` // appId
AppSecret string `json:"app_secret"` // appSecret
CreatedBy string `json:"created_by"` // 创建者
CreatedTime jsontime.Time `json:"created_time"` // 创建时间
State int `json:"state"` // 状态0禁用1启用
DevelopId string `json:"develop_id"` // 开发厂商uuid
DevelopName string `json:"develop_name"` // 开发厂商名称
AccessAddress string `json:"access_address"` // 访问地址
BusinessDesc string `json:"business_desc"` // 业务系统描述
Logo string `json:"logo"` // 头像logo
ContactName string `json:"contact_name"` // 联系人姓名
ContactPhone string `json:"contact_phone"` // 联系人电话
ContactEmail string `json:"contact_email"` // 联系人邮箱
Remark string `json:"remark"` // 备注
SystemId string `json:"system_id"` // 系统账号id
IsAdmin int `json:"is_admin"` // 用户类型
CreatedUserRole []string `json:"created_user_role"` // 系统角色
}
type SystemUserListRes struct {
Id int32 `json:"id" ` // id
OrganizationId string `json:"organization_id"` // 所属组织
OrganizationName string `json:"organization_name"` // 所属组织
BusinessCode string `json:"business_code"` // 业务系统编码
BusinessName string `json:"business_name"` // 业务系统名称
SystemAccount string `json:"system_account"` // 系统账号
State int `json:"state"` // 状态0禁用1启用
CreatedTime jsontime.Time `json:"created_time" ` // 创建时间
SystemId string `json:"system_id"` // 系统账号id
}
package response
import (
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/entity"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
)
type UserListItem struct {
entity.User
CreatedAt jsontime.Time `column:"created_at" json:"created_at"` //创建时间
UpdatedAt jsontime.Time `column:"updated_at" json:"updated_at"` //更新时间
}
type UserList struct {
TotalCount int `json:"total_count"`
List []UserListItem `json:"list"`
}
type UserMigListItem struct {
Id string `json:"id"` //用户唯一标识
UnitName string `json:"unit_name"` //迁移单位名称
Phone string `json:"phone"` //联系电话
UserName string `json:"username"` //用户名称
}
...@@ -82,3 +82,18 @@ func (r Redis) Del(key string) error { ...@@ -82,3 +82,18 @@ func (r Redis) Del(key string) error {
bmd := r.Conn.Del(strings.ToUpper(key)) bmd := r.Conn.Del(strings.ToUpper(key))
return bmd.Err() return bmd.Err()
} }
func (r Redis) Ttl(key string) (time.Duration, error) {
key = fmt.Sprintf("%s-%s", strings.ToUpper(r.Prefix), strings.ToUpper(key))
return r.Conn.TTL(strings.ToUpper(key)).Result()
}
func (r Redis) Incr(key string) (int64, error) {
key = fmt.Sprintf("%s-%s", strings.ToUpper(r.Prefix), strings.ToUpper(key))
return r.Conn.Incr(strings.ToUpper(key)).Result()
}
func (r Redis) Expire(key string, expiration time.Duration) (bool, error) {
key = fmt.Sprintf("%s-%s", strings.ToUpper(r.Prefix), strings.ToUpper(key))
return r.Conn.Expire(strings.ToUpper(key), expiration).Result()
}
...@@ -2,6 +2,7 @@ package conf ...@@ -2,6 +2,7 @@ package conf
import ( import (
"go.uber.org/zap" "go.uber.org/zap"
"time"
) )
var ( var (
...@@ -30,3 +31,13 @@ type Config struct { ...@@ -30,3 +31,13 @@ type Config struct {
MinioSecretKey string MinioSecretKey string
MinioBucket string MinioBucket string
} }
const (
LockDuration = 1 * time.Hour //锁定时间 默认 1小时
LockErrorNumber = 3 //错误次数 3次
WIDTH = 240
HEIGHT = 60
CookieName = "bgToken"
CookieNameLastLogin string = "lastLogin"
LocalDateTimeFormat string = "2006-01-02 15:04:05"
)
package tools
import (
"math/rand"
"strings"
)
var CHARS = []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}
/*RandAllString 生成随机字符串([a~zA~Z0~9])
lenNum 长度
*/
func RandAllString(lenNum int) string {
str := strings.Builder{}
length := len(CHARS)
for i := 0; i < lenNum; i++ {
l := CHARS[rand.Intn(length)]
str.WriteString(l)
}
return str.String()
}
/*RandNumString 生成随机数字字符串([0~9])
lenNum 长度
*/
func RandNumString(lenNum int) string {
str := strings.Builder{}
length := 10
for i := 0; i < lenNum; i++ {
str.WriteString(CHARS[52+rand.Intn(length)])
}
return str.String()
}
/*RandString 生成随机字符串(a~zA~Z])
lenNum 长度
*/
func RandString(lenNum int) string {
str := strings.Builder{}
length := 52
for i := 0; i < lenNum; i++ {
str.WriteString(CHARS[rand.Intn(length)])
}
return str.String()
}
package tools
import (
"github.com/mojocn/base64Captcha"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/client"
"log"
"time"
)
type ConfigJsonBody struct {
Id string `json:"id"`
CaptchaType string `json:"captcha_type"`
VerifyValue string `json:"verify_value"`
DriverAudio *base64Captcha.DriverAudio `json:"driver_audio"`
DriverString *base64Captcha.DriverString `json:"driver_string"`
DriverChinese *base64Captcha.DriverChinese `json:"driver_chinese"`
DriverMath *base64Captcha.DriverMath `json:"driver_math"`
DriverDigit *base64Captcha.DriverDigit `json:"driver_digit"`
}
type RedisStore struct {
}
var store = RedisStore{}
func GenerateCaptcha(param ConfigJsonBody) (id, b64s string, err error) {
var driver base64Captcha.Driver
switch param.CaptchaType {
case "audio":
driver = param.DriverAudio
case "string":
driver = param.DriverString.ConvertFonts()
case "math":
driver = param.DriverMath.ConvertFonts()
case "chinese":
driver = param.DriverChinese.ConvertFonts()
default:
driver = param.DriverDigit
}
c := base64Captcha.NewCaptcha(driver, store)
id, b64s, err = c.Generate()
//fmt.Println(id, b64s,err)
//fmt.Println("base64编码1", b64s)
//aaaa := b64s[strings.IndexByte(b64s, ',')+1:]
//fmt.Println("base64编码2", aaaa)
//ddd, err1 := base64.StdEncoding.DecodeString(aaaa) //成图片文件并把文件写入到buffer
//fmt.Println("二进制", ddd)
//fmt.Println("错误", err1)
//err2 := ioutil.WriteFile("./output.png", ddd, 0666) //buffer输出到jpg文件中(不做处理,直接写到文件)
//fmt.Println(err2)
return
}
func Verify(body ConfigJsonBody) bool {
return store.Verify(body.Id, body.VerifyValue, true)
}
func (body RedisStore) Set(id string, value string) error {
redis, err := client.GetRedisClient()
if err != nil {
log.Println(err)
}
return redis.Set(id, value, time.Hour*5)
}
func (body RedisStore) Get(id string, clear bool) string {
redis, err := client.GetRedisClient()
if err != nil {
log.Println(err)
}
value, _ := redis.Get(id)
return value
}
func (body RedisStore) Verify(id, answer string, clear bool) bool {
redis, err := client.GetRedisClient()
if err != nil {
log.Println(err)
}
value, _ := redis.Get(id)
right := false
if answer == value {
right = true
} else {
right = false
return right
}
if clear {
redis.Del(id)
}
return right
}
package controller
import (
vd "github.com/bytedance/go-tagexpr/validator"
"github.com/gin-gonic/gin"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/request"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/conf"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/service"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/util"
"go.uber.org/zap"
"strconv"
)
func UserLogin(c *gin.Context) {
userReq := request.UserReq{}
err := c.BindJSON(&userReq)
if err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil)
return
}
//参数检测
if err := vd.Validate(userReq); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), "")
return
}
// 验证 userName 是否含有危险字符
if util.IfDangerCharacter(userReq.SystemAccount) {
SendJsonResponse(c, resp.InvalidParam.WithMsg("账号存在危险字符"), "")
return
}
//TODO 解密password
pwd, err := util.DecryptPwd(userReq.Password)
if err != nil {
SendJsonResponse(c, resp.FAIL.WithError(err), "")
return
}
userReq.Password = pwd
loginInf := service.UserSvc{SystemAccount: userReq.SystemAccount, PassWord: userReq.Password}
msg, uuidStr, lastLogin, err := loginInf.Login()
if err != nil {
SendJsonResponse(c, err, "")
return
}
c.SetCookie(conf.CookieName, uuidStr, 1*60*60*24, "/", "", false, false)
c.SetCookie(conf.CookieNameLastLogin, lastLogin, 1*60*60*24, "/", "", false, false)
SendJsonResponse(c, resp.OK, msg)
}
func GetUserInfo(c *gin.Context) {
token, _ := c.Cookie(conf.CookieName)
conf.Logger.Info("当前token信息为", zap.String("bgToken", token))
header := c.GetHeader(conf.CookieName)
conf.Logger.Info("当前header信息为", zap.String("header", header))
if token == "" {
SendJsonResponse(c, resp.FAIL.WithMsg("登录超时"), "")
return
}
loginInf := service.UserSvc{}
result, err := loginInf.GetCurUser(token)
if err != nil {
SendJsonResponse(c, err, "")
return
}
SendJsonResponse(c, resp.OK, result)
}
func GetCaptcha(c *gin.Context) {
widthS := c.Query("width")
heightS := c.Query("height")
var width, height int
if widthS == "" {
width = conf.WIDTH
} else {
width, _ = strconv.Atoi(widthS)
}
if heightS == "" {
height = conf.HEIGHT
} else {
height, _ = strconv.Atoi(heightS)
}
loginInf := service.UserSvc{}
m, err := loginInf.GetCaptcha(width, height)
if err != nil {
SendJsonResponse(c, err, "")
return
}
SendJsonResponse(c, resp.OK, m)
}
func VerifyCaptcha(c *gin.Context) {
id := c.Query("id")
value := c.Query("value")
if id == "" || value == "" {
SendJsonResponse(c, resp.FAIL.WithMsg("id and value are required"), "")
return
}
loginInf := service.UserSvc{}
err := loginInf.VerifyCaptcha(id, value)
if err != nil {
SendJsonResponse(c, err, "")
return
}
SendJsonResponse(c, resp.OK, "验证码正确")
}
func UserLogout(c *gin.Context) {
cookie, _ := c.Cookie(conf.CookieName)
c.SetCookie(conf.CookieName, "0", -1, "/", "", false, true)
c.SetCookie(conf.CookieNameLastLogin, "0", -1, "/", "", false, true)
loginInf := service.UserSvc{}
msg, err := loginInf.UserLogout(cookie)
if err != nil {
SendJsonResponse(c, err, "")
return
}
SendJsonResponse(c, resp.OK, msg)
}
package router
import (
"fmt"
"github.com/gin-gonic/gin"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/conf"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/controller"
)
// InitSystemLoginRouter 初始化登录相关路由
func InitSystemLoginRouter(e *gin.Engine) {
base := e.Group(fmt.Sprintf("%s/user", conf.Options.Prefix))
{
base.POST("/login", controller.UserLogin) // 登录
base.POST("/logout", controller.UserLogout) // 登出
base.GET("/getUserInfo", controller.GetUserInfo) // 获取用户信息
base.GET("/getCaptcha", controller.GetCaptcha) // 获取验证码
base.GET("/verifyCaptcha", controller.VerifyCaptcha) // 校验验证码
}
}
...@@ -41,4 +41,6 @@ func Load(r *gin.Engine, middleware ...gin.HandlerFunc) { ...@@ -41,4 +41,6 @@ func Load(r *gin.Engine, middleware ...gin.HandlerFunc) {
// 初始化自动化运维路由 // 初始化自动化运维路由
InitAutomatedMaintenRouter(r) InitAutomatedMaintenRouter(r)
// 初始化登录路由
InitSystemLoginRouter(r)
} }
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
type Example struct { type Example struct {
} }
func (e Example) List() (result response.UserList, err error) { func (e Example) List() (result response.SystemUserListRes, err error) {
db, err := client.GetDbClient() db, err := client.GetDbClient()
if err != nil { if err != nil {
err = resp.FAIL.WithError(err) err = resp.FAIL.WithError(err)
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
) )
type HostManageSvc struct { type HostManageSvc struct {
User *entity.User User *entity.SystemUser
} }
// AddHostManage 新增主机 // AddHostManage 新增主机
......
package service
import (
"crypto/md5"
"encoding/hex"
"errors"
"fmt"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/entity"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/response"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/client"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/conf"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/tools"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp"
"image/color"
"strings"
"time"
"github.com/go-redis/redis"
"github.com/mojocn/base64Captcha"
uuid "github.com/satori/go.uuid"
"github.com/spf13/cast"
"go.uber.org/zap"
"k8s.io/apimachinery/pkg/util/json"
)
type UserSvc struct {
SystemAccount string
PassWord string
}
func (u *UserSvc) Login() (msg string, uuidStr string, last_login string, err error) {
db, err := client.GetDbClient()
if err != nil {
return "", "", "", resp.DbConnectError.WithError(err)
}
// 查询用户
var userInfo entity.SystemUserInfo
_, err = db.Table("system_user").
Select("system_user.*").
Where("system_account = ?", u.SystemAccount).Get(&userInfo)
if err != nil {
return
}
if userInfo.Id == 0 {
conf.Logger.Error("用户名或密码错误", zap.Error(err))
return "", "", "", resp.FAIL.WithMsg("用户名或密码错误")
}
if userInfo.State == 0 {
conf.Logger.Error("账号未启用", zap.Error(err))
return "", "", "", resp.FAIL.WithMsg("账号未启用")
}
redisCli, err := client.GetRedisClient()
if err != nil {
return "", "", "", resp.RedisConnectError.WithError(err)
}
lockKey := fmt.Sprintf("so-operation-user-lock-%s", userInfo.Id)
haslock, err := redisCli.Get(lockKey)
if err != nil && err != redis.Nil {
conf.Logger.Error("获取密码插入次数失败", zap.Error(err))
return "", "", "", resp.DbSelectError.WithError(err)
} else if haslock == "" {
if err := redisCli.Set(lockKey, 0, conf.LockDuration); err != nil {
conf.Logger.Error("密码插入次数插入redis失败", zap.Error(err))
return "", "", "", resp.DbInsertError.WithError(err)
}
} else if cast.ToInt(haslock) >= conf.LockErrorNumber {
if ttl, err := redisCli.Ttl(lockKey); err != nil {
msg = "错误次数达到上限,请稍后重试"
} else {
if ttl.Seconds() <= 0 {
if err := redisCli.Del(lockKey); err != nil {
msg = "删除错误次数错误,请稍后重试"
}
ttl = time.Second
}
ttl := int(ttl.Seconds())
if ttl >= 3600 {
msg = fmt.Sprintf("错误次数达到上限,请%d小时后重试", ttl/3600)
} else if ttl >= 60 && ttl < 3600 {
msg = fmt.Sprintf("错误次数达到上限,请%d分钟后重试", ttl/60)
} else {
msg = fmt.Sprintf("错误次数达到上限,请%d秒后重试", ttl)
}
}
err = errors.New(msg)
if err != nil {
conf.Logger.Error(msg, zap.Error(err))
return "", "", "", resp.RedisExecError.WithError(err)
}
}
h := md5.New()
_, err = h.Write([]byte(strings.ToUpper(fmt.Sprintf("%d-%s", userInfo.Id, u.PassWord))))
if err != nil {
conf.Logger.Error("加密错误", zap.Error(err))
return "", "", "", resp.FAIL.WithError(err)
}
uppperMd5Pass := strings.ToUpper(hex.EncodeToString(h.Sum(nil)))
if uppperMd5Pass != userInfo.Password {
incr, err := redisCli.Incr(lockKey)
if err != nil {
conf.Logger.Error("写入错误次数失败", zap.Error(err))
return "", "", "", resp.RedisExecError.WithError(err)
}
conf.Logger.Info("当前错误次数为", zap.Int64("incr", incr))
//再次错误执行续期
expire, err := redisCli.Expire(lockKey, conf.LockDuration)
if err != nil {
conf.Logger.Error("错误次数续期错误", zap.Error(err))
return "", "", "", resp.RedisExecError.WithError(err)
}
conf.Logger.Info("续期结果为", zap.Bool("expire", expire))
return "", "", "", resp.FAIL.WithMsg("用户名或密码错误")
}
//密码正确 删除 锁定文件
if err := redisCli.Del(lockKey); err != nil {
conf.Logger.Error("删除锁定文件错误", zap.Error(err))
return "", "", "", resp.RedisExecError.WithError(err)
}
uu := uuid.NewV4()
uuidStr = uu.String()
// 存入redis
b, err := json.Marshal(userInfo)
if err != nil {
return "", "", "", resp.FAIL.WithError(err)
}
err = redisCli.Set(uuidStr, string(b), time.Minute*60*24)
if err != nil {
conf.Logger.Error("登录失败", zap.Error(err))
return "", "", "", resp.FAIL.WithError(err)
}
msg = "登录成功"
conf.Logger.Info("登录成功", zap.String("msg", msg))
//登录时间计录在map
loginMap := make(map[string]string, 0)
cont, _ := redisCli.Get("LOGIN-TIME")
//if err != nil {
// conf.Logger.Error("获取登录时间失败", zap.Error(err))
// return "", "", "", res.DataFailError.ErrorDetail(err)
//}
if cont != "" {
err = json.Unmarshal([]byte(cont), &loginMap)
if err != nil {
return "", "", "", resp.FAIL.WithError(err)
}
}
now := time.Now().Format(conf.LocalDateTimeFormat)
if _, ok := loginMap[u.SystemAccount]; ok {
last_login = loginMap[u.SystemAccount]
} else {
last_login = now
}
loginMap[u.SystemAccount] = now
a, err := json.Marshal(loginMap)
if err != nil {
return "", "", "", resp.FAIL.WithError(err)
}
err = redisCli.Set("LOGIN-TIME", string(a), -1)
if err != nil {
conf.Logger.Error("登录失败", zap.Error(err))
return "", "", "", resp.FAIL.WithError(err)
}
return
}
func (u *UserSvc) GetCurUser(token string) (m entity.SystemUserInfo, err error) {
rcon, err := client.GetRedisClient()
if err != nil {
return m, resp.RedisConnectError.WithError(err)
}
result, err := rcon.Get(token)
if err != nil {
if err.Error() == "redis: nil" {
err = errors.New("登录超时")
return m, resp.FAIL.WithError(err)
} else {
conf.Logger.Error("获取token失败", zap.Error(err))
return m, resp.FAIL.WithError(err)
}
}
if result == "" {
err = errors.New("登录超时")
return m, resp.FAIL.WithError(err)
}
err = json.Unmarshal([]byte(result), &m)
if err != nil {
return m, resp.FAIL.WithError(err)
}
m.Password = ""
return
}
func (u *UserSvc) UserLogout(cookie string) (msg string, err error) {
// 清理redis
redisCli, err := client.GetRedisClient()
if err != nil {
return "", resp.FAIL.WithError(err)
}
err = redisCli.Del(cookie)
if err != nil {
msg = "登出失败"
return msg, resp.FAIL.WithError(err)
}
return "登出成功", nil
}
func (u *UserSvc) GetCaptcha(width, height int) (captcha response.Captcha, err error) {
param := tools.ConfigJsonBody{
CaptchaType: "string",
DriverString: &base64Captcha.DriverString{
Height: height,
Width: width,
NoiseCount: 0,
ShowLineOptions: 2,
Length: 4,
Source: "124567890",
BgColor: &color.RGBA{255, 255, 255, 1},
//Fonts: []string{"3Dumb.ttf", "ApothecaryFont.ttf", "Comismsh.ttf", "DENNEthree-dee.ttf", "DeborahFancyDress.ttf",
// "Flim-Flam.ttf", "RitaSmith.ttf", "actionj.ttf", "chromohv.ttf"},
Fonts: []string{"DENNEthree-dee.ttf"},
},
}
captcha.Id, captcha.Captcha, err = tools.GenerateCaptcha(param)
return
}
func (u *UserSvc) VerifyCaptcha(id, value string) (err error) {
param := tools.ConfigJsonBody{}
param.Id = id
param.VerifyValue = strings.ToLower(value)
right := tools.Verify(param)
if !right {
err = errors.New("验证码不正确")
conf.Logger.Error("验证码不正确", zap.Error(err))
}
return
}
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
) )
type TaskManageSvc struct { type TaskManageSvc struct {
User *entity.User User *entity.SystemUser
} }
// AddTaskManage 新增任务 // AddTaskManage 新增任务
......
/*
* @Descripttion:
* @Author: Zhang YaSong
* @version:
* @Date: 2022-10-21 18:21:35
* @LastEditors: Zhang YaSong
* @LastEditTime: 2022-10-21 18:36:04
*/
package util
import (
"net/http"
"regexp"
"github.com/Luzifer/go-openssl/v4"
"github.com/google/uuid"
)
var OpenSslManager *openssl.OpenSSL = openssl.New()
func IfDangerCharacter(toMatch string) bool {
// 正则过滤sql注入的方法
// 参数 : 要匹配的语句
//过滤 ‘
//ORACLE 注解 -- /**/
//关键字过滤 update ,delete
str := `(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|(\b(select|update|and|or|delete|insert|trancate|char|chr|into|substr|ascii|declare|exec|count|master|into|drop|execute)\b)`
re, err := regexp.Compile(str)
if err != nil {
return false
}
return re.MatchString(toMatch)
}
func DecryptPwd(pwd string) (str string, err error) {
passphrase := "swuE9cmCZQwrkYRV"
dec, err := OpenSslManager.DecryptBytes(passphrase, []byte(pwd), openssl.BytesToKeyMD5)
return string(dec), err
}
func EncryptPwd(password string) (pwd string, err error) {
passphrase := "swuE9cmCZQwrkYRV"
ecs, err := OpenSslManager.EncryptBytes(passphrase, []byte(password), openssl.BytesToKeyMD5)
return string(ecs), err
}
// GetCookieStr , 获取cookie字符串
func GetCookieStr(req *http.Request) (str string, err error) {
cookies := req.Cookies()
for _, v := range cookies {
str += v.Name + "=" + v.Value + ";"
}
return str, nil
}
func GetUUID() string {
// Creating UUID Version 4
return uuid.New().String()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment