feat:added dto

This commit is contained in:
zhangwenjian committed 2020-08-29 15:33:44 +08:00
1 parent 33b462217c
commit ce80857d5f
7 files changed
+144 -60

No files matched your search

+13 -12
View File
@@ -30,13 +30,6 @@ func GetSysJobList(c *gin.Context) {
err = c.Bind(&v)
tools.HasError(err, "数据解析失败", 422)
//data.JobId, _ = tools.StringToInt(c.Request.FormValue("jobId"))
//data.JobName = c.Request.FormValue("jobName")
//data.JobGroup = c.Request.FormValue("jobGroup")
//data.CronExpression = c.Request.FormValue("cronExpression")
//data.InvokeTarget = c.Request.FormValue("invokeTarget")
//data.Status, _ = tools.StringToInt(c.Request.FormValue("status"))
data.DataScope = tools.GetUserIdStr(c)
result, count, err := data.GetPage(pageSize, pageIndex, v)
tools.HasError(err, "", -1)
@@ -46,7 +39,10 @@ func GetSysJobList(c *gin.Context) {
func GetSysJob(c *gin.Context) {
var data models.SysJob
data.JobId, _ = tools.StringToInt(c.Param("jobId"))
var v tools.GeneralGetDto
err := c.BindUri(&v)
tools.HasError(err, "", 500)
data.JobId, _ = tools.StringToInt(v.Id)
result, err := data.Get()
tools.HasError(err, "抱歉未找到相关信息", -1)
@@ -79,9 +75,8 @@ func DeleteSysJob(c *gin.Context) {
var v tools.GeneralDelDto
err := c.BindUri(&v)
tools.HasError(err, "", 500)
data.UpdateBy = tools.GetUserIdStr(c)
IDS := tools.IdsStrToIdsIntGroupStr(v.Id)
_, err = data.BatchDelete(IDS)
tools.HasError(err, msg.DeletedFail, 500)
@@ -90,7 +85,10 @@ func DeleteSysJob(c *gin.Context) {
func RemoveJob(c *gin.Context) {
var data models.SysJob
data.JobId, _ = tools.StringToInt(c.Param("jobId"))
var v tools.GeneralDelDto
err := c.BindUri(&v)
tools.HasError(err, "", 500)
data.JobId, _ = tools.StringToInt(v.Id)
result, err := data.Get()
tools.HasError(err, "", 500)
cn := jobs.Remove(result.EntryId)
@@ -109,7 +107,10 @@ func RemoveJob(c *gin.Context) {
func StartJob(c *gin.Context) {
var data models.SysJob
data.JobId, _ = tools.StringToInt(c.Param("jobId"))
var v tools.GeneralGetDto
err := c.BindUri(&v)
tools.HasError(err, "", 500)
data.JobId, _ = tools.StringToInt(v.Id)
result, err := data.Get()
tools.HasError(err, "", 500)
if result.JobType == 1 {
+11
View File
@@ -30,6 +30,8 @@ func Preview(c *gin.Context) {
tools2.HasError(err, "", -1)
t5, err := template.ParseFiles("template/router.go.template")
tools2.HasError(err, "", -1)
t6, err := template.ParseFiles("template/dto.go.template")
tools2.HasError(err, "", -1)
tab, _ := table.Get()
var b1 bytes.Buffer
err = t1.Execute(&b1, tab)
@@ -41,6 +43,8 @@ func Preview(c *gin.Context) {
err = t4.Execute(&b4, tab)
var b5 bytes.Buffer
err = t5.Execute(&b5, tab)
var b6 bytes.Buffer
err = t6.Execute(&b6, tab)
mp := make(map[string]interface{})
mp["template/model.go.template"] = b1.String()
@@ -48,6 +52,7 @@ func Preview(c *gin.Context) {
mp["template/js.go.template"] = b3.String()
mp["template/vue.go.template"] = b4.String()
mp["template/router.go.template"] = b5.String()
mp["template/dto.go.template"] = b6.String()
var res app.Response
res.Data = mp
@@ -90,10 +95,13 @@ func GenCode(c *gin.Context) {
tools2.HasError(err, "", -1)
t5, err := template.ParseFiles("template/vue.go.template")
tools2.HasError(err, "", -1)
t6, err := template.ParseFiles("template/dto.go.template")
tools2.HasError(err, "", -1)
_ = tools2.PathCreate("./apis/" + tab.ModuleName + "/")
_ = tools2.PathCreate("./models/")
_ = tools2.PathCreate("./router/")
_ = tools2.PathCreate("./dto/")
_ = tools2.PathCreate(config.GenConfig.FrontPath + "/api/")
_ = tools2.PathCreate(config.GenConfig.FrontPath + "/views/" + tab.PackageName)
@@ -107,11 +115,14 @@ func GenCode(c *gin.Context) {
err = t4.Execute(&b4, tab)
var b5 bytes.Buffer
err = t5.Execute(&b5, tab)
var b6 bytes.Buffer
err = t6.Execute(&b6, tab)
tools2.FileCreate(b1, "./models/"+tab.PackageName+".go")
tools2.FileCreate(b2, "./apis/"+tab.ModuleName+"/"+tab.PackageName+".go")
tools2.FileCreate(b3, "./router/"+tab.PackageName+".go")
tools2.FileCreate(b4, config.GenConfig.FrontPath+"/api/"+tab.PackageName+".js")
tools2.FileCreate(b5, config.GenConfig.FrontPath+"/views/"+tab.PackageName+"/index.vue")
tools2.FileCreate(b5, "./dto/"+tab.PackageName+".go")
helper := tools2.ReplaceHelper{
Root: "./router/router.go",