feat:完善入驻信息管理
This commit is contained in:
@ -113,10 +113,10 @@ type InvalidStatus struct {
|
||||
type InvalidStatusKind int
|
||||
|
||||
const (
|
||||
// InvalidStatusForNot 未失效
|
||||
InvalidStatusForNot InvalidStatusKind = iota
|
||||
// InvalidStatusForYes 已失效
|
||||
InvalidStatusForYes
|
||||
InvalidStatusForYes InvalidStatusKind = iota - 1
|
||||
// InvalidStatusForNot 未失效
|
||||
InvalidStatusForNot
|
||||
)
|
||||
|
||||
type Area struct {
|
||||
|
@ -1,6 +1,9 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/utils"
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// ManageAgent 经纪人入驻信息管理
|
||||
type ManageAgent struct {
|
||||
@ -9,18 +12,22 @@ type ManageAgent struct {
|
||||
Name string `gorm:"column:name;type:varchar(30);default:'';comment:姓名" json:"name"`
|
||||
Mobile string `gorm:"column:mobile;type:varchar(15);default:'';comment:联系方式" json:"mobile"`
|
||||
IDCard string `gorm:"column:id_card;type:varchar(18);default:'';comment:身份证号" json:"id_card"`
|
||||
IDImage string `gorm:"column:id_image;type:text;comment:身份证图片" json:"-"`
|
||||
Industry string `gorm:"column:industry;type:varchar(255);default:'';comment:行业领域" json:"industry"`
|
||||
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;comment:身份证图片" json:"-"`
|
||||
CredentialImage string `gorm:"column:credential_image;type:varchar(255);default:'';comment:资格证书" json:"credential_image"`
|
||||
Examine
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
// ManageAgentIDImage 身份证信息
|
||||
type ManageAgentIDImage struct {
|
||||
Front string `json:"front"`
|
||||
Behind string `json:"behind"`
|
||||
Hold string `json:"hold"`
|
||||
}
|
||||
|
||||
func (m *ManageAgent) TableName() string {
|
||||
@ -47,6 +54,17 @@ func (m *ManageAgent) SetKeywordAttribute(value []string) {
|
||||
m.Keyword = utils.AnyToJSON(value)
|
||||
}
|
||||
|
||||
func (m *ManageAgent) GetIDImageAttribute() *ManageAgentIDImage {
|
||||
out := new(ManageAgentIDImage)
|
||||
_ = json.Unmarshal([]byte(m.IDImage), out)
|
||||
return out
|
||||
}
|
||||
|
||||
func (m *ManageAgent) SetIDImageAttribute(value *ManageAgentIDImage) {
|
||||
_bytes, _ := json.Marshal(value)
|
||||
m.IDImage = string(_bytes)
|
||||
}
|
||||
|
||||
func (m *ManageAgent) GetCredentialImageAttribute() []string {
|
||||
out := make([]string, 0)
|
||||
_ = utils.FromJSON(m.CredentialImage, &out)
|
||||
|
@ -1,32 +1,144 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
GormEngine "github.com/belief428/gorm-engine"
|
||||
"github.com/belief428/gorm-engine/engine"
|
||||
"github.com/belief428/gorm-engine/logic"
|
||||
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/serve/orm/logic"
|
||||
"SciencesServer/utils"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
_db *gorm.DB
|
||||
)
|
||||
// PPatent 专利信息数据模型
|
||||
type PPatent struct {
|
||||
Model
|
||||
Kind string `gorm:"column:kind;type:tinyint(1);default:0;comment:专利类型" json:"kind"`
|
||||
Title string `gorm:"column:title;type:varchar(255);default:'';comment:名称标题" json:"title"`
|
||||
FileUrl string `gorm:"column:file_url;type:varchar(255);default:'';comment:文件地址" json:"file_url"`
|
||||
ApplyCode string `gorm:"column:apply_code;type:varchar(50);default:'';comment:申请号" json:"apply_code"`
|
||||
ApplyAt string `gorm:"column:apply_at;type:varchar(30);default:'';comment:申请日" json:"apply_at"`
|
||||
OpenCode string `gorm:"column:open_code;type:varchar(50);default:'';comment:公开(公告)号" json:"open_code"`
|
||||
OpenAt string `gorm:"column:open_at;type:varchar(30);default:'';comment:公开(公告)日" json:"open_at"`
|
||||
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;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:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func mysql() logic.IEngine {
|
||||
return &engine.MConfig{
|
||||
User: "appuser", Password: "ABCabc01!",
|
||||
Host: "192.168.99.188", Port: 3306,
|
||||
DBName: "iot", Parameters: "charset=utf8mb4,utf8&parseTime=True&loc=Asia%2FShanghai",
|
||||
func (m *PPatent) TableName() string {
|
||||
return "manage_patent"
|
||||
}
|
||||
|
||||
func mysql() *gorm.DB {
|
||||
instance := orm.NewInstance(
|
||||
orm.WithDebug(true),
|
||||
orm.WithDBMode("mysql"),
|
||||
orm.WithTablePrefix(""),
|
||||
orm.WithSingularTable(false),
|
||||
orm.WithMaxIdleConns(3600),
|
||||
orm.WithMaxOpenConns(2000),
|
||||
orm.WithMaxLifetime(1000),
|
||||
orm.WithMysqlOption(&logic.Mysql{
|
||||
User: "appuser", Password: "ABCabc01!", Host: "192.168.0.188", Port: 3306,
|
||||
DBName: "sciences", Parameters: "charset=utf8mb4,utf8&parseTime=True&loc=Local",
|
||||
}),
|
||||
).Init()
|
||||
return instance.Engine
|
||||
}
|
||||
|
||||
func sqlite() *gorm.DB {
|
||||
instance := orm.NewInstance(
|
||||
orm.WithDebug(true),
|
||||
orm.WithDBMode("sqlite"),
|
||||
orm.WithTablePrefix(""),
|
||||
orm.WithSingularTable(false),
|
||||
orm.WithMaxIdleConns(3600),
|
||||
orm.WithMaxOpenConns(2000),
|
||||
orm.WithMaxLifetime(1000),
|
||||
orm.WithSqliteOption(&logic.Sqlite{Path: "../../../lib",
|
||||
Name: "data.db"}),
|
||||
).Init()
|
||||
return instance.Engine
|
||||
}
|
||||
|
||||
func filter(src string) string {
|
||||
src = utils.ReplaceAllCompile(src, "\t", "")
|
||||
src = utils.ReplaceAllCompile(src, "\n", "")
|
||||
src = strings.TrimLeft(src, " ")
|
||||
src = strings.TrimRight(src, " ")
|
||||
return src
|
||||
}
|
||||
|
||||
func TestRecoveryPatent(t *testing.T) {
|
||||
src := make([]*PPatent, 0)
|
||||
sqlite := sqlite()
|
||||
|
||||
var err error
|
||||
|
||||
page := 1
|
||||
|
||||
mysql := mysql()
|
||||
|
||||
mSysPatent := new(SysPatent)
|
||||
|
||||
now := time.Now()
|
||||
|
||||
limit := 100
|
||||
|
||||
for {
|
||||
if err = sqlite.Offset((page - 1) * limit).Limit(limit).Find(&src).Error; err != nil {
|
||||
t.Error("Sqlite:" + err.Error())
|
||||
return
|
||||
}
|
||||
if len(src) <= 0 {
|
||||
t.Log("执行结束")
|
||||
return
|
||||
}
|
||||
t.Log(len(src))
|
||||
out := make([]*SysPatent, 0)
|
||||
|
||||
for _, v := range src {
|
||||
kind := SysParentKindForInvent
|
||||
|
||||
if v.Kind == "实用新型" {
|
||||
kind = SysParentKindForNewPractical
|
||||
} else if v.Kind == "外观设计" {
|
||||
kind = SysParentKindForDesign
|
||||
}
|
||||
data := &SysPatent{
|
||||
Kind: kind,
|
||||
Title: v.Title,
|
||||
FileUrl: v.FileUrl,
|
||||
ApplyCode: v.ApplyCode,
|
||||
ApplyAt: v.ApplyAt,
|
||||
OpenCode: v.OpenCode,
|
||||
OpenAt: v.OpenAt,
|
||||
ApplyName: filter(v.ApplyName),
|
||||
ApplyAddress: filter(v.ApplyAddress),
|
||||
Inventor: filter(v.Inventor),
|
||||
Description: filter(v.Description),
|
||||
PrincipalClaim: filter(v.PrincipalClaim),
|
||||
IPCCode: v.IPCCode,
|
||||
Shelf: Shelf{ShelfStatus: 1},
|
||||
ModelAt: ModelAt{
|
||||
CreatedAt: now, UpdatedAt: now,
|
||||
},
|
||||
}
|
||||
out = append(out, data)
|
||||
}
|
||||
src = make([]*PPatent, 0)
|
||||
page++
|
||||
|
||||
if err = mysql.Table(mSysPatent.TableName()).Create(out).Error; err != nil {
|
||||
t.Error("Mysql:" + err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func _init() {
|
||||
_db = GormEngine.NewEngine()(1, &GormEngine.EngineConfig{
|
||||
Debug: true,
|
||||
TablePrefix: "",
|
||||
Complex: false,
|
||||
MaxIdleConns: 50,
|
||||
MaxOpenConns: 150,
|
||||
MaxLifetime: 3600,
|
||||
}).Start(mysql())
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ type SysPatent struct {
|
||||
ApplyAt string `gorm:"column:apply_at;type:varchar(30);default:'';comment:申请日" json:"apply_at"`
|
||||
OpenCode string `gorm:"column:open_code;type:varchar(50);default:'';comment:公开(公告)号" json:"open_code"`
|
||||
OpenAt string `gorm:"column:open_at;type:varchar(30);default:'';comment:公开(公告)日" json:"open_at"`
|
||||
ApplyName string `gorm:"column:apply_name;type:varchar(100);default:'';comment:申请(专利权)人" json:"apply_name"`
|
||||
ApplyName string `gorm:"column:apply_name;type:varchar(255);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"`
|
||||
Inventor string `gorm:"column:inventor;type:varchar(255);default:'';comment:发明人" json:"inventor"`
|
||||
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"`
|
||||
|
Reference in New Issue
Block a user