feat:完善信息
This commit is contained in:
@ -16,6 +16,7 @@ type (
|
|||||||
tenantForm struct {
|
tenantForm struct {
|
||||||
Name string `json:"name" form:"name" binding:"required"` // 名称
|
Name string `json:"name" form:"name" binding:"required"` // 名称
|
||||||
Domain string `json:"domain" form:"domain" binding:"required"` // 域名
|
Domain string `json:"domain" form:"domain" binding:"required"` // 域名
|
||||||
|
IP string `json:"ip" form:"ip" binding:"required"` // IP
|
||||||
Contact string `json:"contact" form:"contact" binding:"required"` // 联系人
|
Contact string `json:"contact" form:"contact" binding:"required"` // 联系人
|
||||||
ContactMobile string `json:"contact_mobile" form:"contact_mobile" binding:"required"` // 联系方式
|
ContactMobile string `json:"contact_mobile" form:"contact_mobile" binding:"required"` // 联系方式
|
||||||
Province string `json:"province" form:"province" binding:"required"` // 省
|
Province string `json:"province" form:"province" binding:"required"` // 省
|
||||||
@ -52,7 +53,7 @@ func (a *Tenant) Form(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := tenant.NewInstance()(api.GetSession()(c).(*session.Admin)).Form(&tenant.InstanceParams{ID: form.Convert(),
|
err := tenant.NewInstance()(api.GetSession()(c).(*session.Admin)).Form(&tenant.InstanceParams{ID: form.Convert(),
|
||||||
Name: form.Name, Domain: form.Domain, Contact: form.Contact, ContactMobile: form.ContactMobile,
|
Name: form.Name, Domain: form.Domain, IP: form.IP, Contact: form.Contact, ContactMobile: form.ContactMobile,
|
||||||
Area: config.Area{Province: form.Province, City: form.City}, Remark: form.Remark,
|
Area: config.Area{Province: form.Province, City: form.City}, Remark: form.Remark,
|
||||||
})
|
})
|
||||||
api.APIResponse(err)(c)
|
api.APIResponse(err)(c)
|
||||||
|
@ -39,7 +39,7 @@ type (
|
|||||||
// InstanceParams 参数信息
|
// InstanceParams 参数信息
|
||||||
InstanceParams struct {
|
InstanceParams struct {
|
||||||
ID uint64
|
ID uint64
|
||||||
Name, Domain, Remark string
|
Name, Domain, IP, Remark string
|
||||||
Area config.Area
|
Area config.Area
|
||||||
Contact, ContactMobile string
|
Contact, ContactMobile string
|
||||||
}
|
}
|
||||||
@ -118,6 +118,9 @@ func (c *Instance) Form(params *InstanceParams) error {
|
|||||||
|
|
||||||
isExist := false
|
isExist := false
|
||||||
|
|
||||||
|
if !utils.ValidateIP(params.IP) {
|
||||||
|
return errors.New("操作错误,IP地址异常")
|
||||||
|
}
|
||||||
if params.ID > 0 {
|
if params.ID > 0 {
|
||||||
mSysTenant.ID = params.ID
|
mSysTenant.ID = params.ID
|
||||||
|
|
||||||
@ -143,6 +146,7 @@ func (c *Instance) Form(params *InstanceParams) error {
|
|||||||
Province: params.Area.Province,
|
Province: params.Area.Province,
|
||||||
City: params.Area.City,
|
City: params.Area.City,
|
||||||
}
|
}
|
||||||
|
mSysTenant.IP = params.IP
|
||||||
mSysTenant.Contact = params.Contact
|
mSysTenant.Contact = params.Contact
|
||||||
mSysTenant.ContactMobile = params.ContactMobile
|
mSysTenant.ContactMobile = params.ContactMobile
|
||||||
mSysTenant.Remark = params.Remark
|
mSysTenant.Remark = params.Remark
|
||||||
|
@ -176,7 +176,16 @@ func (c *DemandService) Delete(id uint64) error {
|
|||||||
} else if !isExist {
|
} else if !isExist {
|
||||||
return errors.New("操作错误,需求服务信息不存在或已被删除")
|
return errors.New("操作错误,需求服务信息不存在或已被删除")
|
||||||
}
|
}
|
||||||
return nil
|
mUserAgent := model.NewUserAgent()
|
||||||
|
|
||||||
|
if isExist, err = model2.FirstField(mUserAgent.UserAgent, []string{"id", "agent_id"}, model2.NewWhere("uid", c.UID)); err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("操作错误,未知的身份信息")
|
||||||
|
} else if mUserAgent.AgentID != mTechnologyDemandService.AgentID {
|
||||||
|
return errors.New("操作错误,无权限操作")
|
||||||
|
}
|
||||||
|
return model2.Delete(mTechnologyDemandService.TechnologyDemandService)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDemandService() DemandServiceHandle {
|
func NewDemandService() DemandServiceHandle {
|
||||||
|
@ -9,6 +9,7 @@ type SysTenant struct {
|
|||||||
ContactMobile string `gorm:"column:contact_mobile;type:varchar(15);default:'';comment:联系方式" json:"contact_mobile"`
|
ContactMobile string `gorm:"column:contact_mobile;type:varchar(15);default:'';comment:联系方式" json:"contact_mobile"`
|
||||||
Area
|
Area
|
||||||
Domain string `gorm:"column:domain;type:varchar(255);default:'';comment:域名地址" json:"domain"`
|
Domain string `gorm:"column:domain;type:varchar(255);default:'';comment:域名地址" json:"domain"`
|
||||||
|
IP string `gorm:"column:ip;type:char(16);default:'';comment:IP地址" json:"ip"`
|
||||||
Remark string `gorm:"column:remark;type:varchar(255);default:'';comment:备注信息" json:"remark"`
|
Remark string `gorm:"column:remark;type:varchar(255);default:'';comment:备注信息" json:"remark"`
|
||||||
ModelDeleted
|
ModelDeleted
|
||||||
ModelAt
|
ModelAt
|
||||||
|
@ -2,9 +2,11 @@ package web
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -58,7 +60,19 @@ func WithFunction(function func(string) (bool, func(r *http.Request))) Option {
|
|||||||
func (this *Web) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (this *Web) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
//remoteUrl, _ := url.Parse("http://192.168.0.147:9000")
|
//remoteUrl, _ := url.Parse("http://192.168.0.147:9000")
|
||||||
fmt.Println(r.Host)
|
fmt.Println(r.Host)
|
||||||
//fmt.Println(r.RequestURI)
|
// 获取
|
||||||
|
ip, _, err := net.SplitHostPort(strings.TrimSpace(r.RemoteAddr))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
_, _ = w.Write([]byte("403: Host forbidden"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
remoteIP := net.ParseIP(ip)
|
||||||
|
|
||||||
|
if remoteIP == nil {
|
||||||
|
_, _ = w.Write([]byte("403: Host forbidden"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if this.function != nil {
|
if this.function != nil {
|
||||||
pass, callback := this.function(r.Host)
|
pass, callback := this.function(r.Host)
|
||||||
|
@ -24,6 +24,8 @@ func TestArrayFlip(t *testing.T) {
|
|||||||
t.Log(a[4])
|
t.Log(a[4])
|
||||||
a = append(a, []int{1, 2, 3, 4, 5, 6, 7, 8, 9}...)
|
a = append(a, []int{1, 2, 3, 4, 5, 6, 7, 8, 9}...)
|
||||||
t.Log(a)
|
t.Log(a)
|
||||||
|
t.Log(len(a))
|
||||||
|
t.Log(cap(a))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestArrayStrings(t *testing.T) {
|
func TestArrayStrings(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user