feat:完善项目管理
This commit is contained in:
@ -235,3 +235,50 @@ func (*Manage) ResearchVisit(c *gin.Context) {
|
|||||||
Visit(form.Page, form.PageSize)
|
Visit(form.Page, form.PageSize)
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*Manage) AgentCompany(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
Name string `json:"name" form:"name"`
|
||||||
|
api.PageForm
|
||||||
|
}{}
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := manage.NewAgent()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||||
|
Company(form.Name, form.Page, form.PageSize)
|
||||||
|
api.APIResponse(err, data)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Manage) AgentCompanyAdd(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
Name string `json:"name" form:"name"`
|
||||||
|
Industrys []string `json:"industrys" form:"industrys"`
|
||||||
|
}{}
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := manage.NewAgent()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||||
|
Form(0, form.Name, form.Industrys)
|
||||||
|
api.APIResponse(err)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Manage) AgentCompanyEdit(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
api.IDStringForm
|
||||||
|
Name string `json:"name" form:"name"`
|
||||||
|
Industrys []string `json:"industrys" form:"industrys"`
|
||||||
|
}{}
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := manage.NewAgent()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||||
|
Form(form.Convert(), form.Name, form.Industrys)
|
||||||
|
api.APIResponse(err)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Manage) AgentCompanyDelete(c *gin.Context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
129
app/api/enterprise/controller/manage/agent.go
Normal file
129
app/api/enterprise/controller/manage/agent.go
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
package manage
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/enterprise/model"
|
||||||
|
"SciencesServer/app/basic/controller"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/session"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Agent struct {
|
||||||
|
*session.Enterprise
|
||||||
|
local string
|
||||||
|
}
|
||||||
|
|
||||||
|
type AgentHandle func(session *session.Enterprise, local string) *Agent
|
||||||
|
|
||||||
|
type (
|
||||||
|
// AgentCompany 经纪人公司信息
|
||||||
|
AgentCompany struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Company 公司信息
|
||||||
|
func (c *Agent) Company(name string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
|
mUserAgent := model.NewUserAgent()
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mUserAgent.UserAgent, []string{"id", "agent_id"},
|
||||||
|
model2.NewWhere("uid", c.UID), model2.NewWhere("invalid_status", model2.InvalidStatusForNot))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if !isExist {
|
||||||
|
return nil, errors.New("操作错误,无权限操作")
|
||||||
|
}
|
||||||
|
mManageAgentCompany := model.NewManageAgentCompany()
|
||||||
|
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
out := make([]*model.ManageAgentCompanyInfo, 0)
|
||||||
|
|
||||||
|
where := []*model2.ModelWhere{model2.NewWhere("c.agent_id", mUserAgent.ID)}
|
||||||
|
|
||||||
|
if name != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("c.name", name))
|
||||||
|
}
|
||||||
|
if out, err = mManageAgentCompany.Company(page, pageSize, &count, where...); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*AgentCompany, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &AgentCompany{ID: v.GetEncodeID()})
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Form 数据操作
|
||||||
|
func (c *Agent) Form(id uint64, name string, industrys []string) error {
|
||||||
|
mUserAgent := model.NewUserAgent()
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mUserAgent.UserAgent, []string{"id", "agent_id"},
|
||||||
|
model2.NewWhere("uid", c.UID), model2.NewWhere("invalid_status", model2.InvalidStatusForNot))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("操作错误,无权限操作")
|
||||||
|
}
|
||||||
|
mManageAgentCompany := model.NewManageAgentCompany()
|
||||||
|
|
||||||
|
if id > 0 {
|
||||||
|
mManageAgentCompany.ID = id
|
||||||
|
|
||||||
|
if isExist, err = model2.FirstField(mManageAgentCompany.ManageAgentCompany, []string{"id", "agent_id",
|
||||||
|
"name", "created_at"}); err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("操作错误,无企业信息")
|
||||||
|
}
|
||||||
|
if mUserAgent.AgentID != mManageAgentCompany.AgentID {
|
||||||
|
return errors.New("无权限操作")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mManageAgentCompany.Name = name
|
||||||
|
mManageAgentCompany.SetIndustryAttribute(industrys)
|
||||||
|
|
||||||
|
if mManageAgentCompany.ID > 0 {
|
||||||
|
return model2.Updates(mManageAgentCompany.ManageAgentCompany, mManageAgentCompany.ManageAgentCompany)
|
||||||
|
}
|
||||||
|
return model2.Create(mManageAgentCompany.ManageAgentCompany)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete 删除操作
|
||||||
|
func (c *Agent) Delete(id uint64) error {
|
||||||
|
mUserAgent := model.NewUserAgent()
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mUserAgent.UserAgent, []string{"id", "agent_id"},
|
||||||
|
model2.NewWhere("uid", c.UID), model2.NewWhere("invalid_status", model2.InvalidStatusForNot))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("操作错误,无权限操作")
|
||||||
|
}
|
||||||
|
mManageAgentCompany := model.NewManageAgentCompany()
|
||||||
|
mManageAgentCompany.ID = id
|
||||||
|
|
||||||
|
if isExist, err = model2.FirstField(mManageAgentCompany.ManageAgentCompany, []string{"id", "agent_id",
|
||||||
|
"name", "created_at"}); err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("操作错误,无企业信息")
|
||||||
|
}
|
||||||
|
if mUserAgent.AgentID != mManageAgentCompany.AgentID {
|
||||||
|
return errors.New("无权限操作")
|
||||||
|
}
|
||||||
|
return model2.Delete(mManageAgentCompany.ManageAgentCompany)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAgent() AgentHandle {
|
||||||
|
return func(session *session.Enterprise, local string) *Agent {
|
||||||
|
return &Agent{
|
||||||
|
Enterprise: session,
|
||||||
|
local: local,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -73,7 +73,7 @@ func (c *Research) Laboratory(title string, page, pageSize int) (*controller.Ret
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Visit 访问记录
|
// Visit 访问记录
|
||||||
func (c *Research) Visit(page, pageSize int) (interface{}, error) {
|
func (c *Research) Visit(page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
// 获取当前科研机构下所有的专家人员
|
// 获取当前科研机构下所有的专家人员
|
||||||
mUserResearch := model.NewUserResearch()
|
mUserResearch := model.NewUserResearch()
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ func (m *ActivityInstance) Joins(page, pageSize int, count *int64, where ...*mod
|
|||||||
Where("j.status = ?", model.ActivityJoinStatusForSuccess)
|
Where("j.status = ?", model.ActivityJoinStatusForSuccess)
|
||||||
|
|
||||||
if len(where) > 0 {
|
if len(where) > 0 {
|
||||||
for _, v := range where {
|
` for _, v := range where {
|
||||||
db = db.Where(v.Condition, v.Value)
|
db = db.Where(v.Condition, v.Value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ func (m *ActivityInstance) Joins(page, pageSize int, count *int64, where ...*mod
|
|||||||
if err := db.Order("j.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
if err := db.Order("j.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return out, nil
|
return out, nil`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewActivityInstance() *ActivityInstance {
|
func NewActivityInstance() *ActivityInstance {
|
||||||
|
39
app/api/enterprise/model/manage_agent_company.go
Normal file
39
app/api/enterprise/model/manage_agent_company.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/serve/orm"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ManageAgentCompany struct {
|
||||||
|
*model.ManageAgentCompany
|
||||||
|
}
|
||||||
|
|
||||||
|
type ManageAgentCompanyInfo struct {
|
||||||
|
*model.ManageAgentCompany
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ManageAgentCompany) Company(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageAgentCompanyInfo, error) {
|
||||||
|
db := orm.GetDB().Table(m.TableName() + " AS c").
|
||||||
|
Joins(fmt.Sprintf(""))
|
||||||
|
|
||||||
|
if len(where) > 0 {
|
||||||
|
for _, v := range where {
|
||||||
|
db = db.Where(v.Condition, v.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out := make([]*ManageAgentCompanyInfo, 0)
|
||||||
|
|
||||||
|
if err := db.Count(count).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := db.Order("c.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewManageAgentCompany() *ManageAgentCompany {
|
||||||
|
return &ManageAgentCompany{model.NewManageAgentCompany()}
|
||||||
|
}
|
@ -1,11 +1,45 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "SciencesServer/app/common/model"
|
import (
|
||||||
|
"SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/serve/orm"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type ManageCompany struct {
|
type ManageCompany struct {
|
||||||
*model.ManageCompany
|
*model.ManageCompany
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ManageCompanyInfo 公司信息,包含公司下需求信息
|
||||||
|
type ManageCompanyInfo struct {
|
||||||
|
model.Model
|
||||||
|
Name string `json:"name"`
|
||||||
|
SettledAt time.Time `json:"settled_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ManageCompany) Company(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageCompanyInfo, error) {
|
||||||
|
// TODO:未完成功能
|
||||||
|
db := orm.GetDB().Table(m.TableName()+" AS c").
|
||||||
|
Select("c.id", "c.name", "c.industry", "c.examine_at AS settled_at").
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT * FROM %s AS u_c)"))
|
||||||
|
|
||||||
|
if len(where) > 0 {
|
||||||
|
for _, v := range where {
|
||||||
|
db = db.Where(v.Condition, v.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out := make([]*ManageCompanyInfo, 0)
|
||||||
|
|
||||||
|
if err := db.Count(count).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := db.Order("c.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
func NewManageCompany() *ManageCompany {
|
func NewManageCompany() *ManageCompany {
|
||||||
return &ManageCompany{model.NewManageCompany()}
|
return &ManageCompany{model.NewManageCompany()}
|
||||||
}
|
}
|
||||||
|
@ -1 +1,7 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
|
type Index struct{}
|
||||||
|
|
||||||
|
func (*Index) Instance() {
|
||||||
|
|
||||||
|
}
|
||||||
|
31
app/common/model/manage_agent_company.go
Normal file
31
app/common/model/manage_agent_company.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "SciencesServer/utils"
|
||||||
|
|
||||||
|
// ManageAgentCompany 经纪人服务公司数据模型
|
||||||
|
type ManageAgentCompany struct {
|
||||||
|
Model
|
||||||
|
AgentID uint64 `gorm:"column:agent_id;type:int(11);default:0;comment:经纪人模型ID" json:"-"`
|
||||||
|
Name string `gorm:"column:name;type:varchar(100);default:'';comment:公司名称" json:"name"`
|
||||||
|
Industry string `gorm:"column:industry;type:varchar(255);default:'';comment:行业领域" json:"-"`
|
||||||
|
ModelDeleted
|
||||||
|
ModelAt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ManageAgentCompany) TableName() string {
|
||||||
|
return "manage_agent_company"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ManageAgentCompany) GetIndustryAttribute() []string {
|
||||||
|
out := make([]string, 0)
|
||||||
|
_ = utils.FromJSON(m.Industry, &out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ManageAgentCompany) SetIndustryAttribute(value []string) {
|
||||||
|
m.Industry = utils.AnyToJSON(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewManageAgentCompany() *ManageAgentCompany {
|
||||||
|
return &ManageAgentCompany{}
|
||||||
|
}
|
22
app/common/model/technology_demand_visit.go
Normal file
22
app/common/model/technology_demand_visit.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// TechnologyDemandVisit 技术需求访问数据模型
|
||||||
|
type TechnologyDemandVisit struct {
|
||||||
|
Model
|
||||||
|
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||||
|
DemandID uint64 `gorm:"column:demand_id;index:idx_demand_visit_demand;type:int(11);default:0;comment:科技产品ID" json:"product_id"`
|
||||||
|
Count int `gorm:"column:count;type:int(8);default:0;comment:浏览次数" json:"count"`
|
||||||
|
Date time.Time `gorm:"column:date;type:datetime;not null;comment:浏览时间" json:"date"`
|
||||||
|
ModelDeleted
|
||||||
|
ModelAt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TechnologyDemandVisit) TableName() string {
|
||||||
|
return "technology_demand_visit"
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewTechnologyDemandVisit() *TechnologyDemandVisit {
|
||||||
|
return &TechnologyDemandVisit{}
|
||||||
|
}
|
Reference in New Issue
Block a user