feat:完善入驻信息管理

This commit is contained in:
henry
2021-12-07 16:10:12 +08:00
parent 3989befe92
commit 95e8fdb9bb
30 changed files with 397 additions and 89 deletions

View File

@ -3,6 +3,7 @@ package api
import (
"SciencesServer/app/api/enterprise/controller/config"
"SciencesServer/app/basic/api"
"SciencesServer/utils"
"github.com/gin-gonic/gin"
)
@ -19,7 +20,15 @@ func (a *Config) Transaction(c *gin.Context) {
}
func (a *Config) Industry(c *gin.Context) {
form := &struct {
ParentID string `json:"parent_id" form:"parent_id"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data := config.NewConfig().Industry(utils.StringToUnit64(form.ParentID))
api.APISuccess(data)(c)
}
func (a *Config) Research(c *gin.Context) {
@ -28,12 +37,12 @@ func (a *Config) Research(c *gin.Context) {
func (a *Config) Area(c *gin.Context) {
form := &struct {
Key string `json:"key" form:"key"`
Code string `json:"code" form:"code"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data := config.NewConfig().Area(form.Key)
data := config.NewConfig().Area(form.Code)
api.APIResponse(nil, data)(c)
}

View File

@ -47,11 +47,26 @@ func (*Settled) Company(c *gin.Context) {
api.APIFailure(err.(error))(c)
return
}
form.License = (&api.ImageForm{Image: form.License}).FilterImageURL()
err := settled.NewCompany()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
Launch(form.settledForm.bind(), (&api.IDStringForm{ID: form.InviterCode}).Convert(), &form.IdentityForCompany)
api.APIResponse(err)(c)
}
// CompanyGet 公司入驻信息
func (*Settled) CompanyGet(c *gin.Context) {
form := &struct {
Code string `json:"code" form:"code" binding:"required"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := settled.NewCompany()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).Get(form.Code)
api.APIResponse(err, data)(c)
}
// Expert 专家入驻信息
func (*Settled) Expert(c *gin.Context) {
form := &struct {

View File

@ -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)
}

View File

@ -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 研究领域信息

View File

@ -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

View File

@ -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
}

View File

@ -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),

View File

@ -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

View File

@ -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()

View File

@ -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 != "" {

View File

@ -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

View File

@ -0,0 +1,40 @@
package model
import (
"SciencesServer/app/common/model"
"SciencesServer/serve/orm"
"fmt"
)
type TechnologyProductVisit struct {
*model.TechnologyProductVisit
}
type TechnologyProductVisitInfo struct {
}
func (m *TechnologyProductVisit) Visit(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyProductVisitInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS v").
Select("v.id").
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON v.company_id = c.id", model.NewManageCompany().TableName())).
Where("v.is_deleted = ?", model.DeleteStatusForNot)
out := make([]*TechnologyProductVisitInfo, 0)
if len(where) > 0 {
for _, v := range where {
db = db.Where(v.Condition, v.Value)
}
}
if err := db.Count(count).Error; err != nil {
return nil, err
}
if err := db.Order("v.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
return nil, err
}
return out, nil
}
func NewTechnologyProductVisit() *TechnologyProductVisit {
return &TechnologyProductVisit{model.NewTechnologyProductVisit()}
}

View File

@ -14,7 +14,7 @@ func (m *UserAgent) Agent(uid uint64) (*UserSettledInfo, error) {
out := new(UserSettledInfo)
err := orm.GetDB().Table(m.TableName()+" AS u").
Select("u.id", "c.examine_status").
Select("u.id", "c.examine_status", "c.examine_remark").
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u.agent_id = c.id", model.NewManageAgent().TableName())).
Where("u.uid = ?", uid).
Where("u.is_deleted = ? AND u.invalid_status = ?", model.DeleteStatusForNot, model.InvalidStatusForNot).

View File

@ -12,7 +12,7 @@ type UserCompany struct {
type UserSettledInfo struct {
ID uint64 `json:"id"`
model.Examine
*model.Examine
}
// Company 公司信息
@ -20,7 +20,7 @@ func (m *UserCompany) Company(uid uint64) (*UserSettledInfo, error) {
out := new(UserSettledInfo)
err := orm.GetDB().Table(m.TableName()+" AS u").
Select("u.id", "c.examine_status").
Select("u.id", "c.examine_status", "c.examine_remark").
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u.company_id = c.id", model.NewManageCompany().TableName())).
Where("u.uid = ?", uid).
Where("u.is_deleted = ? AND u.invalid_status = ?", model.DeleteStatusForNot, model.InvalidStatusForNot).

View File

@ -14,7 +14,7 @@ func (m *UserExpert) Expert(uid uint64) (*UserSettledInfo, error) {
out := new(UserSettledInfo)
err := orm.GetDB().Table(m.TableName()+" AS u").
Select("u.id", "c.examine_status").
Select("u.id", "c.examine_status", "c.examine_remark").
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u.expert_id = c.id", model.NewManageExpert().TableName())).
Where("u.uid = ?", uid).
Where("u.is_deleted = ? AND u.invalid_status = ?", model.DeleteStatusForNot, model.InvalidStatusForNot).

View File

@ -14,7 +14,7 @@ func (m *UserLaboratory) Laboratory(uid uint64) (*UserSettledInfo, error) {
out := new(UserSettledInfo)
err := orm.GetDB().Table(m.TableName()+" AS u").
Select("u.id", "c.examine_status").
Select("u.id", "c.examine_status", "c.examine_remark").
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u.laboratory_id = c.id", model.NewManageLaboratory().TableName())).
Where("u.uid = ?", uid).
Where("u.is_deleted = ? AND u.invalid_status = ?", model.DeleteStatusForNot, model.InvalidStatusForNot).

View File

@ -14,7 +14,7 @@ func (m *UserResearch) Research(uid uint64) (*UserSettledInfo, error) {
out := new(UserSettledInfo)
err := orm.GetDB().Table(m.TableName()+" AS u").
Select("u.id", "c.examine_status").
Select("u.id", "c.examine_status", "c.examine_remark").
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u.research_id = c.id", model.NewManageResearch().TableName())).
Where("u.uid = ?", uid).
Where("u.is_deleted = ? AND u.invalid_status = ?", model.DeleteStatusForNot, model.InvalidStatusForNot).

View File

@ -5,14 +5,15 @@ import "strings"
type (
// MemoryForIndustry 行业
MemoryForIndustry struct {
Name string `json:"name"`
Children map[string]*MemoryForIndustry `json:"children"`
Code string `json:"code"`
Name string `json:"name"`
Children []*MemoryForIndustry `json:"children"`
}
)
var (
// MemoryForIndustryInfo 行业信息
MemoryForIndustryInfo map[string]*MemoryForIndustry = make(map[string]*MemoryForIndustry, 0)
MemoryForIndustryInfo map[string]string = make(map[string]string, 0)
)
// GetIndustryInfo 获取行业信息
@ -21,7 +22,7 @@ func GetIndustryInfo(industry, mark string) string {
out := make([]string, 0)
for _, v := range obj {
out = append(out, MemoryForIndustryInfo[v].Name)
out = append(out, MemoryForIndustryInfo[v])
}
return strings.Join(out, "-")
}

View File

@ -11,7 +11,10 @@ type Area struct {
type (
// IdentityForCompany 公司附加信息
IdentityForCompany struct {
Url string `json:"url" form:"url"` // 企业网站
Kinds []int `json:"kinds" form:"kinds"`
Product string `json:"product" form:"product" binding:"required"`
Url string `json:"url" form:"url"` // 企业网站
License string `json:"license" form:"license" binding:"required"`
}
// IdentityForExpert 专家附加信息
IdentityForExpert struct {

View File

@ -6,6 +6,7 @@ import (
"SciencesServer/config"
"SciencesServer/serve/orm"
"SciencesServer/utils"
"fmt"
)
type synchronized struct {
@ -74,6 +75,43 @@ func initModel() {
}
return out
}},
&synchronized{iModel: model.NewSysIndustry(), iValues: func() interface{} {
file := "./file/sys_industry.json"
src := make([]*config2.MemoryForIndustry, 0)
utils.LoadConfig(file, &src)
out := make([]*model.SysIndustry, 0)
var id uint64 = 1
for _, v := range src {
var parentID uint64 = 0
data := &model.SysIndustry{
Model: model.Model{
ID: id,
},
ParentID: parentID,
Name: v.Name,
}
out = append(out, data)
if v.Children != nil && len(v.Children) > 0 {
parentID = id
for _, val := range v.Children {
id++
data = &model.SysIndustry{
Model: model.Model{
ID: id,
},
ParentID: parentID,
Name: val.Name,
}
out = append(out, data)
}
}
}
return out
}},
// 日志管理
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},
// 用户管理
@ -114,6 +152,18 @@ func initCacheMode() {
}
}},
)
function(
&caches{iModel: model.NewSysIndustry(), iValues: func() interface{} {
out := make([]*model.SysIndustry, 0)
_ = model.ScanFields(model.NewSysIndustry(), &out, []string{"id", "name"})
return out
}, toCache: func(values interface{}) {
out := values.([]*model.SysIndustry)
for _, v := range out {
config2.MemoryForIndustryInfo[fmt.Sprintf("%d", v.ID)] = v.Name
}
}},
)
}
func Init() {

View File

@ -4,8 +4,8 @@ package model
type ActivityApply struct {
Model
Local
MUid uint64 `gorm:"column:m_uid;type:int;default:0;comment:用户manage_uuid" json:"-"`
Mode ActivityInstanceMode `gorm:"column:mode;type:tinyint(1);default:1;comment:活动模式" json:"mode"`
IdentityUID uint64 `gorm:"column:identity_uid;type:int;default:0;comment:用户身份表uuid" json:"-"`
Mode ActivityInstanceMode `gorm:"column:mode;type:tinyint(1);default:1;comment:活动模式" json:"mode"`
ActivityInstanceBasic
Content string `gorm:"column:title;type:text;comment:活动详情" json:"content"`
MaxNumber int `gorm:"column:max_number;type:int(6);default:0;comment:报名限制人数0不做限制" json:"max_number"`

View File

@ -7,23 +7,42 @@ type ManageCompany struct {
Model
Local
InviterID uint64 `gorm:"column:inviter_id;type:int;default:0;comment:邀请人ID" json:"inviter_id"`
Kind string `gorm:"column:kind;type:varchar(255);default:'';comment:类型" json:"kind"`
Name string `gorm:"column:name;type:varchar(30);default:'';comment:名称" json:"name"`
Code string `gorm:"column:code;type:varchar(30);default:'';comment:信用代码" json:"code"`
Image
Area
Product string `gorm:"column:product;type:varchar(255);default:'';comment:产品信息" json:"product"`
Url string `gorm:"column:url;type:varchar(255);default:'';comment:企业网站" json:"url"`
Industry string `gorm:"column:industry;type:varchar(255);default:'';comment:行业领域" json:"industry"`
Keyword string `gorm:"column:keyword;type:varchar(255);default:'';comment:关键词" json:"keyword"`
License string `gorm:"column:license;type:varchar(255);default:'';comment:营业执照" json:"license"`
Industry string `gorm:"column:industry;type:varchar(255);default:'';comment:行业领域" json:"-"`
Keyword string `gorm:"column:keyword;type:varchar(255);default:'';comment:关键词" json:"-"`
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
Examine
ModelDeleted
ModelAt
}
type ManageCompanyKind int
const (
ManageCompanyKindForMYQY ManageCompanyKind = iota + 1
)
func (m *ManageCompany) TableName() string {
return "manage_company"
}
func (m *ManageCompany) GetKindAttribute() []int {
out := make([]int, 0)
_ = utils.FromJSON(m.Industry, &out)
return out
}
func (m *ManageCompany) SetKindAttribute(value []int) {
m.Industry = utils.AnyToJSON(value)
}
func (m *ManageCompany) GetIndustryAttribute() []string {
out := make([]string, 0)
_ = utils.FromJSON(m.Industry, &out)

View File

@ -1,9 +1,11 @@
package model
import (
"SciencesServer/app/basic/config"
"SciencesServer/serve/orm"
"SciencesServer/serve/orm/logic"
"SciencesServer/utils"
"fmt"
"gorm.io/gorm"
"strings"
"testing"
@ -77,6 +79,7 @@ func filter(src string) string {
}
func TestRecoveryPatent(t *testing.T) {
return
src := make([]*PPatent, 0)
sqlite := sqlite()
@ -142,3 +145,50 @@ func TestRecoveryPatent(t *testing.T) {
}
}
}
func TestA(t *testing.T) {
return
mysql := mysql()
file := "../../../file/sys_industry.json"
src := make([]*config.MemoryForIndustry, 0)
utils.LoadConfig(file, &src)
out := make([]*SysIndustry, 0)
var id uint64 = 1
for _, v := range src {
var parentID uint64 = 0
data := &SysIndustry{
Model: Model{
ID: id,
},
ParentID: parentID,
Name: v.Name,
}
out = append(out, data)
if v.Children != nil && len(v.Children) > 0 {
parentID = id
for _, val := range v.Children {
id++
data = &SysIndustry{
Model: Model{
ID: id,
},
ParentID: parentID,
Name: val.Name,
}
out = append(out, data)
}
}
id++
}
fmt.Println(utils.AnyToJSON(out))
err := mysql.Table(NewSysIndustry().TableName()).Create(out).Error
t.Log(err)
}

View File

@ -4,7 +4,6 @@ package model
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:'';comment:编号" json:"code"`
Name string `gorm:"column:name;type:varchar(30);default:'';comment:行业名称" json:"name"`
ModelDeleted
ModelAt

View File

@ -0,0 +1,18 @@
package model
// TechnologyProductVisit 技术产品访问数据模型
type TechnologyProductVisit struct {
Model
ProductID uint64 `gorm:"column:product_id;type:int(11);default:0;comment:科技产品ID" json:"product_id"`
CompanyID uint64 `gorm:"column:company_id;type:int(11);default:0;comment:公司ID" json:"company_id"`
ModelDeleted
ModelAt
}
func (m *TechnologyProductVisit) TableName() string {
return "technology_product_visit"
}
func NewTechnologyProductVisit() *TechnologyProductVisit {
return &TechnologyProductVisit{}
}

View File

@ -9,7 +9,7 @@ import (
type Enterprise struct {
Token string `json:"token"` // token
UID uint64 `json:"uid"` // 唯一标识ID
ManageUID uint64 `json:"manage_uid"` // 管理平台用户唯一ID
IdentityUID uint64 `json:"identity_uid"` // 用户身份唯一ID
Avatar string `json:"avatar"` // 头像
Name string `json:"name"` // 名称
Mobile string `json:"mobile"` // 手机号码

View File

@ -6,7 +6,6 @@ import (
"SciencesServer/config"
"SciencesServer/cron"
"SciencesServer/router"
"SciencesServer/rpc/client"
"SciencesServer/serve/cache"
"SciencesServer/serve/es"
"SciencesServer/serve/logger"
@ -36,19 +35,19 @@ func (this *Serve) Run() {
obj.Upload.Exts = strings.Split(obj.Upload.Ext, ",")
logger.NewLogger().Init(&logger.Option{File: obj.Log.File, LeastDay: obj.Log.LeastDay, Level: obj.Log.Level, IsStdout: false}).Load()
})
utils.LoadConfig(this.Option.RpcConfig, config.RPCServerSettingInfo, func(i interface{}) {
obj := i.(*config.RPCServerSetting)
go utils.TryCatch(func() {
options := make(map[string]*client.ServerOption, 0)
for k, v := range obj.Servers {
options[k] = &client.ServerOption{
Host: v.Host, Port: v.Port, IsTLS: v.IsTLS, TLSName: v.TLSName, Pem: v.Pem,
}
}
client.NewServer(options).Run()
})
})
//utils.LoadConfig(this.Option.RpcConfig, config.RPCServerSettingInfo, func(i interface{}) {
// obj := i.(*config.RPCServerSetting)
// go utils.TryCatch(func() {
// options := make(map[string]*client.ServerOption, 0)
//
// for k, v := range obj.Servers {
// options[k] = &client.ServerOption{
// Host: v.Host, Port: v.Port, IsTLS: v.IsTLS, TLSName: v.TLSName, Pem: v.Pem,
// }
// }
// client.NewServer(options).Run()
// })
//})
cache.Init()
orm.NewInstance(
orm.WithDebug(config.SettingInfo.Engine.Debug),

View File

@ -2,7 +2,7 @@
{
"code": "1",
"name": "农、林、牧、渔业",
"child": [
"children": [
{
"code": "01",
"name": "农业"
@ -28,7 +28,7 @@
{
"code": "2",
"name": "采矿业",
"child": [
"children": [
{
"code": "06",
"name": "煤炭开采和洗选业"
@ -62,7 +62,7 @@
{
"code": "3",
"name": "制造业",
"child": [
"children": [
{
"code": "13",
"name": "农副食品加工业"
@ -192,7 +192,7 @@
{
"code": "4",
"name": "电力、热力、燃气及水生产和供应业",
"child": [
"children": [
{
"code": "44",
"name": "电力、热力生产和供应业"
@ -210,7 +210,7 @@
{
"code": "5",
"name": "建筑业",
"child": [
"children": [
{
"code": "47",
"name": "房屋建筑业"
@ -232,7 +232,7 @@
{
"code": "6",
"name": "批发和零售业",
"child": [
"children": [
{
"code": "51",
"name": "批发业"
@ -246,7 +246,7 @@
{
"code": "7",
"name": "交通运输、仓储和邮政业",
"child": [
"children": [
{
"code": "53",
"name": "铁路运输业"
@ -284,7 +284,7 @@
{
"code": "8",
"name": "住宿和餐饮业",
"child": [
"children": [
{
"code": "61",
"name": "住宿业"
@ -298,7 +298,7 @@
{
"code": "9",
"name": "信息传输、软件和信息技术服务业",
"child": [
"children": [
{
"code": "63",
"name": "电信、广播电视和卫星传输服务"
@ -316,7 +316,7 @@
{
"code": "10",
"name": "金融业",
"child": [
"children": [
{
"code": "66",
"name": "货币金融服务"
@ -338,7 +338,7 @@
{
"code": "11",
"name": "房地产业",
"child": [
"children": [
{
"code": "70",
"name": "房地产业"
@ -348,7 +348,7 @@
{
"code": "12",
"name": "租赁和商务服务业",
"child": [
"children": [
{
"code": "71",
"name": "租赁业"
@ -362,7 +362,7 @@
{
"code": "13",
"name": "科学研究和技术服务业",
"child": [
"children": [
{
"code": "73",
"name": "研究和试验发展"
@ -380,7 +380,7 @@
{
"code": "14",
"name": "水利、环境和公共设施管理业",
"child": [
"children": [
{
"code": "76",
"name": "水利管理业"
@ -398,7 +398,7 @@
{
"code": "15",
"name": "居民服务、修理和其他服务业",
"child": [
"children": [
{
"code": "79",
"name": "居民服务业"
@ -416,7 +416,7 @@
{
"code": "16",
"name": "教育",
"child": [
"children": [
{
"code": "82",
"name": "教育"
@ -426,7 +426,7 @@
{
"code": "17",
"name": "卫生和社会工作",
"child": [
"children": [
{
"code": "83",
"name": "卫生"
@ -440,7 +440,7 @@
{
"code": "18",
"name": "文化、体育和娱乐业",
"child": [
"children": [
{
"code": "85",
"name": "新闻和出版业"
@ -466,7 +466,7 @@
{
"code": "19",
"name": "公共管理、社会保障和社会组织",
"child": [
"children": [
{
"code": "90",
"name": "中国共产党机关"
@ -496,7 +496,7 @@
{
"code": "20",
"name": "国际组织",
"child": [
"children": [
{
"code": "96",
"name": "国际组织"

View File

@ -143,6 +143,7 @@ func registerEnterpriseAPI(app *gin.Engine) {
_api := new(api2.Config)
configV1.GET("/area", _api.Area)
configV1.GET("/identity", _api.Identity)
configV1.GET("/industry", _api.Industry)
}
// Account 账号管理
accountV1 := v1.Group("/account")
@ -172,6 +173,7 @@ func registerEnterpriseAPI(app *gin.Engine) {
_api := new(api2.Settled)
settledV1.GET("", _api.Index)
settledV1.POST("/company", _api.Company)
settledV1.POST("/company/get", _api.CompanyGet)
settledV1.POST("/expert", _api.Expert)
settledV1.POST("/research", _api.Research)
settledV1.POST("/laboratory", _api.Laboratory)

View File

@ -1,6 +1,7 @@
package utils
import (
"SciencesServer/app/basic/config"
"fmt"
"testing"
)
@ -22,9 +23,13 @@ type ManagePatent struct {
}
func TestLoadConfig(t *testing.T) {
file := "../file/manage_patent.json"
//file := "../file/manage_patent.json"
//out := make([]*ManagePatent, 0)
//LoadConfig(file, &out)
//fmt.Println(AnyToJSON(out))
out := make([]*ManagePatent, 0)
file := "../file/sys_industry.json"
out := make([]*config.MemoryForIndustry, 0)
LoadConfig(file, &out)