feat:完善入驻信息管理
This commit is contained in:
@ -38,7 +38,7 @@ func (c *Apply) List(title string, page, pageSize int) (*controller.ReturnPages,
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
},
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("m_uid", c.UID),
|
||||
Where: model2.NewWhere("identity_uid", c.IdentityUID),
|
||||
},
|
||||
}
|
||||
if title != "" {
|
||||
@ -63,7 +63,7 @@ func (c *Apply) List(title string, page, pageSize int) (*controller.ReturnPages,
|
||||
func (c *Apply) Launch(params *ApplyLaunchParams) error {
|
||||
mActivityApply := model.NewActivityApply()
|
||||
mActivityApply.Local.Local = c.local
|
||||
mActivityApply.MUid = c.ManageUID
|
||||
mActivityApply.IdentityUID = c.IdentityUID
|
||||
mActivityApply.Mode = model2.ActivityInstanceMode(params.Mode)
|
||||
mActivityApply.Title = params.Title
|
||||
mActivityApply.Content = params.Content
|
||||
@ -79,7 +79,7 @@ func (c *Apply) Revoke(id uint64) error {
|
||||
mActivityApply := model.NewActivityApply()
|
||||
mActivityApply.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mActivityApply.ActivityApply, []string{"id", "status"})
|
||||
isExist, err := model2.FirstField(mActivityApply.ActivityApply, []string{"id", "identity_uid", "status"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -87,6 +87,8 @@ func (c *Apply) Revoke(id uint64) error {
|
||||
return errors.New("操作错误,活动信息不存在或已被删除")
|
||||
} else if mActivityApply.Status != model2.ActivityApplyStatusForExamining {
|
||||
return errors.New("操作错误,当前活动状态易发生变化,不可撤销")
|
||||
} else if mActivityApply.IdentityUID != c.IdentityUID {
|
||||
return errors.New("无权限操作")
|
||||
}
|
||||
return model2.Updates(mActivityApply.ActivityApply, map[string]interface{}{
|
||||
"status": model2.ActivityApplyStatusForRevoke, "updated_at": time.Now(),
|
||||
@ -97,6 +99,16 @@ func (c *Apply) Revoke(id uint64) error {
|
||||
func (c *Apply) Delete(id uint64) error {
|
||||
mActivityApply := model.NewActivityApply()
|
||||
mActivityApply.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mActivityApply.ActivityApply, []string{"id", "identity_uid"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,活动信息不存在或已被删除")
|
||||
} else if mActivityApply.IdentityUID != c.IdentityUID {
|
||||
return errors.New("无权限操作")
|
||||
}
|
||||
return model2.Delete(mActivityApply.ActivityApply)
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,23 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
config2 "SciencesServer/config"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Config struct{}
|
||||
|
||||
type (
|
||||
// IndustryInfo 所属领域信息
|
||||
IndustryInfo struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
)
|
||||
|
||||
// Basic 基础配置信息
|
||||
func (c *Config) Basic() {
|
||||
|
||||
@ -28,8 +39,27 @@ func (c *Config) Transaction() map[int]string {
|
||||
}
|
||||
|
||||
// Industry 行业信息
|
||||
func (c *Config) Industry() map[string]*config.MemoryForIndustry {
|
||||
return config.MemoryForIndustryInfo
|
||||
func (c *Config) Industry(parentID uint64) []*IndustryInfo {
|
||||
mSysIndustry := model.NewSysIndustry()
|
||||
out := make([]*model2.SysIndustry, 0)
|
||||
|
||||
err := model2.ScanFields(mSysIndustry.SysIndustry, &out, []string{"id", "name"}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("parent_id", parentID),
|
||||
})
|
||||
|
||||
list := make([]*IndustryInfo, 0)
|
||||
|
||||
if err != nil {
|
||||
return list
|
||||
}
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &IndustryInfo{
|
||||
ID: fmt.Sprintf("%d", v.ID),
|
||||
Name: v.Name,
|
||||
})
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
// Research 研究领域信息
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
config2 "SciencesServer/config"
|
||||
"SciencesServer/serve/orm"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
@ -19,6 +20,38 @@ type Company struct {
|
||||
|
||||
type CompanyHandle func(session *session.Enterprise, local string) *Company
|
||||
|
||||
type CompanyInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.ManageCompany
|
||||
Kinds []int `json:"kinds"`
|
||||
Industry []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
}
|
||||
|
||||
// Get 获取信息
|
||||
func (c *Company) Get(code string) (*CompanyInfo, error) {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
|
||||
isExist, err := model2.FirstWhere(mManageCompany.ManageCompany, model2.NewWhere("code", code))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
mManageCompany.Image.Image = mManageCompany.Image.Analysis(config2.SettingInfo.Domain)
|
||||
mManageCompany.License = (&model2.Image{Image: mManageCompany.License}).Analysis(config2.SettingInfo.Domain)
|
||||
|
||||
return &CompanyInfo{
|
||||
ID: mManageCompany.GetEncodeID(),
|
||||
ManageCompany: mManageCompany.ManageCompany,
|
||||
Kinds: mManageCompany.GetKindAttribute(),
|
||||
Industry: mManageCompany.GetIndustryAttribute(),
|
||||
Keywords: mManageCompany.GetKeywordAttribute(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Launch 发起入驻
|
||||
func (c *Company) Launch(params *BasicParams, inviterID uint64, other *config.IdentityForCompany) error {
|
||||
if c.Identity&config.TenantUserIdentityForCompany > 0 {
|
||||
@ -51,13 +84,16 @@ func (c *Company) Launch(params *BasicParams, inviterID uint64, other *config.Id
|
||||
}
|
||||
mManageCompany.Local.Local = c.local
|
||||
mManageCompany.InviterID = inviterID
|
||||
mManageCompany.SetKindAttribute(other.Kinds)
|
||||
mManageCompany.Name = params.Name
|
||||
mManageCompany.Code = params.Code
|
||||
mManageCompany.Image = model2.Image{Image: params.Image}
|
||||
mManageCompany.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
mManageCompany.Product = other.Product
|
||||
mManageCompany.Url = other.Url
|
||||
mManageCompany.License = other.License
|
||||
mManageCompany.SetIndustryAttribute(params.Industrys)
|
||||
mManageCompany.SetKeywordAttribute(params.Keywords)
|
||||
mManageCompany.Introduce = params.Introduce
|
||||
|
@ -16,49 +16,54 @@ type Instance struct {
|
||||
type InstanceHandle func(session *session.Enterprise, local string) *Instance
|
||||
|
||||
type InstanceInfo struct {
|
||||
Identity int `json:"identity"` // 所有身份
|
||||
ExamineIdentity map[int]model2.ExamineStatusKind `json:"examine_identity"` // 审核中信息
|
||||
SelectIdentity int `json:"select_identity"` // 当前选择的身份
|
||||
Identity int `json:"identity"` // 所有身份
|
||||
ExamineIdentity map[int]*InstanceExamineInfo `json:"examine_identity"` // 审核中信息
|
||||
SelectIdentity int `json:"select_identity"` // 当前选择的身份
|
||||
}
|
||||
|
||||
func (c *Instance) company() (bool, model2.ExamineStatusKind, error) {
|
||||
type InstanceExamineInfo struct {
|
||||
Status model2.ExamineStatusKind `json:"status"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
func (c *Instance) company() (bool, *model2.Examine, error) {
|
||||
mUserCompany := model.NewUserCompany()
|
||||
out, err := mUserCompany.Company(c.UID)
|
||||
return out.ID > 0, out.ExamineStatus, err
|
||||
return out.ID > 0, out.Examine, err
|
||||
}
|
||||
|
||||
func (c *Instance) expert() (bool, model2.ExamineStatusKind, error) {
|
||||
func (c *Instance) expert() (bool, *model2.Examine, error) {
|
||||
mUserExpert := model.NewUserExpert()
|
||||
out, err := mUserExpert.Expert(c.UID)
|
||||
return out.ID > 0, out.ExamineStatus, err
|
||||
return out.ID > 0, out.Examine, err
|
||||
}
|
||||
|
||||
func (c *Instance) research() (bool, model2.ExamineStatusKind, error) {
|
||||
func (c *Instance) research() (bool, *model2.Examine, error) {
|
||||
mUserResearch := model.NewUserResearch()
|
||||
out, err := mUserResearch.Research(c.UID)
|
||||
return out.ID > 0, out.ExamineStatus, err
|
||||
return out.ID > 0, out.Examine, err
|
||||
}
|
||||
|
||||
func (c *Instance) laboratory() (bool, model2.ExamineStatusKind, error) {
|
||||
func (c *Instance) laboratory() (bool, *model2.Examine, error) {
|
||||
mUserLaboratory := model.NewUserLaboratory()
|
||||
out, err := mUserLaboratory.Laboratory(c.UID)
|
||||
return out.ID > 0, out.ExamineStatus, err
|
||||
return out.ID > 0, out.Examine, err
|
||||
}
|
||||
|
||||
func (c *Instance) agent() (bool, model2.ExamineStatusKind, error) {
|
||||
func (c *Instance) agent() (bool, *model2.Examine, error) {
|
||||
mUserAgent := model.NewUserAgent()
|
||||
out, err := mUserAgent.Agent(c.UID)
|
||||
return out.ID > 0, out.ExamineStatus, err
|
||||
return out.ID > 0, out.Examine, err
|
||||
}
|
||||
|
||||
func (c *Instance) Index() (*InstanceInfo, error) {
|
||||
out := &InstanceInfo{
|
||||
Identity: c.Identity,
|
||||
ExamineIdentity: make(map[int]model2.ExamineStatusKind, 0),
|
||||
ExamineIdentity: make(map[int]*InstanceExamineInfo, 0),
|
||||
SelectIdentity: c.SelectIdentity,
|
||||
}
|
||||
isExist := false
|
||||
var kind model2.ExamineStatusKind
|
||||
examine := new(model2.Examine)
|
||||
var err error
|
||||
|
||||
// 查询其他信息
|
||||
@ -67,15 +72,15 @@ func (c *Instance) Index() (*InstanceInfo, error) {
|
||||
continue
|
||||
}
|
||||
if k == config.TenantUserIdentityForCompany {
|
||||
isExist, kind, err = c.company()
|
||||
isExist, examine, err = c.company()
|
||||
} else if k == config.TenantUserIdentityForExpert {
|
||||
isExist, kind, err = c.expert()
|
||||
isExist, examine, err = c.expert()
|
||||
} else if k == config.TenantUserIdentityForResearch {
|
||||
isExist, kind, err = c.research()
|
||||
isExist, examine, err = c.research()
|
||||
} else if k == config.TenantUserIdentityForLaboratory {
|
||||
isExist, kind, err = c.laboratory()
|
||||
isExist, examine, err = c.laboratory()
|
||||
} else if k == config.TenantUserIdentityForAgent {
|
||||
isExist, kind, err = c.agent()
|
||||
isExist, examine, err = c.agent()
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -83,7 +88,10 @@ func (c *Instance) Index() (*InstanceInfo, error) {
|
||||
if !isExist {
|
||||
continue
|
||||
}
|
||||
out.ExamineIdentity[k] = kind
|
||||
out.ExamineIdentity[k] = &InstanceExamineInfo{
|
||||
Status: examine.ExamineStatus,
|
||||
Remark: examine.ExamineRemark,
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ func (c *Demand) List(status, page, pageSize int) (*controller.ReturnPages, erro
|
||||
mTechnologyDemand := model.NewTechnologyDemand()
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("uid", c.ManageUID),
|
||||
Where: model2.NewWhere("uid", c.UID),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("status", status),
|
||||
|
@ -97,7 +97,7 @@ func (c *Paper) Delete(id uint64) error {
|
||||
|
||||
var count int64
|
||||
|
||||
err := model2.Count(mTechnologyPaper.TechnologyPaper, &count, model2.NewWhere("id", id), model2.NewWhere("uid", c.ManageUID))
|
||||
err := model2.Count(mTechnologyPaper.TechnologyPaper, &count, model2.NewWhere("id", id), model2.NewWhere("uid", c.UID))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -23,6 +23,7 @@ type (
|
||||
ID string `json:"id"`
|
||||
*model2.TechnologyProduct
|
||||
}
|
||||
// ProductDetailInfo 产品详细信息
|
||||
ProductDetailInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.TechnologyProduct
|
||||
@ -99,6 +100,17 @@ func (c *Product) Detail(id uint64) (*ProductDetailInfo, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Match 匹配结果
|
||||
func (c *Product) Match(id uint64) {
|
||||
|
||||
}
|
||||
|
||||
func (c *Product) Visit(id uint64, page, pageSize int) {
|
||||
mTechnologyProductVisit := model.NewTechnologyProductVisit()
|
||||
var count int64
|
||||
mTechnologyProductVisit.Visit(page, pageSize, &count)
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (c *Product) Form(params *ProductParams) error {
|
||||
mTechnologyProduct := model.NewTechnologyProduct()
|
||||
|
@ -37,7 +37,7 @@ func (c *Project) List(title string, page, pageSize int) (*controller.ReturnPage
|
||||
mTechnologyProject := model.NewTechnologyProject()
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("uid", c.ManageUID),
|
||||
Where: model2.NewWhere("uid", c.UID),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc)}}
|
||||
|
||||
if title != "" {
|
||||
|
@ -52,12 +52,12 @@ func (c *Identity) Switch(identity int) error {
|
||||
if c.SelectIdentity == identity {
|
||||
return nil
|
||||
}
|
||||
c.ManageUID = 0
|
||||
c.IdentityUID = 0
|
||||
// 已存在相应的身份,更新最后
|
||||
if c.Identity&identity > 0 {
|
||||
mUserIdentity := model.NewUserIdentity()
|
||||
// 查询用户身份
|
||||
isExist, err := model2.FirstField(mUserIdentity.UserIdentity, []string{"id", "tenant_id", "name", "uuid"},
|
||||
isExist, err := model2.FirstField(mUserIdentity.UserIdentity, []string{"id", "name", "uuid"},
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("identity", identity))
|
||||
|
||||
if err != nil {
|
||||
@ -68,7 +68,7 @@ func (c *Identity) Switch(identity int) error {
|
||||
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.UpdatesWhere(mUserIdentity.UserIdentity, map[string]interface{}{
|
||||
"is_selected": model2.UserIdentitySelectedForNo, "updated_at": now,
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.ManageUID)}, tx); err != nil {
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uuid", c.IdentityUID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model2.Updates(mUserIdentity.UserIdentity, map[string]interface{}{
|
||||
@ -78,7 +78,7 @@ func (c *Identity) Switch(identity int) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
c.ManageUID = mUserIdentity.UUID
|
||||
c.IdentityUID = mUserIdentity.UUID
|
||||
c.SelectIdentity = identity
|
||||
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccount, c.UIDToString(), c.Enterprise)
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user