feat:完善信息

This commit is contained in:
henry
2021-10-12 16:53:49 +08:00
parent cf3bc8ffb4
commit eccd71809d
14 changed files with 88 additions and 69 deletions

View File

@ -73,7 +73,7 @@ func (c *Account) Login(account, password, captchaKey, captchaValue, equipment,
} }
if level <= 0 { if level <= 0 {
session.TenantID = mSysTenant.ID session.TenantID = mSysTenant.ID
session.TenantKey = mSysTenant.Key //session.TenantKey = mSysTenant.Key
} }
// 判断是否含有含有上级 // 判断是否含有含有上级
if mSysTenant.ParentID <= 0 { if mSysTenant.ParentID <= 0 {

View File

@ -47,7 +47,7 @@ func (c *Log) Login(name string, page, pageSize int) (*ReturnPages, error) {
SysUserLoginLogInfo: v, IPAddress: string(ipAddress), SysUserLoginLogInfo: v, IPAddress: string(ipAddress),
}) })
} }
return &ReturnPages{Data: list, Page: page, TotalCount: count}, nil return &ReturnPages{Data: list, Count: count}, nil
} }
func NewLog() LogHandle { func NewLog() LogHandle {

View File

@ -63,7 +63,7 @@ func (c *Instance) List(name string, status, page, pageSize int) (*controller.Re
for _, v := range out { for _, v := range out {
list = append(list, &InstanceInfo{SysRole: v, StatusTitle: v.StatusTitle()}) list = append(list, &InstanceInfo{SysRole: v, StatusTitle: v.StatusTitle()})
} }
return &controller.ReturnPages{Data: list, Page: page, TotalCount: count}, nil return &controller.ReturnPages{Data: list, Count: count}, nil
} }

View File

@ -97,7 +97,7 @@ func member(id uint64) func(args ...interface{}) (interface{}, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &controller.ReturnPages{Data: out, Page: page, TotalCount: count}, nil return &controller.ReturnPages{Data: out, Count: count}, nil
} }
} }
@ -165,7 +165,7 @@ func (c *Instance) List(name string, status, page, pageSize int) (*controller.Re
list = append(list, &InstanceInfo{SysTenantInfo: v}) list = append(list, &InstanceInfo{SysTenantInfo: v})
} }
return &controller.ReturnPages{Data: list, Page: page, TotalCount: count}, nil return &controller.ReturnPages{Data: list, Count: count}, nil
} }
// Add 数据处理 // Add 数据处理

View File

@ -51,6 +51,10 @@ func (m *Images) AnalysisSlice(domain string) []string {
return images return images
} }
type Local struct {
Local uint64 `gorm:"column:local;type:int(11);default:0;comment:数据位置来源" json:"-"`
}
// AccountStatus 账号状态 // AccountStatus 账号状态
type AccountStatus struct { type AccountStatus struct {
Status AccountStatusKind `gorm:"column:status;type:tinyint(1);default:1;comment:状态(1启用2禁用)" json:"-"` Status AccountStatusKind `gorm:"column:status;type:tinyint(1);default:1;comment:状态(1启用2禁用)" json:"-"`

View File

@ -5,6 +5,7 @@ import "SciencesServer/utils"
// ManageCompany 公司企业管理 // ManageCompany 公司企业管理
type ManageCompany struct { type ManageCompany struct {
Model Model
Local
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
Name string `gorm:"column:name;type:varchar(30);default:null;comment:名称" json:"name"` Name string `gorm:"column:name;type:varchar(30);default:null;comment:名称" json:"name"`
Code string `gorm:"column:code;type:varchar(30);default:null;comment:信用代码" json:"code"` Code string `gorm:"column:code;type:varchar(30);default:null;comment:信用代码" json:"code"`

View File

@ -8,6 +8,7 @@ import (
// ManageExpert 专家入驻信息管理 // ManageExpert 专家入驻信息管理
type ManageExpert struct { type ManageExpert struct {
Model Model
Local
ModelTenant ModelTenant
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
Area Area

View File

@ -7,6 +7,7 @@ import (
// ManageLaboratory 实验室信息管理 // ManageLaboratory 实验室信息管理
type ManageLaboratory struct { type ManageLaboratory struct {
Model Model
Local
ModelTenant ModelTenant
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
Name string `gorm:"column:name;type:varchar(30);default:null;comment:名称" json:"name"` Name string `gorm:"column:name;type:varchar(30);default:null;comment:名称" json:"name"`

View File

@ -2,6 +2,7 @@ package model
type SysTenant struct { type SysTenant struct {
Model Model
Key string `gorm:"column:key;type:varchar(30);default:null;comment:key" json:"key"`
ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"-"` ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"-"`
Image Image
Name string `gorm:"column:name;type:varchar(30);default:null;comment:名称" json:"name"` Name string `gorm:"column:name;type:varchar(30);default:null;comment:名称" json:"name"`
@ -12,6 +13,7 @@ type SysTenant struct {
Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:所属领域" json:"industry"` Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:所属领域" json:"industry"`
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"` Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
Config string `gorm:"column:config;type:varchar(255);default:null;comment:配置信息" json:"-"` Config string `gorm:"column:config;type:varchar(255);default:null;comment:配置信息" json:"-"`
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注信息" json:"remark"`
ModelDeleted ModelDeleted
ModelAt ModelAt
} }

View File

@ -10,6 +10,7 @@ import (
type SysUser struct { type SysUser struct {
Model Model
Local
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_sys_user_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"` UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_sys_user_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
Account string `gorm:"column:account;type:varchar(50);default:null;comment:账户名" json:"account"` Account string `gorm:"column:account;type:varchar(50);default:null;comment:账户名" json:"account"`
Avatar string `gorm:"column:avatar;type:varchar(255);default:null;comment:头像" json:"avatar"` Avatar string `gorm:"column:avatar;type:varchar(255);default:null;comment:头像" json:"avatar"`

View File

@ -61,7 +61,7 @@ func (a *Account) Register(c *gin.Context) {
} }
func (a *Account) BindMobile() { func (a *Account) BindMobile() {
account.NewOther()().BindMobile() //account.NewOther()().BindMobile()
} }
func (a *Account) Logout(c *gin.Context) { func (a *Account) Logout(c *gin.Context) {

View File

@ -1,11 +1,29 @@
package account package account
import (
"SciencesServer/app/handle"
"SciencesServer/utils"
"errors"
)
type Other struct{} type Other struct{}
type OtherHandle func() *Other type OtherHandle func() *Other
func (c *Other) BindMobile() { // BindMobile 绑定手机号码
func (c *Other) BindMobile(token, mobile, captcha string) (interface{}, error) {
if !utils.ValidateMobile(mobile) {
return nil, errors.New("手机号码格式异常")
}
pass, err := handle.NewCaptcha().Validate(&handle.CaptchaSms{
Mobile: mobile, Captcha: captcha,
})
if err != nil {
return nil, err
} else if !pass {
return nil, errors.New("验证码错误或已过期")
}
return nil, nil
} }
func NewOther() OtherHandle { func NewOther() OtherHandle {

View File

@ -33,10 +33,12 @@ func (c *RegisterParams) checkUserExist(mUserInstance *model2.UserInstance) (boo
} }
return count > 0, nil return count > 0, nil
} }
func (c *RegisterParams) checkCaptcha() (bool, error) { func (c *RegisterParams) checkCaptcha() (bool, error) {
return handle.NewCaptcha().Validate(&handle.CaptchaSms{Captcha: c.Captcha, Mobile: c.Mobile}) return handle.NewCaptcha().Validate(&handle.CaptchaSms{Captcha: c.Captcha, Mobile: c.Mobile})
} }
// Launch 发起注册
func (c *Register) Launch(params *RegisterParams) (*InstanceLoginReturn, error) { func (c *Register) Launch(params *RegisterParams) (*InstanceLoginReturn, error) {
if params.checkPassword() { if params.checkPassword() {
return nil, errors.New("两次密码不一致") return nil, errors.New("两次密码不一致")

View File

@ -1,16 +1,5 @@
package cron package cron
import (
"SciencesServer/app/common/model"
"SciencesServer/app/service"
"SciencesServer/config"
"SciencesServer/serve/logger"
"SciencesServer/serve/orm"
"time"
"gorm.io/gorm"
)
type Tenant struct{} type Tenant struct{}
type TenantHandle func() (string, func()) type TenantHandle func() (string, func())
@ -19,56 +8,56 @@ type TenantHandle func() (string, func())
func (this *Tenant) ContractDeadline() TenantHandle { func (this *Tenant) ContractDeadline() TenantHandle {
return func() (string, func()) { return func() (string, func()) {
return "0 0 0 * * ?", func() { return "0 0 0 * * ?", func() {
now := time.Now() //now := time.Now()
//
mSysTenant := model.NewSysTenant() //mSysTenant := model.NewSysTenant()
//
out := make([]*model.SysTenant, 0) //out := make([]*model.SysTenant, 0)
//
err := model.Find(mSysTenant, &out, &model.ModelWhereOrder{Where: model.NewWhereIn("status", []model.SysTenantStatus{ //err := model.Find(mSysTenant, &out, &model.ModelWhereOrder{Where: model.NewWhereIn("status", []model.SysTenantStatus{
model.SysTenantStatusForNormal, model.SysTenantStatusForWellExpire, // model.SysTenantStatusForNormal, model.SysTenantStatusForWellExpire,
})}, &model.ModelWhereOrder{Where: model.NewWhereCondition("deadline", ">=", now.AddDate(0, 0, -7))}) //})}, &model.ModelWhereOrder{Where: model.NewWhereCondition("deadline", ">=", now.AddDate(0, 0, -7))})
//
if err != nil { //if err != nil {
logger.ErrorF("Cron Tenant ContractDeadline Error%v", err) // logger.ErrorF("Cron Tenant ContractDeadline Error%v", err)
return // return
} //}
well := make([]uint64, 0) //well := make([]uint64, 0)
expired := make([]uint64, 0) //expired := make([]uint64, 0)
expiredKey := make([]string, 0) //expiredKey := make([]string, 0)
//
for _, v := range out { //for _, v := range out {
// 超过协议时间 // // 超过协议时间
if v.Deadline.After(now) { // if v.Deadline.After(now) {
expired = append(expired, v.ID) // expired = append(expired, v.ID)
expiredKey = append(expiredKey, v.Key) // expiredKey = append(expiredKey, v.Key)
continue // continue
} // }
if v.Status == model.SysTenantStatusForNormal { // if v.Status == model.SysTenantStatusForNormal {
well = append(well, v.ID) // well = append(well, v.ID)
} // }
} //}
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error { //if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
if len(well) > 0 { // if len(well) > 0 {
if err = model.UpdatesWhere(mSysTenant, map[string]interface{}{ // if err = model.UpdatesWhere(mSysTenant, map[string]interface{}{
"status": model.SysTenantStatusForWellExpire, "updated_at": now, // "status": model.SysTenantStatusForWellExpire, "updated_at": now,
}, []*model.ModelWhere{model.NewWhereIn("id", well)}, tx); err != nil { // }, []*model.ModelWhere{model.NewWhereIn("id", well)}, tx); err != nil {
return err // return err
} // }
} // }
if len(expired) > 0 { // if len(expired) > 0 {
if err = model.UpdatesWhere(mSysTenant, map[string]interface{}{ // if err = model.UpdatesWhere(mSysTenant, map[string]interface{}{
"status": model.SysTenantStatusForExpired, "updated_at": now, // "status": model.SysTenantStatusForExpired, "updated_at": now,
}, []*model.ModelWhere{model.NewWhereIn("id", expired)}, tx); err != nil { // }, []*model.ModelWhere{model.NewWhereIn("id", expired)}, tx); err != nil {
return err // return err
} // }
service.Publish(config.EventForRedisListDestroy, config.RedisKeyForTenant, expiredKey) // service.Publish(config.EventForRedisListDestroy, config.RedisKeyForTenant, expiredKey)
} // }
return nil // return nil
}); err != nil { //}); err != nil {
logger.ErrorF("Cron Tenant ContractDeadline Transaction Error%v", err) // logger.ErrorF("Cron Tenant ContractDeadline Transaction Error%v", err)
return // return
} //}
return return
} }
} }