feat:完善信息

This commit is contained in:
henry
2021-10-09 11:55:54 +08:00
parent 2191f0ea3f
commit af44287b4a
19 changed files with 368 additions and 12 deletions

View File

@ -15,7 +15,7 @@ type InstanceLoginCallback func(params *InstanceLoginParams) *InstanceLoginRetur
type (
InstanceLoginParams struct {
UID uint64
UID, TenantID uint64
Name, Mobile, Avatar string
Identity, SelectIdentity int
Status model.AccountStatusKind
@ -34,6 +34,7 @@ func (c *Instance) Login() InstanceLoginCallback {
session := service.NewSessionEnterprise()
session.Token = token
session.UID = params.UID
session.TenantID = params.TenantID
session.Avatar = params.Avatar
session.Name = params.Name
session.Mobile = params.Mobile

View File

@ -79,8 +79,9 @@ func loginForSmsCaptcha(params *LoginParams) (*InstanceLoginParams, error) {
}
RETURNS:
return &InstanceLoginParams{
UID: mUserInstance.UUID, Name: mUserInstance.Name, Mobile: mUserInstance.Mobile, Avatar: mUserTenant.Avatar,
Identity: mUserInstance.Identity, SelectIdentity: mUserTenant.Identity, Status: mUserInstance.Status,
UID: mUserInstance.UUID, TenantID: mUserTenant.TenantID, Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
Avatar: mUserTenant.Avatar, Identity: mUserInstance.Identity, SelectIdentity: mUserTenant.Identity,
Status: mUserInstance.Status,
}, nil
}
@ -109,8 +110,9 @@ func loginForPassword(params *LoginParams) (*InstanceLoginParams, error) {
return nil, err
}
return &InstanceLoginParams{
UID: mUserInstance.UUID, Name: mUserInstance.Name, Mobile: mUserInstance.Mobile, Avatar: mUserTenant.Avatar,
Identity: mUserInstance.Identity, SelectIdentity: mUserTenant.Identity, Status: mUserInstance.Status,
UID: mUserInstance.UUID, TenantID: mUserTenant.TenantID, Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
Avatar: mUserTenant.Avatar, Identity: mUserInstance.Identity, SelectIdentity: mUserTenant.Identity,
Status: mUserInstance.Status,
}, nil
}

View File

@ -0,0 +1,25 @@
package technology
import "SciencesServer/app/service"
// Instance 技术管理
type Instance struct{ *service.SessionEnterprise }
type InstanceHandle func(enterprise *service.SessionEnterprise) *Instance
func (c *Instance) List(status, page, pageSize int) {
}
func (c *Instance) Form() {
}
func (c *Instance) Delete() {
}
func NewInstance() InstanceHandle {
return func(enterprise *service.SessionEnterprise) *Instance {
return &Instance{enterprise}
}
}

View File

@ -0,0 +1,111 @@
package technology
import (
"SciencesServer/app/api/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/enterprise/model"
"SciencesServer/app/service"
"SciencesServer/utils"
"errors"
"time"
)
// Paper 论文管理
type Paper struct{ *service.SessionEnterprise }
type PaperHandle func(enterprise *service.SessionEnterprise) *Paper
type (
PaperInfo struct {
ID string `json:"id"`
*model2.TechnologyPaper
Tags []string `json:"tags"`
}
PaperParams struct {
ID uint64
Title, Ext, Author, PublishAt, Keyword, Remark string
Tags []string
}
)
// List 列表信息
func (c *Paper) List(title string, page, pageSize int) (*controller.ReturnPages, error) {
mTechnologyPaper := model.NewTechnologyPaper()
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
Where: model2.NewWhere("tenant_id", c.TenantID),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}}
if title != "" {
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereLike("title", title)})
}
out := make([]*model2.TechnologyPaper, 0)
var count int64
if err := model2.Pages(mTechnologyPaper.TechnologyPaper, &out, page, pageSize, &count, where...); err != nil {
return nil, err
}
list := make([]*PaperInfo, 0)
for _, v := range out {
list = append(list, &PaperInfo{ID: v.GetEncodeID(), TechnologyPaper: v, Tags: v.GetTagAttribute()})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Form 参数信息
func (c *Paper) Form(params *PaperParams) error {
mTechnologyPaper := model.NewTechnologyPaper()
if params.ID > 0 {
mTechnologyPaper.ID = params.ID
if isExist, err := model2.First(mTechnologyPaper.TechnologyPaper); err != nil {
return err
} else if !isExist {
return errors.New("当前论文信息不存在")
} else if mTechnologyPaper.UID != c.UID {
return errors.New("无权限操作")
}
}
mTechnologyPaper.Title = params.Title
mTechnologyPaper.Ext = params.Ext
mTechnologyPaper.Author = params.Author
mTechnologyPaper.PublishAt = utils.DateTimeToTime(params.PublishAt)
mTechnologyPaper.Keyword = params.Keyword
mTechnologyPaper.SetTagAttribute(params.Tags)
mTechnologyPaper.Remark = params.Remark
if params.ID <= 0 {
return model2.Create(mTechnologyPaper.TechnologyPaper)
}
mTechnologyPaper.UpdatedAt = time.Now()
return model2.Updates(mTechnologyPaper.TechnologyPaper, mTechnologyPaper.TechnologyPaper)
}
// Delete 删除操作
func (c *Paper) Delete(id uint64) error {
mTechnologyPaper := model.NewTechnologyPaper()
mTechnologyPaper.ID = id
var count int64
err := model2.Count(mTechnologyPaper.TechnologyPaper, &count, model2.NewWhere("id", id), model2.NewWhere("uid", c.UID))
if err != nil {
return err
} else if count <= 0 {
return errors.New("当前论文信息不存在")
}
if err = model2.Delete(mTechnologyPaper.TechnologyPaper); err != nil {
return err
}
return nil
}
func NewPaper() PaperHandle {
return func(enterprise *service.SessionEnterprise) *Paper {
return &Paper{enterprise}
}
}

View File

@ -0,0 +1,4 @@
package technology
// Patent 专利管理
type Patent struct{}

View File

@ -47,6 +47,7 @@ type (
var tenantHandlePerfect = map[int]func(params *TenantPerfectParams) (string, error){
config.TenantUserIdentityForCompany: perfectForCompany,
config.TenantUserIdentityForExpert: perfectForExpert,
}
func perfectForCompany(params *TenantPerfectParams) (string, error) {
@ -56,8 +57,8 @@ func perfectForCompany(params *TenantPerfectParams) (string, error) {
return utils.AnyToJSON(params.TenantParamsForCompany), nil
}
func perfectForExpert() error {
return nil
func perfectForExpert(params *TenantPerfectParams) (string, error) {
return "", nil
}
func perfectForResearch() error {