clear:formatting code
This commit is contained in:
1 parent
426cec1b62
commit
8c554d7ee7
21 files changed
+35
-51
No files matched your search
@@ -7,3 +7,4 @@ temp/
|
|||||||
vendor
|
vendor
|
||||||
config/settings.dev.yml
|
config/settings.dev.yml
|
||||||
go-admin
|
go-admin
|
||||||
|
middleware/demo.go
|
||||||
@@ -47,7 +47,6 @@ func ServerInfo(c *gin.Context) {
|
|||||||
cpuDic := make(map[string]interface{}, 0)
|
cpuDic := make(map[string]interface{}, 0)
|
||||||
cpuDic["cpuNum"], _ = cpu.Counts(false)
|
cpuDic["cpuNum"], _ = cpu.Counts(false)
|
||||||
|
|
||||||
|
|
||||||
app.Custum(c, gin.H{
|
app.Custum(c, gin.H{
|
||||||
"code": 200,
|
"code": 200,
|
||||||
"os": osDic,
|
"os": osDic,
|
||||||
|
|||||||
@@ -145,5 +145,3 @@ func DeleteConfig(c *gin.Context) {
|
|||||||
tools.HasError(err, "修改失败", 500)
|
tools.HasError(err, "修改失败", 500)
|
||||||
app.OK(c, result, msg.DeletedSuccess)
|
app.OK(c, result, msg.DeletedSuccess)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -33,7 +33,6 @@ $(function(){
|
|||||||
</html>
|
</html>
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|
||||||
func HelloWorld(c *gin.Context) {
|
func HelloWorld(c *gin.Context) {
|
||||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||||
c.String(200, INDEX)
|
c.String(200, INDEX)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package database
|
package database
|
||||||
|
|
||||||
|
|
||||||
func Setup(driver string) {
|
func Setup(driver string) {
|
||||||
dbType := driver
|
dbType := driver
|
||||||
if dbType == "mysql" {
|
if dbType == "mysql" {
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import (
|
|||||||
|
|
||||||
var RequestLogger = &logrus.Entry{}
|
var RequestLogger = &logrus.Entry{}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// TODO: requestLogger log format
|
// TODO: requestLogger log format
|
||||||
// RequestLogger = logrus.WithFields(logrus.Fields{"request_id": request_id, "user_ip": user_ip})
|
// RequestLogger = logrus.WithFields(logrus.Fields{"request_id": request_id, "user_ip": user_ip})
|
||||||
|
|||||||
@@ -153,7 +153,6 @@ func RAMCheck(c *gin.Context) {
|
|||||||
text = "WARNING"
|
text = "WARNING"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
app.Custum(c, gin.H{
|
app.Custum(c, gin.H{
|
||||||
"code": 200,
|
"code": 200,
|
||||||
"msg": text,
|
"msg": text,
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ type SysUserB struct {
|
|||||||
BaseModel
|
BaseModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type SysUser struct {
|
type SysUser struct {
|
||||||
SysUserId
|
SysUserId
|
||||||
SysUserB
|
SysUserB
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ e = some(where (p.eft == allow))
|
|||||||
m = r.sub == p.sub && (keyMatch2(r.obj, p.obj) || keyMatch(r.obj, p.obj)) && (r.act == p.act || p.act == "*")
|
m = r.sub == p.sub && (keyMatch2(r.obj, p.obj) || keyMatch(r.obj, p.obj)) && (r.act == p.act || p.act == "*")
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func Setup() {
|
func Setup() {
|
||||||
Apter, err := gormAdapter.NewAdapterByDB(global.Eloquent)
|
Apter, err := gormAdapter.NewAdapterByDB(global.Eloquent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -9,5 +9,3 @@ var (
|
|||||||
Warning *log.Logger
|
Warning *log.Logger
|
||||||
Error *log.Logger
|
Error *log.Logger
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -7,8 +7,6 @@ import (
|
|||||||
jwt "go-admin/pkg/jwtauth"
|
jwt "go-admin/pkg/jwtauth"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 路由示例
|
// 路由示例
|
||||||
func InitExamplesRouter(r *gin.Engine, authMiddleware *jwt.GinJWTMiddleware) *gin.Engine {
|
func InitExamplesRouter(r *gin.Engine, authMiddleware *jwt.GinJWTMiddleware) *gin.Engine {
|
||||||
|
|
||||||
@@ -36,6 +34,3 @@ func examplesCheckRoleRouter(r *gin.Engine, authMiddleware *jwtauth.GinJWTMiddle
|
|||||||
|
|
||||||
// {{认证路由自动补充在此处请勿删除}}
|
// {{认证路由自动补充在此处请勿删除}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+33
-17
@@ -7,9 +7,11 @@
|
|||||||
{{- if ($x) -}}
|
{{- if ($x) -}}
|
||||||
<el-form-item label="{{.ColumnComment}}" prop="{{.JsonField}}">
|
<el-form-item label="{{.ColumnComment}}" prop="{{.JsonField}}">
|
||||||
{{if eq .DictType "" -}}
|
{{if eq .DictType "" -}}
|
||||||
<el-input v-model="queryParams.{{.JsonField}}" placeholder="请输入{{.ColumnComment}}" clearable size="small" @keyup.enter.native="handleQuery" />
|
<el-input v-model="queryParams.{{.JsonField}}" placeholder="请输入{{.ColumnComment}}" clearable
|
||||||
|
size="small" @keyup.enter.native="handleQuery"/>
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
<el-select v-model="queryParams.{{.JsonField}}" placeholder="{{$tableComment}}{{.ColumnComment}}" clearable size="small">
|
<el-select v-model="queryParams.{{.JsonField}}"
|
||||||
|
placeholder="{{$tableComment}}{{.ColumnComment}}" clearable size="small">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in {{.JsonField}}Options"
|
v-for="dict in {{.JsonField}}Options"
|
||||||
:key="dict.dictValue"
|
:key="dict.dictValue"
|
||||||
@@ -35,7 +37,8 @@
|
|||||||
icon="el-icon-plus"
|
icon="el-icon-plus"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="handleAdd"
|
@click="handleAdd"
|
||||||
>新增</el-button>
|
>新增
|
||||||
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
@@ -45,7 +48,8 @@
|
|||||||
size="mini"
|
size="mini"
|
||||||
:disabled="single"
|
:disabled="single"
|
||||||
@click="handleUpdate"
|
@click="handleUpdate"
|
||||||
>修改</el-button>
|
>修改
|
||||||
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
@@ -55,7 +59,8 @@
|
|||||||
size="mini"
|
size="mini"
|
||||||
:disabled="multiple"
|
:disabled="multiple"
|
||||||
@click="handleDelete"
|
@click="handleDelete"
|
||||||
>删除</el-button>
|
>删除
|
||||||
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
@@ -65,14 +70,16 @@
|
|||||||
{{- $x := .IsList -}}
|
{{- $x := .IsList -}}
|
||||||
{{- if ($x) }}
|
{{- if ($x) }}
|
||||||
{{- if ne .DictType "" -}}
|
{{- if ne .DictType "" -}}
|
||||||
<el-table-column label="{{.ColumnComment}}" align="center" prop="{{.JsonField}}" :formatter="{{.JsonField}}Format" width="100">
|
<el-table-column label="{{.ColumnComment}}" align="center" prop="{{.JsonField}}"
|
||||||
|
:formatter="{{.JsonField}}Format" width="100">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
{{ "{{" }} {{.JsonField}}Format(scope.row) {{"}}"}}
|
{{ "{{" }} {{.JsonField}}Format(scope.row) {{"}}"}}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- if eq .DictType "" -}}
|
{{- if eq .DictType "" -}}
|
||||||
<el-table-column label="{{.ColumnComment}}" align="center" prop="{{.JsonField}}" :show-overflow-tooltip="true" />
|
<el-table-column label="{{.ColumnComment}}" align="center" prop="{{.JsonField}}"
|
||||||
|
:show-overflow-tooltip="true"/>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@@ -85,14 +92,16 @@
|
|||||||
type="text"
|
type="text"
|
||||||
icon="el-icon-edit"
|
icon="el-icon-edit"
|
||||||
@click="handleUpdate(scope.row)"
|
@click="handleUpdate(scope.row)"
|
||||||
>修改</el-button>
|
>修改
|
||||||
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
v-permisaction="['{{.PackageName}}:{{.ModuleName}}:remove']"
|
v-permisaction="['{{.PackageName}}:{{.ModuleName}}:remove']"
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
icon="el-icon-delete"
|
icon="el-icon-delete"
|
||||||
@click="handleDelete(scope.row)"
|
@click="handleDelete(scope.row)"
|
||||||
>删除</el-button>
|
>删除
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@@ -120,9 +129,11 @@
|
|||||||
{{- else }}
|
{{- else }}
|
||||||
<el-form-item label="{{.ColumnComment}}" prop="{{.JsonField}}">
|
<el-form-item label="{{.ColumnComment}}" prop="{{.JsonField}}">
|
||||||
{{ if eq "input" .HtmlType -}}
|
{{ if eq "input" .HtmlType -}}
|
||||||
<el-input v-model="form.{{.JsonField}}" placeholder="{{.ColumnComment}}" {{if eq .IsEdit "false" -}}:disabled="isEdit" {{- end}}/>
|
<el-input v-model="form.{{.JsonField}}" placeholder="{{.ColumnComment}}"
|
||||||
|
{{if eq .IsEdit "false" -}}:disabled="isEdit" {{- end}}/>
|
||||||
{{- else if eq "select" .HtmlType -}}
|
{{- else if eq "select" .HtmlType -}}
|
||||||
<el-select v-model="form.{{.JsonField}}" {{if eq .IsEdit "false" -}} :disabled="isEdit" {{- end }}>
|
<el-select
|
||||||
|
v-model="form.{{.JsonField}}" {{if eq .IsEdit "false" -}} :disabled="isEdit" {{- end }}>
|
||||||
<el-option label="demo1" value="demo1"/>
|
<el-option label="demo1" value="demo1"/>
|
||||||
<el-option label="demo2" value="demo2"/>
|
<el-option label="demo2" value="demo2"/>
|
||||||
</el-select>
|
</el-select>
|
||||||
@@ -149,7 +160,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { list{{.ClassName}}, get{{.ClassName}}, del{{.ClassName}}, add{{.ClassName}}, update{{.ClassName}} } from '@/api/{{.PackageName}}'
|
import {add, del, get, list, update} from '@/api/'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Config',
|
name: 'Config',
|
||||||
@@ -184,13 +195,15 @@
|
|||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
{{ range .Columns }}
|
{{ range .Columns }}
|
||||||
{{- if (.IsQuery) -}}
|
{{- if (.IsQuery) -}}
|
||||||
{{.JsonField}}:undefined,
|
{{.JsonField}}:
|
||||||
|
undefined,
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
},
|
},
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {
|
form: {
|
||||||
},
|
}
|
||||||
|
,
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
{{- range .Columns -}}
|
{{- range .Columns -}}
|
||||||
@@ -243,7 +256,8 @@
|
|||||||
{{- else if eq .GoField "UpdateBy" -}}
|
{{- else if eq .GoField "UpdateBy" -}}
|
||||||
{{- else if eq .GoField "CreateBy" -}}
|
{{- else if eq .GoField "CreateBy" -}}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{.JsonField}}: undefined,
|
{{.JsonField}}:
|
||||||
|
undefined,
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@@ -285,7 +299,8 @@
|
|||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
this.reset()
|
this.reset()
|
||||||
const {{.PkJsonField}} = row.{{.PkJsonField}} || this.ids
|
const {{.PkJsonField}} =
|
||||||
|
row.{{.PkJsonField}} || this.ids
|
||||||
get{{.ClassName}}({{.PkJsonField}}).then(response => {
|
get{{.ClassName}}({{.PkJsonField}}).then(response => {
|
||||||
this.form = response.data
|
this.form = response.data
|
||||||
this.open = true
|
this.open = true
|
||||||
@@ -333,7 +348,8 @@
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.getList()
|
this.getList()
|
||||||
this.msgSuccess('删除成功')
|
this.msgSuccess('删除成功')
|
||||||
}).catch(function() {})
|
}).catch(function () {
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func TestGoModelTemplate(t *testing.T) {
|
func TestGoModelTemplate(t *testing.T) {
|
||||||
t1, err := template.ParseFiles("model.go.template")
|
t1, err := template.ParseFiles("model.go.template")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ type PageResponse struct {
|
|||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (res *Response) ReturnOK() *Response {
|
func (res *Response) ReturnOK() *Response {
|
||||||
res.Code = 200
|
res.Code = 200
|
||||||
return res
|
return res
|
||||||
@@ -36,11 +35,7 @@ func (res *Response) ReturnError(code int) *Response {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (res *PageResponse) ReturnOK() *PageResponse {
|
func (res *PageResponse) ReturnOK() *PageResponse {
|
||||||
res.Code = 200
|
res.Code = 200
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -20,7 +20,6 @@ type configJsonBody struct {
|
|||||||
DriverDigit *base64Captcha.DriverDigit
|
DriverDigit *base64Captcha.DriverDigit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func DriverStringFunc() (id, b64s string, err error) {
|
func DriverStringFunc() (id, b64s string, err error) {
|
||||||
e := configJsonBody{}
|
e := configJsonBody{}
|
||||||
e.Id = uuid.New().String()
|
e.Id = uuid.New().String()
|
||||||
@@ -30,7 +29,6 @@ func DriverStringFunc() (id, b64s string, err error) {
|
|||||||
return cap.Generate()
|
return cap.Generate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func DriverDigitFunc() (id, b64s string, err error) {
|
func DriverDigitFunc() (id, b64s string, err error) {
|
||||||
e := configJsonBody{}
|
e := configJsonBody{}
|
||||||
e.Id = uuid.New().String()
|
e.Id = uuid.New().String()
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ var cfgLog *viper.Viper
|
|||||||
var cfgSsl *viper.Viper
|
var cfgSsl *viper.Viper
|
||||||
var cfgGen *viper.Viper
|
var cfgGen *viper.Viper
|
||||||
|
|
||||||
|
|
||||||
//载入配置文件
|
//载入配置文件
|
||||||
func ConfigSetup(path string) {
|
func ConfigSetup(path string) {
|
||||||
viper.SetConfigFile(path)
|
viper.SetConfigFile(path)
|
||||||
@@ -25,7 +24,6 @@ func ConfigSetup(path string) {
|
|||||||
log.Fatal(fmt.Sprintf("Read config file fail: %s", err.Error()))
|
log.Fatal(fmt.Sprintf("Read config file fail: %s", err.Error()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Replace environment variables
|
//Replace environment variables
|
||||||
err = viper.ReadConfig(strings.NewReader(os.ExpandEnv(string(content))))
|
err = viper.ReadConfig(strings.NewReader(os.ExpandEnv(string(content))))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -69,7 +67,6 @@ func ConfigSetup(path string) {
|
|||||||
GenConfig = InitGen(cfgGen)
|
GenConfig = InitGen(cfgGen)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func SetConfig(configPath string, key string, value interface{}) {
|
func SetConfig(configPath string, key string, value interface{}) {
|
||||||
viper.AddConfigPath(configPath)
|
viper.AddConfigPath(configPath)
|
||||||
viper.Set(key, value)
|
viper.Set(key, value)
|
||||||
|
|||||||
@@ -19,4 +19,3 @@ func InitDatabase(cfg *viper.Viper) *Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var DatabaseConfig = new(Database)
|
var DatabaseConfig = new(Database)
|
||||||
|
|
||||||
@@ -119,6 +119,7 @@ type ReplaceHelper struct {
|
|||||||
OldText string //需要替换的文本
|
OldText string //需要替换的文本
|
||||||
NewText string //新的文本
|
NewText string //新的文本
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ReplaceHelper) DoWrok() error {
|
func (h *ReplaceHelper) DoWrok() error {
|
||||||
|
|
||||||
return filepath.Walk(h.Root, h.walkCallback)
|
return filepath.Walk(h.Root, h.walkCallback)
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ func InitLogger() {
|
|||||||
log.FieldKeyLevel: "@level",
|
log.FieldKeyLevel: "@level",
|
||||||
log.FieldKeyMsg: "@message"}})
|
log.FieldKeyMsg: "@message"}})
|
||||||
|
|
||||||
|
|
||||||
switch Mode(config2.ApplicationConfig.Mode) {
|
switch Mode(config2.ApplicationConfig.Mode) {
|
||||||
case ModeDev, ModeTest:
|
case ModeDev, ModeTest:
|
||||||
log.SetOutput(os.Stdout)
|
log.SetOutput(os.Stdout)
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ func StringToInt(e string) (int, error) {
|
|||||||
return strconv.Atoi(e)
|
return strconv.Atoi(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func GetCurrentTimeStr() string {
|
func GetCurrentTimeStr() string {
|
||||||
return time.Now().Format("2006/01/02 15:04:05")
|
return time.Now().Format("2006/01/02 15:04:05")
|
||||||
}
|
}
|
||||||
@@ -26,7 +25,6 @@ func GetCurrentTime() time.Time {
|
|||||||
return time.Now()
|
return time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func StructToJsonStr(e interface{}) (string, error) {
|
func StructToJsonStr(e interface{}) (string, error) {
|
||||||
if b, err := json.Marshal(e); err == nil {
|
if b, err := json.Marshal(e); err == nil {
|
||||||
return string(b), err
|
return string(b), err
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ func IdsStrToIdsIntGroup(key string, c *gin.Context) []int {
|
|||||||
return idsStrToIdsIntGroup(c.Param(key))
|
return idsStrToIdsIntGroup(c.Param(key))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func idsStrToIdsIntGroup(keys string) []int {
|
func idsStrToIdsIntGroup(keys string) []int {
|
||||||
IDS := make([]int, 0)
|
IDS := make([]int, 0)
|
||||||
ids := strings.Split(keys, ",")
|
ids := strings.Split(keys, ",")
|
||||||
|
|||||||
Reference in new issue
Block a user