feat:优化项目信息
This commit is contained in:
@ -79,7 +79,7 @@ func loginForSmsCaptcha(params *LoginParams, local string) (*InstanceLoginParams
|
||||
}
|
||||
RETURNS:
|
||||
return &InstanceLoginParams{
|
||||
UID: mUserInstance.UUID, TenantID: mUserManage.TenantID, ManageUID: mUserManage.UUID,
|
||||
UID: mUserInstance.UUID, ManageUID: mUserManage.UUID,
|
||||
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Identity: mUserInstance.Identity, SelectIdentity: mUserManage.Identity,
|
||||
Status: mUserInstance.Status,
|
||||
@ -111,7 +111,7 @@ func loginForPassword(params *LoginParams, local string) (*InstanceLoginParams,
|
||||
return nil, err
|
||||
}
|
||||
return &InstanceLoginParams{
|
||||
UID: mUserInstance.UUID, TenantID: mUserManage.TenantID, ManageUID: mUserManage.UUID,
|
||||
UID: mUserInstance.UUID, ManageUID: mUserManage.UUID,
|
||||
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Identity: mUserInstance.Identity, SelectIdentity: mUserManage.Identity,
|
||||
Status: mUserInstance.Status,
|
||||
|
@ -36,7 +36,6 @@ func (c *Paper) List(title string, page, pageSize int) (*controller.ReturnPages,
|
||||
mTechnologyPaper := model.NewTechnologyPaper()
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("tenant_id", c.TenantID),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("local", c.local),
|
||||
|
60
app/api/enterprise/controller/user/consume.go
Normal file
60
app/api/enterprise/controller/user/consume.go
Normal file
@ -0,0 +1,60 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
)
|
||||
|
||||
// Consume 消耗日志
|
||||
type Consume struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type ConsumeHandle func(session *session.Enterprise, local string) *Consume
|
||||
|
||||
type (
|
||||
ConsumeInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.UserConsume
|
||||
}
|
||||
)
|
||||
|
||||
// List 列表信息
|
||||
func (c *Consume) List(source, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mUserConsume := model.NewUserConsume()
|
||||
|
||||
where := []*model2.ModelWhereOrder{
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("uid", c.UID),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
},
|
||||
}
|
||||
out := make([]*model2.UserConsume, 0)
|
||||
|
||||
var count int64
|
||||
|
||||
if err := model2.Pages(mUserConsume.UserConsume, &out, page, pageSize, &count, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ConsumeInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &ConsumeInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
UserConsume: v,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func NewConsume() ConsumeHandle {
|
||||
return func(session *session.Enterprise, local string) *Consume {
|
||||
return &Consume{
|
||||
Enterprise: session,
|
||||
local: local,
|
||||
}
|
||||
}
|
||||
}
|
@ -99,7 +99,7 @@ func (c *Instance) SwitchIdentity(identity int) error {
|
||||
if c.SelectIdentity == identity {
|
||||
return nil
|
||||
}
|
||||
c.TenantID, c.ManageUID = 0, 0
|
||||
c.ManageUID = 0
|
||||
// 已存在相应的身份,更新最后
|
||||
if c.Identity&identity > 0 {
|
||||
mUserManage := model.NewUserManage()
|
||||
@ -125,12 +125,12 @@ func (c *Instance) SwitchIdentity(identity int) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
c.TenantID = mUserManage.TenantID
|
||||
c.ManageUID = mUserManage.UUID
|
||||
c.SelectIdentity = identity
|
||||
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccount, c.UIDToString(), c.Enterprise)
|
||||
return nil
|
||||
}
|
||||
c.SelectIdentity = identity
|
||||
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccount, c.UIDToString(), c.Enterprise)
|
||||
return nil
|
||||
return errors.New("操作错误,无效的身份信息")
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
|
@ -92,7 +92,6 @@ func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mManageExpert.TenantID = other.TenantID
|
||||
mManageExpert.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
@ -156,7 +155,6 @@ func (c *Settled) Laboratory(params *SettledParams, other *config.IdentityForLab
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mManageLaboratory.TenantID = other.TenantID
|
||||
mManageLaboratory.Name = params.Name
|
||||
mManageLaboratory.Code = params.Code
|
||||
mManageLaboratory.Area = model2.Area{
|
||||
|
11
app/api/enterprise/model/user_consume.go
Normal file
11
app/api/enterprise/model/user_consume.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserConsume struct {
|
||||
*model.UserConsume
|
||||
}
|
||||
|
||||
func NewUserConsume() *UserConsume {
|
||||
return &UserConsume{model.NewUserConsume()}
|
||||
}
|
@ -156,7 +156,6 @@ func (c *Examine) Launch(id uint64, identity, status int) error {
|
||||
return err
|
||||
}
|
||||
if !isExist {
|
||||
mUserManage.TenantID = data.TenantID
|
||||
mUserManage.ManageID = data.IModel.GetID()
|
||||
mUserManage.UID = data.UID
|
||||
mUserManage.Identity = identity
|
||||
|
@ -3,7 +3,6 @@ package config
|
||||
// 身份信息
|
||||
|
||||
const (
|
||||
TenantUserIdentityForPerson int = 0 // 0
|
||||
TenantUserIdentityForCompany int = 1 << 0 // 1
|
||||
TenantUserIdentityForExpert int = 1 << 1 // 2
|
||||
TenantUserIdentityForResearch int = 1 << 2 // 4
|
||||
@ -13,7 +12,6 @@ const (
|
||||
|
||||
// TenantUserIdentityData 用户身份信息
|
||||
var TenantUserIdentityData = map[int]string{
|
||||
TenantUserIdentityForPerson: "游客",
|
||||
TenantUserIdentityForCompany: "企业", TenantUserIdentityForExpert: "专家",
|
||||
TenantUserIdentityForResearch: "研究机构", TenantUserIdentityForLaboratory: "实验室",
|
||||
TenantUserIdentityForAgent: "科技经纪人",
|
||||
|
@ -1,6 +1,7 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
config2 "SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/config"
|
||||
"SciencesServer/serve/orm"
|
||||
@ -52,6 +53,24 @@ func initModel() {
|
||||
&synchronized{iModel: model.NewSysPatent(), iValues: func() interface{} {
|
||||
return nil
|
||||
}},
|
||||
&synchronized{iModel: model.NewSysIdentity(), iValues: func() interface{} {
|
||||
out := make([]*model.SysIdentity, 0)
|
||||
|
||||
for k, v := range config2.TenantUserIdentityData {
|
||||
registerCount := 1
|
||||
|
||||
if k == config2.TenantUserIdentityForCompany {
|
||||
registerCount = -1
|
||||
}
|
||||
out = append(out, &model.SysIdentity{
|
||||
Identity: k,
|
||||
Name: v,
|
||||
RegisterCount: registerCount,
|
||||
IsExamine: 1,
|
||||
})
|
||||
}
|
||||
return out
|
||||
}},
|
||||
// 日志管理
|
||||
&synchronized{iModel: model.NewSysUserRole()},
|
||||
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},
|
||||
|
@ -23,14 +23,24 @@ func (m *ManageCompany) TableName() string {
|
||||
return "manage_company"
|
||||
}
|
||||
|
||||
func (m *ManageCompany) GetKeywordAttribute() []string {
|
||||
keywords := make([]string, 0)
|
||||
_ = utils.FromJSON(m.Keyword, &keywords)
|
||||
return keywords
|
||||
func (m *ManageCompany) GetIndustryAttribute() []string {
|
||||
out := make([]string, 0)
|
||||
_ = utils.FromJSON(m.Industry, &out)
|
||||
return out
|
||||
}
|
||||
|
||||
func (m *ManageCompany) SetKeywordAttribute(keywords []string) {
|
||||
m.Keyword = utils.AnyToJSON(keywords)
|
||||
func (m *ManageCompany) SetIndustryAttribute(value []string) {
|
||||
m.Industry = utils.AnyToJSON(value)
|
||||
}
|
||||
|
||||
func (m *ManageCompany) GetKeywordAttribute() []string {
|
||||
out := make([]string, 0)
|
||||
_ = utils.FromJSON(m.Keyword, &out)
|
||||
return out
|
||||
}
|
||||
|
||||
func (m *ManageCompany) SetKeywordAttribute(value []string) {
|
||||
m.Keyword = utils.AnyToJSON(value)
|
||||
}
|
||||
|
||||
func NewManageCompany() *ManageCompany {
|
||||
|
20
app/common/model/sys_identity.go
Normal file
20
app/common/model/sys_identity.go
Normal file
@ -0,0 +1,20 @@
|
||||
package model
|
||||
|
||||
// SysIdentity 身份管理数据模型
|
||||
type SysIdentity struct {
|
||||
Model
|
||||
Identity int `gorm:"column:identity;uniqueIndex:idx_sys_identity;type:tinyint(3);default:0;comment:身份信息" json:"identity"`
|
||||
Name string `gorm:"column:name;type:varchar(20);default:null;comment:身份名称" json:"name"`
|
||||
RegisterCount int `gorm:"column:register_count;type:tinyint(3);default:0;comment:每个平台下可以最大注册人数,-1不作限制" json:"register_count"`
|
||||
IsExamine int `gorm:"column:is_examine;type:tinyint(1);default:0;comment:是否需要后台审核" json:"is_examine"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *SysIdentity) TableName() string {
|
||||
return "sys_identity"
|
||||
}
|
||||
|
||||
func NewSysIdentity() *SysIdentity {
|
||||
return &SysIdentity{}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package model
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type SysTenant struct {
|
||||
Model
|
||||
Key string `gorm:"column:key;type:varchar(30);default:null;comment:key" json:"key"`
|
||||
@ -10,7 +12,7 @@ type SysTenant struct {
|
||||
Images
|
||||
Area
|
||||
Position string `gorm:"column:position;type:varchar(255);default:null;comment:坐标" json:"-"`
|
||||
Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:所属领域" json:"industry"`
|
||||
Industry string `gorm:"column:industry;type:varchar(255);default:null;comment:所属领域;行业信息" json:"-"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||
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"`
|
||||
@ -22,6 +24,17 @@ func (m *SysTenant) TableName() string {
|
||||
return "sys_tenant"
|
||||
}
|
||||
|
||||
func (m *SysTenant) GetIndustryAttribute() []string {
|
||||
out := make([]string, 0)
|
||||
_ = json.Unmarshal([]byte(m.Industry), &out)
|
||||
return out
|
||||
}
|
||||
|
||||
func (m *SysTenant) SetIndustryAttribute(value []string) {
|
||||
_bytes, _ := json.Marshal(value)
|
||||
m.Industry = string(_bytes)
|
||||
}
|
||||
|
||||
func NewSysTenant() *SysTenant {
|
||||
return &SysTenant{}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ type TechnologyDemand struct {
|
||||
Kind string `gorm:"column:kind;type:varchar(50);default:null;comment:需求类别" json:"-"`
|
||||
Name string `gorm:"column:name;type:varchar(30);default:null;comment:联系人" json:"name"`
|
||||
Mobile string `gorm:"column:mobile;type:varchar(15);default:null;comment:联系方式" json:"mobile"`
|
||||
Industry string `gorm:"column:industry;type:varchar(255);comment:行业信息" json:"industry"`
|
||||
Industry string `gorm:"column:industry;type:varchar(255);comment:所属领域;行业信息" json:"industry"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:需求描述" json:"introduce"`
|
||||
Budget float64 `gorm:"column:budget;type:decimal(10,2);default:0;comment:投产预算" json:"budget"`
|
||||
BudgetMode TechnologyDemandBudgetMode `gorm:"column:budget_mode;type:tinyint(1);default:1;comment:预算模式(1:具体金额,2:面议)" json:"budget_mode"`
|
||||
|
@ -14,7 +14,7 @@ type TechnologyProduct struct {
|
||||
Image
|
||||
Video string `gorm:"column:video;type:varchar(255);default:null;comment:视频地址" json:"video"`
|
||||
Material string `gorm:"column:material;type:varchar(255);default:null;comment:证明材料" json:"material"`
|
||||
Industry string `gorm:"column:industry;type:varchar(255);default:null;comment:所属领域" json:"industry"`
|
||||
Industry string `gorm:"column:industry;type:varchar(255);default:null;comment:所属领域;行业信息" json:"industry"`
|
||||
Customer string `gorm:"column:customer;type:varchar(255);default:null;comment:应用客户" json:"-"`
|
||||
Maturity config.TechnologyMaturity `gorm:"column:maturity;type:tinyint(1);default:0;comment:技术成熟度" json:"maturity"`
|
||||
LeadStandard TechnologyProductLeadStandard `gorm:"column:lead_standard;type:tinyint(1);default:0;comment:领先标准" json:"lead_standard"`
|
||||
|
18
app/common/model/user_company.go
Normal file
18
app/common/model/user_company.go
Normal file
@ -0,0 +1,18 @@
|
||||
package model
|
||||
|
||||
// UserCompany 用户公司数据模型
|
||||
type UserCompany struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
CompanyID uint64 `gorm:"column:company_id;type:int(11);default:0;comment:公司模型ID" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *UserCompany) TableName() string {
|
||||
return "user_company"
|
||||
}
|
||||
|
||||
func NewUserCompany() *UserCompany {
|
||||
return &UserCompany{}
|
||||
}
|
@ -1,14 +1,24 @@
|
||||
package model
|
||||
|
||||
// UserConsume 用户资产消耗
|
||||
// UserConsume 用户资产消耗数据模型
|
||||
type UserConsume struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Source int `json:"source"`
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Source UserConsumeSource `gorm:"column:source;type:tinyiny(1);default:null;comment:消耗来源" json:"source"`
|
||||
Consume float64 `gorm:"column:consume;type:decimal(10,2);default:null;comment:消耗数量" json:"consume"`
|
||||
Surplus float64 `gorm:"column:surplus;type:decimal(10,2);default:null;comment:剩余数量" json:"surplus"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注信息" json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
type UserConsumeSource int
|
||||
|
||||
const (
|
||||
// UserConsumeSourceForRecharge 充值
|
||||
UserConsumeSourceForRecharge UserConsumeSource = iota + 1
|
||||
)
|
||||
|
||||
func (m *UserConsume) TableName() string {
|
||||
return "user_consume"
|
||||
}
|
||||
|
@ -10,10 +10,9 @@ import (
|
||||
// UserManage 用户管理信息
|
||||
type UserManage struct {
|
||||
Model
|
||||
ModelTenant
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_user_manage_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
ManageID uint64 `gorm:"column:manage_id;type:int(11);default:0;comment:信息管理ID,根据所在身份,对应不同数据表" json:"-"`
|
||||
UID uint64 `gorm:"column:uid;index:idx_user_manage_uid;type:int;default:0;comment:用户表UUID" json:"-"`
|
||||
ManageID uint64 `gorm:"column:manage_id;type:int(11);default:0;comment:信息管理ID,根据所在身份,对应不同数据表" json:"-"`
|
||||
Name string `gorm:"column:name;type:varchar(20);default:null;comment:真实姓名" json:"name"`
|
||||
Email string `gorm:"column:email;type:varchar(50);default:null;comment:邮箱" json:"email"`
|
||||
Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"`
|
||||
|
19
app/event/consume.go
Normal file
19
app/event/consume.go
Normal file
@ -0,0 +1,19 @@
|
||||
package event
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type Consume struct{}
|
||||
|
||||
func (this *Consume) Handle(arg ...interface{}) {
|
||||
mUserConsume := model.NewUserConsume()
|
||||
mUserConsume.UID = arg[0].(uint64)
|
||||
mUserConsume.Source = arg[1].(model.UserConsumeSource)
|
||||
mUserConsume.Consume = arg[2].(float64)
|
||||
mUserConsume.Surplus = arg[3].(float64)
|
||||
mUserConsume.Remark = arg[4].(string)
|
||||
_ = model.Create(mUserConsume)
|
||||
}
|
||||
|
||||
func NewConsume() *Consume {
|
||||
return &Consume{}
|
||||
}
|
@ -19,6 +19,8 @@ func Init() {
|
||||
service.Subscribe(config.EventForAccountLoginProduce, event.NewAccountUserLoginProduce())
|
||||
// 日志录入监听
|
||||
service.Subscribe(config.EventForSysLogProduce, event.NewSysLogProduce())
|
||||
// 消耗录入监听
|
||||
service.Subscribe(config.EventForConsumeProduce, event.NewConsume())
|
||||
// 开启权限
|
||||
service.NewAuth().Register()(config.SettingInfo.Engine.DBMode, orm.GetDB(), model.NewSysAuthRule().TableName())
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
type Enterprise struct {
|
||||
Token string `json:"token"` // token
|
||||
UID uint64 `json:"uid"` // 唯一标识ID
|
||||
TenantID uint64 `json:"tenant_id"` // 租户ID
|
||||
ManageUID uint64 `json:"manage_uid"` // 管理平台用户唯一ID
|
||||
Name string `json:"name"` // 名称
|
||||
Mobile string `json:"mobile"` // 手机号码
|
||||
|
@ -33,6 +33,7 @@ const (
|
||||
|
||||
EventForAccountLoginProduce string = "account_login_produce"
|
||||
EventForSysLogProduce string = "sys_log_produce"
|
||||
EventForConsumeProduce string = "consume_produce"
|
||||
)
|
||||
|
||||
const (
|
||||
|
Reference in New Issue
Block a user