feat:完善信息
This commit is contained in:
@ -22,6 +22,10 @@ func (a *Config) Industry(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func (a *Config) Research(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func (a *Config) Area(c *gin.Context) {
|
||||
form := &struct {
|
||||
Key string `json:"key" form:"key"`
|
||||
|
9
app/api/enterprise/api/menu.go
Normal file
9
app/api/enterprise/api/menu.go
Normal file
@ -0,0 +1,9 @@
|
||||
package api
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
type Menu struct{}
|
||||
|
||||
func (*Menu) Menu(c *gin.Context) {
|
||||
|
||||
}
|
@ -19,7 +19,7 @@ type (
|
||||
Code string `json:"code" form:"code"`
|
||||
config.Area
|
||||
Introduce string `json:"introduce" form:"introduce"`
|
||||
Industry uint64 `json:"industry" form:"industry"`
|
||||
Industry string `json:"industry" form:"industry"` // 行业领域
|
||||
Keywords []string `json:"keywords" form:"keywords"`
|
||||
}
|
||||
// userBankForm 银行平台信息参数
|
||||
|
@ -76,7 +76,7 @@ func (c *Register) Launch(params *RegisterParams) (*InstanceLoginReturn, error)
|
||||
mUserManage.UID = mUserInstance.UUID
|
||||
mUserManage.Name = params.Name
|
||||
mUserManage.Identity = params.Identity
|
||||
mUserManage.Selected = model2.UserManageSelectedForYes
|
||||
mUserManage.IsSelected = model2.UserManageSelectedForYes
|
||||
return model2.Create(mUserManage.UserManage, tx)
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
|
@ -28,8 +28,8 @@ func (c *Config) Transaction() map[int]string {
|
||||
}
|
||||
|
||||
// Industry 行业信息
|
||||
func (c *Config) Industry() {
|
||||
|
||||
func (c *Config) Industry() map[string]*config.MemoryForIndustry {
|
||||
return config.MemoryForIndustryInfo
|
||||
}
|
||||
|
||||
// Research 研究领域信息
|
||||
|
@ -3,8 +3,10 @@ package identity
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/api/manage/controller"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Instance struct {
|
||||
@ -19,6 +21,7 @@ type (
|
||||
InstanceForExpert struct {
|
||||
*model.UserManageForExpert
|
||||
ID string `json:"id"`
|
||||
Industry string `json:"industry"`
|
||||
}
|
||||
)
|
||||
|
||||
@ -46,8 +49,15 @@ func (c *Instance) Expert(name, mobile string, page, pageSize int) (*controller.
|
||||
|
||||
for _, v := range out {
|
||||
mUserManage.ID = v.ID
|
||||
mUserManage.IdentityInfo = v.IdentityInfo
|
||||
obj := mUserManage.GetIdentityInfoAttribute().(*model2.UserIdentityForExpert)
|
||||
industry := make([]string, 0)
|
||||
|
||||
for _, v := range strings.Split(obj.Industry, ";") {
|
||||
industry = append(industry, config.GetIndustryInfo(v, "-"))
|
||||
}
|
||||
list = append(list, &InstanceForExpert{
|
||||
UserManageForExpert: v, ID: mUserManage.GetEncodeID(),
|
||||
UserManageForExpert: v, ID: mUserManage.GetEncodeID(), Industry: strings.Join(industry, ";"),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
|
19
app/api/enterprise/controller/menu/instance.go
Normal file
19
app/api/enterprise/controller/menu/instance.go
Normal file
@ -0,0 +1,19 @@
|
||||
package menu
|
||||
|
||||
import "SciencesServer/app/service"
|
||||
|
||||
type Instance struct {
|
||||
*service.SessionEnterprise
|
||||
}
|
||||
|
||||
type InstanceHandle func(enterprise *service.SessionEnterprise) *Instance
|
||||
|
||||
func (c *Instance) List() {
|
||||
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(enterprise *service.SessionEnterprise) *Instance {
|
||||
return &Instance{enterprise}
|
||||
}
|
||||
}
|
@ -81,12 +81,12 @@ func (c *Instance) SwitchIdentity(identity int) error {
|
||||
|
||||
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.UpdatesWhere(mUserManage.UserManage, map[string]interface{}{
|
||||
"selected": model2.UserManageSelectedForNo, "updated_at": now,
|
||||
"is_selected": model2.UserManageSelectedForNo, "updated_at": now,
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.ManageUID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
return model2.Updates(mUserManage.UserManage, map[string]interface{}{
|
||||
"selected": model2.UserManageSelectedForYes, "updated_at": now,
|
||||
"is_selected": model2.UserManageSelectedForYes, "updated_at": now,
|
||||
}, tx)
|
||||
}); err != nil {
|
||||
return err
|
||||
|
@ -21,7 +21,7 @@ type SettledParams struct {
|
||||
Code string // 唯一编码
|
||||
config.Area
|
||||
Introduce string
|
||||
Industry uint64 `json:"industry"`
|
||||
Industry string `json:"industry"`
|
||||
Keywords []string `json:"keywords"`
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ func (c *SettledParams) pass(uid, mUID uint64, mStatus model2.ExamineStatusKind)
|
||||
func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompany) error {
|
||||
mManageCompany := model3.NewManageCompany()
|
||||
|
||||
err := params.effect(c.ManageUID, mManageCompany.ManageCompany)
|
||||
err := params.effect(c.UID, mManageCompany.ManageCompany)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -73,10 +73,10 @@ func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompan
|
||||
mManageCompany.Introduce = params.Introduce
|
||||
|
||||
if mManageCompany.ID <= 0 {
|
||||
mManageCompany.UID = c.ManageUID
|
||||
mManageCompany.UID = c.UID
|
||||
return model2.Create(mManageCompany.ManageCompany)
|
||||
}
|
||||
if !params.pass(c.ManageUID, mManageCompany.UID, mManageCompany.Status) {
|
||||
if !params.pass(c.UID, mManageCompany.UID, mManageCompany.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageCompany.Status = model2.ExamineStatusForOngoing
|
||||
@ -87,7 +87,7 @@ func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompan
|
||||
func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert) error {
|
||||
mManageExpert := model3.NewManageExpert()
|
||||
|
||||
err := params.effect(c.ManageUID, mManageExpert.ManageExpert)
|
||||
err := params.effect(c.UID, mManageExpert.ManageExpert)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -108,10 +108,10 @@ func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert)
|
||||
mManageExpert.Research = utils.AnyToJSON(other.Research)
|
||||
|
||||
if mManageExpert.ID <= 0 {
|
||||
mManageExpert.UID = c.ManageUID
|
||||
mManageExpert.UID = c.UID
|
||||
return model2.Create(mManageExpert.ManageExpert)
|
||||
}
|
||||
if !params.pass(c.ManageUID, mManageExpert.UID, mManageExpert.Status) {
|
||||
if !params.pass(c.UID, mManageExpert.UID, mManageExpert.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageExpert.Status = model2.ExamineStatusForOngoing
|
||||
@ -122,7 +122,7 @@ func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert)
|
||||
func (c *Settled) Research(params *SettledParams, other *config.IdentityForResearch) error {
|
||||
mManageResearch := model3.NewManageResearch()
|
||||
|
||||
err := params.effect(c.ManageUID, mManageResearch.ManageResearch)
|
||||
err := params.effect(c.UID, mManageResearch.ManageResearch)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -137,10 +137,10 @@ func (c *Settled) Research(params *SettledParams, other *config.IdentityForResea
|
||||
mManageResearch.Research = other.Research
|
||||
|
||||
if mManageResearch.ID <= 0 {
|
||||
mManageResearch.UID = c.ManageUID
|
||||
mManageResearch.UID = c.UID
|
||||
return model2.Create(mManageResearch.ManageResearch)
|
||||
}
|
||||
if !params.pass(c.ManageUID, mManageResearch.UID, mManageResearch.Status) {
|
||||
if !params.pass(c.UID, mManageResearch.UID, mManageResearch.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageResearch.Status = model2.ExamineStatusForOngoing
|
||||
@ -151,7 +151,7 @@ func (c *Settled) Research(params *SettledParams, other *config.IdentityForResea
|
||||
func (c *Settled) Laboratory(params *SettledParams, other *config.IdentityForLaboratory) error {
|
||||
mManageLaboratory := model3.NewManageLaboratory()
|
||||
|
||||
err := params.effect(c.ManageUID, mManageLaboratory.ManageLaboratory)
|
||||
err := params.effect(c.UID, mManageLaboratory.ManageLaboratory)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -169,10 +169,10 @@ func (c *Settled) Laboratory(params *SettledParams, other *config.IdentityForLab
|
||||
mManageLaboratory.Research = utils.AnyToJSON(other.Research)
|
||||
|
||||
if mManageLaboratory.ID <= 0 {
|
||||
mManageLaboratory.UID = c.ManageUID
|
||||
mManageLaboratory.UID = c.UID
|
||||
return model2.Create(mManageLaboratory.ManageLaboratory)
|
||||
}
|
||||
if !params.pass(c.ManageUID, mManageLaboratory.UID, mManageLaboratory.Status) {
|
||||
if !params.pass(c.UID, mManageLaboratory.UID, mManageLaboratory.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageLaboratory.Status = model2.ExamineStatusForOngoing
|
||||
|
15
app/api/enterprise/model/sys_menu.go
Normal file
15
app/api/enterprise/model/sys_menu.go
Normal file
@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type SysMenu struct {
|
||||
*model.SysMenu
|
||||
}
|
||||
|
||||
func (m *SysMenu) Menus() {
|
||||
|
||||
}
|
||||
|
||||
func NewSysMenu() *SysMenu {
|
||||
return &SysMenu{model.NewSysMenu()}
|
||||
}
|
@ -18,13 +18,14 @@ type (
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Mobile string `json:"mobile"`
|
||||
IdentityInfo string `json:"-"`
|
||||
}
|
||||
)
|
||||
|
||||
// Expert 专家数据
|
||||
func (m *UserManage) Expert(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*UserManageForExpert, error) {
|
||||
query := orm.GetDB().Table(m.TableName()+" AS m").
|
||||
Select(strings.Join([]string{"m.id", "m.name", "u.mobile"}, ",")).
|
||||
Select(strings.Join([]string{"m.id", "m.name", "u.mobile", "m.identity_info"}, ",")).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON m.uid = u.uuid", model.NewUserInstance().TableName())).
|
||||
Where("m.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("m.identity = ?", config.TenantUserIdentityForExpert)
|
||||
|
35
app/api/manage/api/manage.go
Normal file
35
app/api/manage/api/manage.go
Normal file
@ -0,0 +1,35 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/api"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Manage struct{}
|
||||
|
||||
func (*Manage) Company(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func (*Manage) Expert(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func (*Manage) Laboratory(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func (*Menu) Research(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func (*Menu) Examine(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
Identity int `json:"identity" form:"identity" binding:"required"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@ package controller
|
||||
|
||||
import (
|
||||
model3 "SciencesServer/app/api/manage/model"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/handle"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/config"
|
||||
@ -36,6 +35,7 @@ func (c *Account) Login(account, password, captchaKey, captchaValue, equipment,
|
||||
} else if !isExist {
|
||||
return nil, errors.New("该帐号信息不存在")
|
||||
}
|
||||
|
||||
if !mSysUser.ValidatePassword(password) {
|
||||
return nil, errors.New("密码错误")
|
||||
}
|
||||
@ -44,52 +44,12 @@ func (c *Account) Login(account, password, captchaKey, captchaValue, equipment,
|
||||
session.Name = mSysUser.Name
|
||||
session.Mobile = mSysUser.Mobile
|
||||
session.IsAdmin = mSysUser.IsAdminUser()
|
||||
// 非超级管理员
|
||||
if !session.IsAdmin {
|
||||
// 查询相应关系
|
||||
mSysUserTenant := model3.NewSysUserTenant()
|
||||
|
||||
if isExist, err = model2.FirstField(mSysUserTenant.SysUserTenant, []string{"id", "tenant_id", "identity", "status"},
|
||||
model2.NewWhere("uid", mSysUser.UUID)); err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("当前不属于任何租户,不可登录")
|
||||
}
|
||||
if mSysUserTenant.TenantID <= 0 {
|
||||
goto Complete
|
||||
}
|
||||
mSysTenant := model3.NewSysTenant()
|
||||
mSysTenant.ID = mSysUserTenant.TenantID
|
||||
|
||||
level := 0
|
||||
|
||||
for {
|
||||
if isExist, err = model2.FirstField(mSysTenant, []string{"id", "key", "parent_id", "deadline", "status"}); err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("租户信息不存在,不可登录")
|
||||
} else if mSysTenant.IsInvalid() {
|
||||
return nil, errors.New("租户协议已失效,不可登录")
|
||||
}
|
||||
if level <= 0 {
|
||||
session.TenantID = mSysTenant.ID
|
||||
//session.TenantKey = mSysTenant.Key
|
||||
}
|
||||
// 判断是否含有含有上级
|
||||
if mSysTenant.ParentID <= 0 {
|
||||
goto Complete
|
||||
}
|
||||
level++
|
||||
mSysTenant.ID = mSysTenant.ParentID
|
||||
}
|
||||
}
|
||||
Complete:
|
||||
uid := mSysUser.UUIDString()
|
||||
|
||||
session.Token = utils.JWTEncrypt(config.SettingInfo.TokenEffectTime, map[string]interface{}{config.TokenForUID: uid})
|
||||
|
||||
service.Publish(config.EventForRedisHashProduce, config.RedisKeyForAccount, uid, session)
|
||||
|
||||
service.Publish(config.EventForAccountLoginProduce, session.TenantID, session.UID, equipment, ip)
|
||||
|
||||
return &AccountLoginResponse{Token: session.Token, EffectTime: config.SettingInfo.TokenEffectTime}, nil
|
||||
|
153
app/api/manage/controller/manage/examine.go
Normal file
153
app/api/manage/controller/manage/examine.go
Normal file
@ -0,0 +1,153 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/manage/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Examine struct {
|
||||
*service.Session
|
||||
local string
|
||||
}
|
||||
|
||||
type ExamineHandle func(session *service.Session, local string) *Examine
|
||||
|
||||
type ExamineManageInfo struct {
|
||||
IModel model2.IModel
|
||||
TenantID uint64 // 租户ID
|
||||
UID uint64 // 用户表UUID
|
||||
IdentityInfo model2.IUserIdentity
|
||||
}
|
||||
|
||||
// examineHandle 审核处理
|
||||
var examineHandle = map[int]func(uint64) (*ExamineManageInfo, error){
|
||||
config.TenantUserIdentityForCompany: examineCompany,
|
||||
config.TenantUserIdentityForExpert: examineExpert,
|
||||
}
|
||||
|
||||
func checkManage(IModel model2.IModel, id uint64) error {
|
||||
IModel.SetID(id)
|
||||
|
||||
if isExist, err := model2.First(IModel); err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("数据信息不存在")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func examineCompany(id uint64) (*ExamineManageInfo, error) {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
|
||||
err := checkManage(mManageCompany.ManageCompany, id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if mManageCompany.Status != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("当前入住信息已审核")
|
||||
}
|
||||
return &ExamineManageInfo{
|
||||
IModel: mManageCompany.ManageCompany, UID: mManageCompany.UID,
|
||||
IdentityInfo: &model2.UserIdentityForCompany{
|
||||
Industry: mManageCompany.Industry, Keyword: mManageCompany.Keyword,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func examineExpert(id uint64) (*ExamineManageInfo, error) {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
err := checkManage(mManageExpert.ManageExpert, id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if mManageExpert.Status != model2.ExamineStatusForOngoing {
|
||||
return nil, errors.New("当前入住信息已审核")
|
||||
}
|
||||
return &ExamineManageInfo{
|
||||
IModel: mManageExpert.ManageExpert, UID: mManageExpert.UID,
|
||||
IdentityInfo: &model2.UserIdentityForExpert{
|
||||
Industry: mManageExpert.Industry, Keyword: mManageExpert.Keyword, Research: mManageExpert.Research,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Launch 发起审核
|
||||
func (c *Examine) Launch(id uint64, identity, status int) error {
|
||||
_status := model2.ExamineStatusKind(status)
|
||||
|
||||
if _status != model2.ExamineStatusForRefuse && _status != model2.ExamineStatusForAgree {
|
||||
return errors.New("未知的审核模式")
|
||||
}
|
||||
handle, has := examineHandle[identity]
|
||||
|
||||
if !has {
|
||||
return errors.New("未知的身份信息")
|
||||
}
|
||||
data, err := handle(id)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.Updates(data.IModel, map[string]interface{}{
|
||||
"status": status, "updated_at": time.Now(),
|
||||
}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
// 拒绝后,不执行以下数据
|
||||
if _status == model2.ExamineStatusForRefuse {
|
||||
return nil
|
||||
}
|
||||
mUserManage := model.NewUserManage()
|
||||
|
||||
isExist := true
|
||||
|
||||
if isExist, err = model2.FirstField(mUserManage.UserManage, []string{"id", "uid"}, model2.NewWhere("uid", data.UID),
|
||||
model2.NewWhere("identity", identity)); err != nil {
|
||||
return err
|
||||
}
|
||||
if !isExist {
|
||||
mUserManage.TenantID = data.TenantID
|
||||
mUserManage.UID = data.UID
|
||||
mUserManage.Identity = identity
|
||||
mUserManage.IdentityInfo = utils.AnyToJSON(data.IdentityInfo)
|
||||
} else {
|
||||
if err = model2.Updates(mUserManage.UserManage, map[string]interface{}{
|
||||
"identity_info": utils.AnyToJSON(data.IdentityInfo), "updated_at": time.Now(),
|
||||
}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// 更新账户身份信息
|
||||
mUserInstance := model.NewUserInstance()
|
||||
|
||||
if _, err = model2.FirstField(mUserInstance.UserInstance, []string{"id", "uuid", "identity"},
|
||||
model2.NewWhere("uuid", data.UID)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = model2.Updates(mUserInstance.UserInstance, map[string]interface{}{
|
||||
"identity": mUserInstance.Identity | identity, "updated_at": time.Now(),
|
||||
}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func NewExamine() ExamineHandle {
|
||||
return func(session *service.Session, local string) *Examine {
|
||||
return &Examine{
|
||||
Session: session,
|
||||
local: local,
|
||||
}
|
||||
}
|
||||
}
|
19
app/api/manage/controller/manage/instance.go
Normal file
19
app/api/manage/controller/manage/instance.go
Normal file
@ -0,0 +1,19 @@
|
||||
package manage
|
||||
|
||||
import "SciencesServer/app/service"
|
||||
|
||||
type Instance struct {
|
||||
*service.Session
|
||||
local string
|
||||
}
|
||||
|
||||
type InstanceHandle func(session *service.Session, local string) *Instance
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(session *service.Session, local string) *Instance {
|
||||
return &Instance{
|
||||
Session: session,
|
||||
local: local,
|
||||
}
|
||||
}
|
||||
}
|
11
app/api/manage/model/manage_company.go
Normal file
11
app/api/manage/model/manage_company.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ManageCompany struct {
|
||||
*model.ManageCompany
|
||||
}
|
||||
|
||||
func NewManageCompany() *ManageCompany {
|
||||
return &ManageCompany{}
|
||||
}
|
11
app/api/manage/model/manage_expert.go
Normal file
11
app/api/manage/model/manage_expert.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ManageExpert struct {
|
||||
*model.ManageExpert
|
||||
}
|
||||
|
||||
func NewManageExpert() *ManageExpert {
|
||||
return &ManageExpert{model.NewManageExpert()}
|
||||
}
|
11
app/api/manage/model/manage_laboratory.go
Normal file
11
app/api/manage/model/manage_laboratory.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ManageLaboratory struct {
|
||||
*model.ManageLaboratory
|
||||
}
|
||||
|
||||
func NewManageLaboratory() *ManageLaboratory {
|
||||
return &ManageLaboratory{model.NewManageLaboratory()}
|
||||
}
|
11
app/api/manage/model/manage_research.go
Normal file
11
app/api/manage/model/manage_research.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ManageResearch struct {
|
||||
*model.ManageResearch
|
||||
}
|
||||
|
||||
func NewManageResearch() *ManageResearch {
|
||||
return &ManageResearch{model.NewManageResearch()}
|
||||
}
|
13
app/api/manage/model/sys_industry.go
Normal file
13
app/api/manage/model/sys_industry.go
Normal file
@ -0,0 +1,13 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
)
|
||||
|
||||
type SysIndustry struct {
|
||||
*model.SysIndustry
|
||||
}
|
||||
|
||||
func NewSysIndustry() *SysIndustry {
|
||||
return &SysIndustry{model.NewSysIndustry()}
|
||||
}
|
11
app/api/manage/model/user_instance.go
Normal file
11
app/api/manage/model/user_instance.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserInstance struct {
|
||||
*model.UserInstance
|
||||
}
|
||||
|
||||
func NewUserInstance() *UserInstance {
|
||||
return &UserInstance{model.NewUserInstance()}
|
||||
}
|
11
app/api/manage/model/user_manage.go
Normal file
11
app/api/manage/model/user_manage.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type UserManage struct {
|
||||
*model.UserManage
|
||||
}
|
||||
|
||||
func NewUserManage() *UserManage {
|
||||
return &UserManage{model.NewUserManage()}
|
||||
}
|
27
app/basic/config/memory.go
Normal file
27
app/basic/config/memory.go
Normal file
@ -0,0 +1,27 @@
|
||||
package config
|
||||
|
||||
import "strings"
|
||||
|
||||
type (
|
||||
// MemoryForIndustry 行业
|
||||
MemoryForIndustry struct {
|
||||
Name string `json:"name"`
|
||||
Children map[string]*MemoryForIndustry `json:"children"`
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
// MemoryForIndustryInfo 行业信息
|
||||
MemoryForIndustryInfo map[string]*MemoryForIndustry = make(map[string]*MemoryForIndustry, 0)
|
||||
)
|
||||
|
||||
// GetIndustryInfo 获取行业信息
|
||||
func GetIndustryInfo(industry, mark string) string {
|
||||
obj := strings.Split(industry, mark)
|
||||
out := make([]string, 0)
|
||||
|
||||
for _, v := range obj {
|
||||
out = append(out, MemoryForIndustryInfo[v].Name)
|
||||
}
|
||||
return strings.Join(out, "-")
|
||||
}
|
23
app/basic/config/memory_test.go
Normal file
23
app/basic/config/memory_test.go
Normal file
@ -0,0 +1,23 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMemory(t *testing.T) {
|
||||
MemoryForIndustryInfo["01"] = &MemoryForIndustry{
|
||||
Name: "01",
|
||||
Children: map[string]*MemoryForIndustry{
|
||||
"001": &MemoryForIndustry{
|
||||
Name: "001",
|
||||
Children: nil,
|
||||
},
|
||||
"002": &MemoryForIndustry{
|
||||
Name: "002",
|
||||
Children: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
t.Logf(utils.AnyToJSON(MemoryForIndustryInfo))
|
||||
}
|
@ -22,7 +22,7 @@ type (
|
||||
Title string `json:"title" form:"title"`
|
||||
WorkAt string `json:"work_at" form:"work_at"`
|
||||
Keyword string `json:"keyword" form:"keyword"`
|
||||
Research map[int]string `json:"research" form:"research"` // 研究方向
|
||||
Research string `json:"research" form:"research"` // 研究方向
|
||||
}
|
||||
// IdentityForResearch 研究机构
|
||||
IdentityForResearch struct {
|
||||
|
@ -11,7 +11,7 @@ type ManageCompany struct {
|
||||
Code string `gorm:"column:code;type:varchar(30);default:null;comment:信用代码" json:"code"`
|
||||
Image
|
||||
Area
|
||||
Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"`
|
||||
Industry string `gorm:"column:industry;type:varchar(255);default:0;comment:行业领域" json:"industry"`
|
||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||
ExamineStatus
|
||||
|
@ -18,7 +18,7 @@ type ManageExpert struct {
|
||||
Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"`
|
||||
Title string `gorm:"column:title;type:varchar(50);default:null;comment:职称" json:"title"`
|
||||
WorkAt time.Time `gorm:"column:work_at;type:date;not null;comment:从业时间" json:"work_at"`
|
||||
Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"`
|
||||
Industry string `gorm:"column:industry;type:varchar(30);default:0;comment:行业领域" json:"industry"`
|
||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"`
|
||||
Research string `gorm:"column:research;type:varchar(255);default:null;comment:研究信息" json:"research"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||
|
@ -15,7 +15,7 @@ type ManageLaboratory struct {
|
||||
Image
|
||||
Area
|
||||
Position string `gorm:"column:position;type:varchar(50);default:null;comment:坐标" json:"-"`
|
||||
Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"`
|
||||
Industry string `gorm:"column:industry;type:varchar(30);default:0;comment:行业领域" json:"industry"`
|
||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"`
|
||||
Research string `gorm:"column:research;type:varchar(255);default:null;comment:研究信息" json:"research"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||
|
@ -13,7 +13,7 @@ type ManageResearch struct {
|
||||
Image
|
||||
Area
|
||||
Position string `gorm:"column:position;type:varchar(50);default:null;comment:坐标" json:"-"`
|
||||
Industry uint64 `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"`
|
||||
Industry string `gorm:"column:industry;type:int(11);default:0;comment:行业领域" json:"industry"`
|
||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"`
|
||||
Research string `gorm:"column:research;type:varchar(255);default:null;comment:研究信息" json:"research"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
|
||||
// IModel
|
||||
type IModel interface {
|
||||
SetID(uint64)
|
||||
GetID() uint64
|
||||
GetEncodeID() string
|
||||
TableName() string
|
||||
@ -64,6 +65,10 @@ const (
|
||||
SubDatabase string = "tenant"
|
||||
)
|
||||
|
||||
func (m *Model) SetID(id uint64) {
|
||||
m.ID = id
|
||||
}
|
||||
|
||||
func (m *Model) GetID() uint64 {
|
||||
return m.ID
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package model
|
||||
// SysIndustry 行业领域数据模型
|
||||
type SysIndustry struct {
|
||||
Model
|
||||
ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"-"`
|
||||
Code string `gorm:"column:code;type:varchar(30);default:null;comment:编号" json:"code"`
|
||||
Name string `gorm:"column:name;type:varchar(30);default:null;comment:行业名称" json:"name"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package model
|
||||
// SysResearch 研究领域数据模型
|
||||
type SysResearch struct {
|
||||
Model
|
||||
ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"-"`
|
||||
Code string `gorm:"column:code;type:varchar(30);default:null;comment:编号" json:"code"`
|
||||
Name string `gorm:"column:name;type:varchar(30);default:null;comment:角色名" json:"name"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/utils"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
@ -15,15 +16,43 @@ type UserManage struct {
|
||||
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"`
|
||||
Identity int `gorm:"column:identity;type:tinyint(3);default:0;comment:身份信息" json:"-"`
|
||||
FixedPhone string `gorm:"column:fixed_phone;type:varchar(20);default:null;comment:固定电话" json:"fixed_phone"`
|
||||
Address string `gorm:"column:address;type:varchar(255);default:null;comment:详细地址" json:"address"`
|
||||
Other string `gorm:"column:other;type:varchar(255);default:null;comment:其他信息" json:"-"`
|
||||
Selected UserManageSelected `gorm:"column:selected;type:tinyint(1);default:0;comment:最后一次选中的身份状态,用于下次登陆展示" json:"-"`
|
||||
Identity int `gorm:"column:identity;type:tinyint(3);default:0;comment:身份" json:"-"`
|
||||
IdentityInfo string `gorm:"column:identity_info;type:varchar(255);default:null;comment:身份信息" json:"-"`
|
||||
IsSelected UserManageSelected `gorm:"column:is_selected;type:tinyint(1);default:0;comment:最后一次选中的身份状态,用于下次登陆展示" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
type IUserIdentity interface {
|
||||
Analysis(src string) interface{}
|
||||
}
|
||||
|
||||
type (
|
||||
// UserIdentityForCompany 公司信息
|
||||
UserIdentityForCompany struct {
|
||||
Industry string `json:"industry"`
|
||||
Keyword string `json:"keyword"`
|
||||
}
|
||||
// UserIdentityForExpert 专家信息
|
||||
UserIdentityForExpert struct {
|
||||
Industry string `json:"industry"`
|
||||
Keyword string `json:"keyword"`
|
||||
Research string `json:"research"`
|
||||
}
|
||||
)
|
||||
|
||||
func (this *UserIdentityForCompany) Analysis(src string) interface{} {
|
||||
utils.FromJSON(src, this)
|
||||
return this
|
||||
}
|
||||
|
||||
func (this *UserIdentityForExpert) Analysis(src string) interface{} {
|
||||
utils.FromJSON(src, this)
|
||||
return this
|
||||
}
|
||||
|
||||
type UserManageSelected int
|
||||
|
||||
const (
|
||||
@ -44,8 +73,22 @@ func (m *UserManage) BeforeCreate(db *gorm.DB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *UserManage) GetOtherAttribute() {
|
||||
func (m *UserManage) GetIdentityInfoAttribute() interface{} {
|
||||
var manage IUserIdentity
|
||||
|
||||
switch m.Identity {
|
||||
case config.TenantUserIdentityForCompany:
|
||||
manage = new(UserIdentityForCompany)
|
||||
break
|
||||
case config.TenantUserIdentityForExpert:
|
||||
manage = new(UserIdentityForExpert)
|
||||
break
|
||||
}
|
||||
return manage.Analysis(m.IdentityInfo)
|
||||
}
|
||||
|
||||
func (m *UserManage) SetIdentityInfoAttribute(src IUserIdentity) {
|
||||
m.IdentityInfo = utils.AnyToJSON(src)
|
||||
}
|
||||
|
||||
func NewUserManage() *UserManage {
|
||||
|
@ -1,24 +1,23 @@
|
||||
package platform
|
||||
|
||||
import "SciencesServer/utils"
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Wechat struct{}
|
||||
type Wechat struct {
|
||||
AppID, AppSecret string
|
||||
}
|
||||
|
||||
type WechatScan struct{}
|
||||
|
||||
type WechatScanHandle func() *WechatScan
|
||||
type WechatHandle func(appID, appSecret string) *Wechat
|
||||
|
||||
type (
|
||||
WechatBasicRequest struct {
|
||||
AppID, Secret string
|
||||
}
|
||||
WechatErrorResponse struct {
|
||||
ErrCode int `json:"errcode"`
|
||||
ErrMsg int `json:"errmsg"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
}
|
||||
// WechatAccessTokenRequest 请求AccessToken参数
|
||||
WechatAccessTokenRequest struct {
|
||||
WechatBasicRequest
|
||||
Code string
|
||||
}
|
||||
// WechatAccessTokenResponse 获取AccessToken响应参数
|
||||
@ -29,7 +28,7 @@ type (
|
||||
OpenID string `json:"openid"`
|
||||
Scope string `json:"scope"`
|
||||
UnionID string `json:"unionid"`
|
||||
*WechatErrorResponse
|
||||
WechatErrorResponse
|
||||
}
|
||||
)
|
||||
|
||||
@ -38,18 +37,18 @@ const (
|
||||
WechatAccessTokenUrl string = "https://api.weixin.qq.com/sns/oauth2/access_token"
|
||||
)
|
||||
|
||||
func (this *WechatScan) Login() {
|
||||
func (this *Wechat) ScanLogin() {
|
||||
|
||||
}
|
||||
|
||||
func (this *WechatScan) Pay() {
|
||||
func (this *Wechat) ScanPay() {
|
||||
|
||||
}
|
||||
|
||||
// AccessToken AccessToken操作
|
||||
func (this *Wechat) AccessToken(req *WechatAccessTokenRequest) (*WechatAccessTokenResponse, error) {
|
||||
params := map[string]interface{}{
|
||||
"appid": req.AppID, "secret": req.Secret, "code": req.Code, "grant_type": "authorization_code",
|
||||
"appid": this.AppID, "secret": this.AppSecret, "code": req.Code, "grant_type": "authorization_code",
|
||||
}
|
||||
resp, err := utils.NewClient(WechatAccessTokenUrl, utils.MethodForGet, params).Request(utils.RequestBodyFormatForXWWWFormUrlencoded)
|
||||
|
||||
@ -61,16 +60,14 @@ func (this *Wechat) AccessToken(req *WechatAccessTokenRequest) (*WechatAccessTok
|
||||
if err = utils.FromJSONBytes(resp, out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if out.WechatErrorResponse.ErrCode != 0 {
|
||||
return nil, errors.New(out.WechatErrorResponse.ErrMsg)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Scan 扫码操作
|
||||
func (this *Wechat) Scan() WechatScanHandle {
|
||||
return func() *WechatScan {
|
||||
return &WechatScan{}
|
||||
func NewWechat() WechatHandle {
|
||||
return func(appID, appSecret string) *Wechat {
|
||||
return &Wechat{AppID: appID, AppSecret: appSecret}
|
||||
}
|
||||
}
|
||||
|
||||
func NewWechat() *Wechat {
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user