代码拉取完成,页面将自动刷新
package metaentity
import (
"gitee.com/leijmdas/gobase/goconfig/common/base/basedata"
"gitee.com/leijmdas/gobase/goconfig/common/base/basedto"
"gitee.com/leijmdas/gobase/goconfig/common/base/fileutils"
"gitee.com/leijmdas/gobase/goconfig/common/base/stringutils"
"gitee.com/leijmdas/gobase/goconfig/common/golog"
"sort"
"strings"
)
const (
SortByType = "type"
SortByName = "name"
)
type EntityDto struct {
basedto.BaseEntity
EntityName string
Fields []*EntityField
SortBy string
*basedata.DataPath
StrategyType int
CodeDto
}
func NewEntityDto() *EntityDto {
var entity = &EntityDto{
Fields: make([]*EntityField, 0),
DataPath: basedata.FindBeanDataPath(),
SortBy: SortByName,
}
entity.InitProxy(entity)
return entity
}
func (self *EntityDto) ToGoEntityName(trimPre bool) string {
var entityName = self.EntityName
if trimPre {
var index = strings.Split(self.EntityName, "_")[1:]
entityName = strings.Join(index, "_")
}
return stringutils.Case2Camel(entityName)
}
func (self *EntityDto) ToGoEntityNameEs(trimPre bool) string {
return self.ToGoEntityName(trimPre) + "Es"
}
func (self *EntityDto) ToGoEntityNameEsCase(trimPre bool) string {
return stringutils.Camel2Case(self.ToGoEntityNameEs(trimPre))
}
func (self *EntityDto) SortByType() {
self.SortBy = SortByType
}
func (self *EntityDto) SortByName() {
self.SortBy = SortByName
}
func (self *EntityDto) Write2File(file string, code string) error {
golog.Info(file, " EntityDtoc code:", code)
return fileutils.WriteBytesFile(file, []byte(code))
}
func (self *EntityDto) SortFields() {
var funSort = func(i, j int) bool {
return self.Fields[i].SortField(self.SortBy, self.Fields[j].EntityGofield)
}
sort.Slice(self.Fields, funSort)
}
func (self *EntityDto) NewField(fileldName, fieldType string) *EntityField {
return NewEntityField(self.StrategyType, fileldName, fieldType)
}
func (self *EntityDto) AppendField(fileldName, fieldType string) *EntityField {
var field = self.NewField(fileldName, fieldType)
field.ToGo()
self.Fields = append(self.Fields, field)
return field
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。