feat:完善入驻信息管理

This commit is contained in:
henry
2021-12-03 15:22:23 +08:00
parent 851a2c1784
commit 911fcf9b1c
16 changed files with 100 additions and 27 deletions

View File

@ -5,6 +5,7 @@ import (
"SciencesServer/app/common/model"
"SciencesServer/config"
"SciencesServer/serve/orm"
"SciencesServer/utils"
)
type synchronized struct {
@ -25,8 +26,10 @@ func initModel() {
function := func(synchronized ...*synchronized) {
for _, v := range synchronized {
if !db.Migrator().HasTable(v.iModel) {
_ = db.Migrator().CreateTable(v.iModel)
err := db.Migrator().CreateTable(v.iModel)
if err != nil {
panic(err)
}
if v.iValues != nil && v.iValues() != nil {
db.Table(v.iModel.TableName()).Create(v.iValues())
}
@ -40,10 +43,10 @@ func initModel() {
&synchronized{iModel: model.NewSysConfig()},
&synchronized{iModel: model.NewSysMenu()}, &synchronized{iModel: model.NewSysAuth()},
&synchronized{iModel: model.NewSysUser(), iValues: func() interface{} {
return &model.SysUser{Account: "admin", Name: "商挈智能", Mobile: "13888888888", Password: "123456",
return &model.SysUser{Account: "admin", Name: "商挈智能", Mobile: "13888888888", Password: utils.Md5String("123456"),
IsAdmin: model.SysUserAdministratorForAdmin, Remark: "超级管理员"}
}},
&synchronized{iModel: model.NewSysUserTenant()},
&synchronized{iModel: model.NewSysUserRole()}, &synchronized{iModel: model.NewSysUserTenant()},
&synchronized{iModel: model.NewSysDepartment()},
&synchronized{iModel: model.NewSysRole()}, &synchronized{iModel: model.NewSysRoleMenu()}, &synchronized{iModel: model.NewSysRoleAuth()},
// 配置管理
@ -72,7 +75,6 @@ func initModel() {
return out
}},
// 日志管理
&synchronized{iModel: model.NewSysUserRole()},
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},
// 用户管理
&synchronized{iModel: model.NewUserInstance()}, &synchronized{iModel: model.NewUserIdentity()},

View File

@ -7,7 +7,7 @@ type ActivityApply struct {
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"`
ActivityInstanceBasic
Content string `gorm:"column:title;type:text;default:'';comment:活动详情" json:"content"`
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"`
Status ActivityApplyStatus `gorm:"column:status;type:tinyint(1);default:0;comment:审核状态" json:"status"`
ModelDeleted

View File

@ -9,7 +9,7 @@ type ActivityInstance struct {
Identity int `gorm:"column:identity;type:tinyint(3);default:0;comment:身份来源" json:"-"`
Mode ActivityInstanceMode `gorm:"column:mode;type:tinyint(1);default:1;comment:活动模式" json:"mode"`
ActivityInstanceBasic
Content string `gorm:"column:title;type:text;default:'';comment:活动详情" json:"content"`
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"`
Status ActivityInstanceStatus `gorm:"column:status;type:tinyint(1);default:1;comment:活动状态1显示2隐藏" json:"status"`
ModelDeleted

View File

@ -39,7 +39,7 @@ func (m *Image) Analysis(domain string) string {
// Images 多个图片信息
type Images struct {
Images string `gorm:"column:images;type:text;default:'';comment:图片" json:"images"`
Images string `gorm:"column:images;type:text;comment:图片" json:"images"`
}
// AnalysisSlice Slice解析

View File

@ -13,7 +13,7 @@ type ManageAgent struct {
Keyword string `gorm:"column:keyword;type:varchar(255);default:'';comment:关键词" json:"-"`
WorkExperience string `gorm:"column:work_experience;type:varchar(255);default:'';comment:工作经历" json:"work_experience"`
WorkPlace string `gorm:"column:work_place;type:varchar(255);default:0;comment:工作地点" json:"work_place"`
IDImage string `gorm:"column:id_image;type:text;default:'';comment:身份证图片" json:"-"`
IDImage string `gorm:"column:id_image;type:text;comment:身份证图片" json:"-"`
CredentialImage string `gorm:"column:credential_image;type:varchar(255);default:'';comment:资格证书" json:"credential_image"`
Examine
ModelDeleted

View File

@ -12,7 +12,7 @@ type ManageEquipment struct {
Title string `gorm:"column:title;type:varchar(100);default:'';comment:器材名称" json:"title"`
Params string `gorm:"column:params;type:varchar(255);default:'';comment:器材参数" json:"params"`
PurchaseAt time.Time `gorm:"column:purchase_at;type:datetime;default:'';comment:购买时间" json:"purchase_at"`
Description string `gorm:"column:description;type:text;default:'';comment:器材描述" json:"description"`
Description string `gorm:"column:description;type:text;comment:器材描述" json:"description"`
ModelDeleted
ModelAt
}

View File

@ -23,7 +23,7 @@ type ManageResearch struct {
}
func (m *ManageResearch) TableName() string {
return "manage_expert"
return "manage_research"
}
func (m *ManageResearch) GetIndustryAttribute() []string {

View File

@ -11,7 +11,7 @@ type ServiceDemand struct {
Title string `gorm:"column:title;type:varchar(50);default:'';comment:需求名称" json:"title"`
Name string `gorm:"column:name;type:varchar(50);default:'';comment:联系人" json:"name"`
Mobile string `gorm:"column:mobile;type:varchar(15);default:'';comment:联系人手机号" json:"mobile"`
Description string `gorm:"column:description;type:text;default:'';comment:需求描述" json:"description"`
Description string `gorm:"column:description;type:text;comment:需求描述" json:"description"`
Status ServiceDemandStatus `gorm:"column:status;type:tinyint(1);default:1;comment:状态" json:"status"`
ModelDeleted
ModelAt

View File

@ -8,7 +8,7 @@ type SysLog struct {
Name string `gorm:"column:name;type:varchar(20);default:'';comment:真实姓名" json:"name"`
Method string `gorm:"column:method;type:varchar(8);default:'';comment:请求方式" json:"method"`
Path string `gorm:"column:path;type:varchar(8);default:0;comment:请求地址" json:"event"`
Params string `gorm:"column:params;type:text;default:'';comment:参数信息" json:"params"`
Params string `gorm:"column:params;type:text;comment:参数信息" json:"params"`
IP string `gorm:"column:ip;type:char(16);default:'';comment:IP地址" json:"ip"`
ModelDeleted
ModelAt

View File

@ -13,8 +13,8 @@ type SysPatent struct {
ApplyName string `gorm:"column:apply_name;type:varchar(100);default:'';comment:申请(专利权)人" json:"apply_name"`
ApplyAddress string `gorm:"column:apply_address;type:varchar(255);default:'';comment:申请人地址" json:"apply_address"`
Inventor string `gorm:"column:inventor;type:varchar(100);default:'';comment:发明人" json:"inventor"`
Description string `gorm:"column:description;type:text;default:'';comment:摘要" json:"description"`
PrincipalClaim string `gorm:"column:principal_claim;type:text;default:'';comment:主权项" json:"principal_claim"`
Description string `gorm:"column:description;type:text;comment:摘要" json:"description"`
PrincipalClaim string `gorm:"column:principal_claim;type:text;comment:主权项" json:"principal_claim"`
IPCCode string `gorm:"column:ipc_code;type:varchar(50);default:'';comment:IPC主分类号" json:"ipc_code"`
Shelf
Status SysParentStatus `gorm:"column:status;type:tinyint(1);default:1;comment:专利状态(1授权2实审3公开)" json:"-"`

View File

@ -21,7 +21,7 @@ type TechnologyInstance struct {
Territory uint64 `gorm:"column:territory;type:int(11);default:0;comment:技术领域" json:"territory"`
Transaction int `gorm:"column:transaction;type:tinyint(3);default:0;comment:交易方式" json:"transaction"`
Images
ProveImages string `gorm:"column:prove_images;type:text;default:'';comment:证明材料图片" json:"prove_images"`
ProveImages string `gorm:"column:prove_images;type:text;comment:证明材料图片" json:"prove_images"`
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
Purpose string `gorm:"column:purpose;type:text;comment:意图-承担科研项目" json:"purpose"`
Remark string `gorm:"column:remark;type:varchar(255);default:'';comment:备注信息" json:"remark"`

View File

@ -5,7 +5,6 @@ import (
"SciencesServer/app/common"
"SciencesServer/config"
"SciencesServer/cron"
"SciencesServer/lib"
"SciencesServer/router"
"SciencesServer/rpc/client"
"SciencesServer/serve/cache"
@ -32,12 +31,12 @@ type Option struct {
func (this *Serve) Run() {
// 载入配置
lib.LoadConfig(this.Option.Config, config.SettingInfo, func(i interface{}) {
utils.LoadConfig(this.Option.Config, config.SettingInfo, func(i interface{}) {
obj := i.(*config.Setting)
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()
})
lib.LoadConfig(this.Option.RpcConfig, config.RPCServerSettingInfo, func(i interface{}) {
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)
@ -56,6 +55,11 @@ func (this *Serve) Run() {
orm.NewInstance(
orm.WithDebug(config.SettingInfo.Engine.Debug),
orm.WithDBMode(config.SettingInfo.Engine.DBMode),
orm.WithTablePrefix(config.SettingInfo.Engine.TablePrefix),
orm.WithSingularTable(!config.SettingInfo.Engine.Complex),
orm.WithMaxIdleConns(config.SettingInfo.Engine.MaxIdleConns),
orm.WithMaxOpenConns(config.SettingInfo.Engine.MaxOpenConns),
orm.WithMaxLifetime(config.SettingInfo.Engine.MaxLifetime),
//orm.WithMysqlUser(config.SettingInfo.Engine.Mysql.User),
).Init()
task.Init()

View File

@ -25,6 +25,9 @@ var (
type Instance struct {
debug bool
dbMode string
tablePrefix string
singularTable bool
maxIdleConns, maxOpenConns, maxLifetime int
*logic.Mysql
*logic.Sqlite
}
@ -43,14 +46,46 @@ func WithDBMode(dbMode string) Option {
}
}
func WithMysqlUser(user string) Option {
func WithTablePrefix(tablePrefix string) Option {
return func(instance *Instance) {
instance.tablePrefix = tablePrefix
}
}
func WithSingularTable(singularTable bool) Option {
return func(instance *Instance) {
instance.singularTable = singularTable
}
}
func WithMaxIdleConns(maxIdleConns int) Option {
return func(instance *Instance) {
instance.maxIdleConns = maxIdleConns
}
}
func WithMaxOpenConns(maxOpenConns int) Option {
return func(instance *Instance) {
instance.maxOpenConns = maxOpenConns
}
}
func WithMaxLifetime(maxLifetime int) Option {
return func(instance *Instance) {
instance.maxLifetime = maxLifetime
}
}
func WithMysqlOption(user string) Option {
return func(instance *Instance) {
instance.Mysql.User = user
}
}
func WithMysql() {
func WithSqliteOption(user string) Option {
return func(instance *Instance) {
instance.Mysql.User = user
}
}
func (this *Instance) Init() {

View File

@ -2,8 +2,8 @@ package tools
import (
"SciencesServer/config"
"SciencesServer/lib"
"SciencesServer/tools/ip"
"SciencesServer/utils"
)
func initIP() {
@ -11,7 +11,7 @@ func initIP() {
}
func initJSON() {
lib.LoadConfig("./file/area.json", &config.SettingAreaInfo)
utils.LoadConfig("./file/area.json", &config.SettingAreaInfo)
}
func Init() {

View File

@ -1,4 +1,4 @@
package lib
package utils
import (
"encoding/json"

32
utils/load_test.go Normal file
View File

@ -0,0 +1,32 @@
package utils
import (
"fmt"
"testing"
)
type ManagePatent struct {
Kind string `json:"kind"`
Title string `json:"title"`
FileUrl string `json:"file_url"`
ApplyCode string `json:"apply_code"`
ApplyAt string `json:"apply_at"`
OpenCode string `json:"open_code"`
OpenAt string `json:"open_at"`
ApplyName string `json:"apply_name"`
ApplyAddress string `json:"apply_address"`
Inventor string `json:"inventor"`
Description string `json:"description"`
PrincipalClaim string `json:"principal_claim"`
IpcCode string `json:"ipc_code"`
}
func TestLoadConfig(t *testing.T) {
file := "../file/manage_patent.json"
out := make([]*ManagePatent, 0)
LoadConfig(file, &out)
fmt.Println(AnyToJSON(out))
}