Compare commits
No commits in common. "main" and "v1.0.00021" have entirely different histories.
main
...
v1.0.00021
|
|
@ -90,7 +90,6 @@
|
|||
<entry key="NewsOne">
|
||||
<value>
|
||||
<set>
|
||||
<option value="file://$PROJECT_DIR$/../gin_test/api/new.go" />
|
||||
<option value="file://$PROJECT_DIR$/../gin_test/req/new.go" />
|
||||
</set>
|
||||
</value>
|
||||
|
|
@ -98,7 +97,6 @@
|
|||
<entry key="NewsSave">
|
||||
<value>
|
||||
<set>
|
||||
<option value="file://$PROJECT_DIR$/../gin_test/api/new.go" />
|
||||
<option value="file://$PROJECT_DIR$/../gin_test/req/new.go" />
|
||||
</set>
|
||||
</value>
|
||||
|
|
@ -201,7 +199,7 @@
|
|||
<entry key="file://$PROJECT_DIR$/database/database.go">
|
||||
<value>
|
||||
<ScannedPath>
|
||||
<option name="lastModified" value="1770258641711" />
|
||||
<option name="lastModified" value="1770100613057" />
|
||||
</ScannedPath>
|
||||
</value>
|
||||
</entry>
|
||||
|
|
@ -342,7 +340,7 @@
|
|||
<entry key="file://$PROJECT_DIR$/valid/valid.go">
|
||||
<value>
|
||||
<ScannedPath>
|
||||
<option name="lastModified" value="1770197737203" />
|
||||
<option name="lastModified" value="1770188345045" />
|
||||
</ScannedPath>
|
||||
</value>
|
||||
</entry>
|
||||
|
|
@ -368,47 +366,6 @@
|
|||
</ScannedPath>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="file://$PROJECT_DIR$/../gin_test/api/home.go">
|
||||
<value>
|
||||
<ScannedPath>
|
||||
<option name="lastModified" value="1770190095707" />
|
||||
</ScannedPath>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="file://$PROJECT_DIR$/../gin_test/api/new.go">
|
||||
<value>
|
||||
<ScannedPath>
|
||||
<option name="lastModified" value="1770191206242" />
|
||||
<option name="schema">
|
||||
<list>
|
||||
<option value="NewsOne" />
|
||||
<option value="NewsSave" />
|
||||
</list>
|
||||
</option>
|
||||
</ScannedPath>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="file://$PROJECT_DIR$/../gin_test/controller/home/houeRouter.go">
|
||||
<value>
|
||||
<ScannedPath>
|
||||
<option name="lastModified" value="1770191001042" />
|
||||
</ScannedPath>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="file://$PROJECT_DIR$/../gin_test/controller/home/index.go">
|
||||
<value>
|
||||
<ScannedPath>
|
||||
<option name="lastModified" value="1770255253603" />
|
||||
</ScannedPath>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="file://$PROJECT_DIR$/../gin_test/controller/home/router.go">
|
||||
<value>
|
||||
<ScannedPath>
|
||||
<option name="lastModified" value="1770190557848" />
|
||||
</ScannedPath>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="file://$PROJECT_DIR$/../gin_test/req/new.go">
|
||||
<value>
|
||||
<ScannedPath>
|
||||
|
|
@ -425,7 +382,7 @@
|
|||
<entry key="file://$PROJECT_DIR$/../gin_test/router/router.go">
|
||||
<value>
|
||||
<ScannedPath>
|
||||
<option name="lastModified" value="1770191024510" />
|
||||
<option name="lastModified" value="1770187001756" />
|
||||
</ScannedPath>
|
||||
</value>
|
||||
</entry>
|
||||
|
|
|
|||
|
|
@ -68,12 +68,10 @@ func mysqlInit() {
|
|||
}
|
||||
|
||||
func sqliteInit() {
|
||||
if !gfile.Exists(dns.String()) {
|
||||
_, err = gfile.Create(dns.String())
|
||||
if err != nil {
|
||||
log.Error("创建数据库文件失败: ", err)
|
||||
return
|
||||
}
|
||||
_, err = gfile.Create(dns.String())
|
||||
if err != nil {
|
||||
log.Error("创建数据库文件失败: ", err)
|
||||
return
|
||||
}
|
||||
Type = sqlite.Open(fmt.Sprintf("%s?cache=shared&mode=rwc&_busy_timeout=10000&_fk=1&_journal=WAL&_sync=FULL", dns.String()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ import (
|
|||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
// ValidToStruct 验证参数并返回结构体
|
||||
func ValidToStruct[T any](c *gin.Context) (object *T) {
|
||||
// ValidAndStruct 验证参数并返回结构体
|
||||
func ValidAndStruct[T any](c *gin.Context) (object *T) {
|
||||
obj := new(T)
|
||||
if err := c.Bind(obj); err != nil {
|
||||
if err := c.BindJSON(obj); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := g.Validator().Data(obj).Run(c); err != nil {
|
||||
|
|
@ -19,10 +19,10 @@ func ValidToStruct[T any](c *gin.Context) (object *T) {
|
|||
return obj
|
||||
}
|
||||
|
||||
// ValidToMap 验证参数并返回结构体
|
||||
func ValidToMap[T any](c *gin.Context) (object map[string]any) {
|
||||
// ValidAndMap 验证参数并返回map
|
||||
func ValidAndMap[T any](c *gin.Context) (object map[string]any) {
|
||||
obj := new(T)
|
||||
if err := c.Bind(obj); err != nil {
|
||||
if err := c.BindJSON(obj); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := g.Validator().Data(obj).Run(c); err != nil {
|
||||
|
|
@ -30,15 +30,3 @@ func ValidToMap[T any](c *gin.Context) (object map[string]any) {
|
|||
}
|
||||
return gconv.Map(obj)
|
||||
}
|
||||
|
||||
// ValidToStructAndMap 验证参数并返回map
|
||||
func ValidToStructAndMap[T any](c *gin.Context) (stru *T, object map[string]any) {
|
||||
obj := new(T)
|
||||
if err := c.Bind(obj); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := g.Validator().Data(obj).Run(c); err != nil {
|
||||
panic(gerror.Current(err).Error())
|
||||
}
|
||||
return obj, gconv.Map(obj)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue