test
This commit is contained in:
1 parent
677cdb7821
commit
bc648c3f2f
60 files changed
+2319
-550
No files matched your search
@@ -30,12 +30,12 @@ func GetLoginLogList(c *gin.Context) {
|
||||
|
||||
size := c.Request.FormValue("pageSize")
|
||||
if size != "" {
|
||||
pageSize = tools.StrToInt(err, size)
|
||||
pageSize, err = tools.StringToInt(size)
|
||||
}
|
||||
|
||||
index := c.Request.FormValue("pageIndex")
|
||||
if index != "" {
|
||||
pageIndex = tools.StrToInt(err, index)
|
||||
pageIndex, err = tools.StringToInt(index)
|
||||
}
|
||||
|
||||
data.Username = c.Request.FormValue("username")
|
||||
|
||||
@@ -30,12 +30,12 @@ func GetOperLogList(c *gin.Context) {
|
||||
|
||||
size := c.Request.FormValue("pageSize")
|
||||
if size != "" {
|
||||
pageSize = tools.StrToInt(err, size)
|
||||
pageSize, err = tools.StringToInt(size)
|
||||
}
|
||||
|
||||
index := c.Request.FormValue("pageIndex")
|
||||
if index != "" {
|
||||
pageIndex = tools.StrToInt(err, index)
|
||||
pageIndex, err = tools.StringToInt(index)
|
||||
}
|
||||
|
||||
data.OperName = c.Request.FormValue("operName")
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
package scol
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go-admin/app/admin/service"
|
||||
common "go-admin/common/models"
|
||||
"net/http"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"go-admin/common/actions"
|
||||
"go-admin/common/apis"
|
||||
"go-admin/common/log"
|
||||
"go-admin/tools"
|
||||
)
|
||||
|
||||
type Scol struct {
|
||||
apis.Api
|
||||
}
|
||||
|
||||
func (e *Scol) GetScolList(c *gin.Context) {
|
||||
msgID := tools.GenerateMsgIDFromContext(c)
|
||||
d := new(dto.ScolSearch)
|
||||
db, err := tools.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
req := d.Generate()
|
||||
|
||||
//查询列表
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
//数据权限检查
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
list := make([]models.Scol, 0)
|
||||
var count int64
|
||||
serviceStudent := service.Scol{}
|
||||
serviceStudent.MsgID = msgID
|
||||
serviceStudent.Orm = db
|
||||
err = serviceStudent.GetScolPage(req, p, &list, &count)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.PageOK(c, list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
func (e *Scol) GetScol(c *gin.Context) {
|
||||
control := new(dto.ScolById)
|
||||
db, err := tools.GetOrm(c)
|
||||
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
msgID := tools.GenerateMsgIDFromContext(c)
|
||||
//查看详情
|
||||
req := control.Generate()
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object common.ActiveRecord
|
||||
object, err = control.GenerateM()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
|
||||
//数据权限检查
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
serviceScol := service.Scol{}
|
||||
serviceScol.MsgID = msgID
|
||||
serviceScol.Orm = db
|
||||
err = serviceScol.GetScol(req, p, &object)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object, "查看成功")
|
||||
}
|
||||
|
||||
func (e *Scol) InsertScol(c *gin.Context) {
|
||||
control := new(dto.ScolControl)
|
||||
db, err := tools.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
msgID := tools.GenerateMsgIDFromContext(c)
|
||||
//新增操作
|
||||
req := control.Generate()
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object common.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
// 设置创建人
|
||||
object.SetCreateBy(tools.GetUserIdUint(c))
|
||||
|
||||
serviceScol := service.Scol{}
|
||||
serviceScol.Orm = db
|
||||
serviceScol.MsgID = msgID
|
||||
err = serviceScol.InsertScol(object)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "创建失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
func (e *Scol) UpdateScol(c *gin.Context) {
|
||||
control := new(dto.ScolControl)
|
||||
db, err := tools.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
msgID := tools.GenerateMsgIDFromContext(c)
|
||||
req := control.Generate()
|
||||
//更新操作
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object common.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
object.SetUpdateBy(tools.GetUserIdUint(c))
|
||||
|
||||
//数据权限检查
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
serviceScol := service.Scol{}
|
||||
serviceScol.Orm = db
|
||||
serviceScol.MsgID = msgID
|
||||
err = serviceScol.UpdateScol(object, p)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "更新成功")
|
||||
}
|
||||
|
||||
func (e *Scol) DeleteScol(c *gin.Context) {
|
||||
control := new(dto.ScolById)
|
||||
db, err := tools.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
msgID := tools.GenerateMsgIDFromContext(c)
|
||||
//删除操作
|
||||
req := control.Generate()
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("MsgID[%s] Bind error: %s", msgID, err)
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object common.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
|
||||
// 设置编辑人
|
||||
object.SetUpdateBy(tools.GetUserIdUint(c))
|
||||
|
||||
// 数据权限检查
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
serviceScol := service.Scol{}
|
||||
serviceScol.Orm = db
|
||||
serviceScol.MsgID = msgID
|
||||
|
||||
err = serviceScol.RemoveScol(req, object, p)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "删除成功")
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package student
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go-admin/app/admin/service"
|
||||
common "go-admin/common/models"
|
||||
"net/http"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"go-admin/common/actions"
|
||||
"go-admin/common/apis"
|
||||
"go-admin/common/log"
|
||||
"go-admin/tools"
|
||||
"go-admin/tools/app"
|
||||
)
|
||||
|
||||
type Student struct {
|
||||
apis.Api
|
||||
}
|
||||
|
||||
func (e *Student) GetStudentList(c *gin.Context) {
|
||||
msgID := tools.GenerateMsgIDFromContext(c)
|
||||
d := new(dto.StudentSearch)
|
||||
db, err := tools.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
req := d.Generate()
|
||||
|
||||
//查询列表
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
app.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
//数据权限检查
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
list := make([]models.Student, 0)
|
||||
var count int64
|
||||
serviceStudent := service.Student{}
|
||||
serviceStudent.MsgID = msgID
|
||||
serviceStudent.Orm = db
|
||||
err = serviceStudent.GetStudentPage(req, p, &list, &count)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.PageOK(c, list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
func (e *Student) GetStudent(c *gin.Context) {
|
||||
control := new(dto.StudentById)
|
||||
d := new(dto.StudentSearch)
|
||||
db, err := tools.GetOrm(c)
|
||||
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
msgID := tools.GenerateMsgIDFromContext(c)
|
||||
//查看详情
|
||||
req := control.Generate()
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object common.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
|
||||
//数据权限检查
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
serviceStudent := service.Student{}
|
||||
serviceStudent.MsgID = msgID
|
||||
serviceStudent.Orm = db
|
||||
err = serviceStudent.GetStudent(d, p, &object)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object, "查看成功")
|
||||
}
|
||||
|
||||
func (e *Student) InsertStudent(c *gin.Context) {
|
||||
control := new(dto.StudentControl)
|
||||
db, err := tools.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
msgID := tools.GenerateMsgIDFromContext(c)
|
||||
//新增操作
|
||||
req := control.Generate()
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object common.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
// 设置创建人
|
||||
object.SetCreateBy(tools.GetUserIdUint(c))
|
||||
|
||||
serviceStudent := service.Student{}
|
||||
serviceStudent.Orm = db
|
||||
serviceStudent.MsgID = msgID
|
||||
err = serviceStudent.InsertStudent(object)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "创建失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
func (e *Student) UpdateStudent(c *gin.Context) {
|
||||
control := new(dto.StudentControl)
|
||||
db, err := tools.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
msgID := tools.GenerateMsgIDFromContext(c)
|
||||
req := control.Generate()
|
||||
//更新操作
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object common.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
object.SetUpdateBy(tools.GetUserIdUint(c))
|
||||
|
||||
//数据权限检查
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
serviceStudent := service.Student{}
|
||||
serviceStudent.Orm = db
|
||||
serviceStudent.MsgID = msgID
|
||||
err = serviceStudent.UpdateStudent(object, p)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "更新成功")
|
||||
}
|
||||
|
||||
func (e *Student) DeleteStudent(c *gin.Context) {
|
||||
control := new(dto.StudentById)
|
||||
db, err := tools.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
msgID := tools.GenerateMsgIDFromContext(c)
|
||||
//删除操作
|
||||
req := control.Generate()
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("MsgID[%s] Bind error: %s", msgID, err)
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object common.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
|
||||
// 设置编辑人
|
||||
object.SetUpdateBy(tools.GetUserIdUint(c))
|
||||
|
||||
// 数据权限检查
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
serviceStudent := service.Student{}
|
||||
serviceStudent.Orm = db
|
||||
serviceStudent.MsgID = msgID
|
||||
err = serviceStudent.RemoveStudent(object, p)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "删除成功")
|
||||
}
|
||||
@@ -17,10 +17,10 @@ func GetSysCategoryList(c *gin.Context) {
|
||||
var pageIndex = 1
|
||||
|
||||
if size := c.Request.FormValue("pageSize"); size != "" {
|
||||
pageSize = tools.StrToInt(err, size)
|
||||
pageSize, err = tools.StringToInt(size)
|
||||
}
|
||||
if index := c.Request.FormValue("pageIndex"); index != "" {
|
||||
pageIndex = tools.StrToInt(err, index)
|
||||
pageIndex, err = tools.StringToInt(index)
|
||||
}
|
||||
|
||||
data.Name = c.Request.FormValue("name")
|
||||
|
||||
@@ -17,10 +17,10 @@ func GetSysContentList(c *gin.Context) {
|
||||
var pageIndex = 1
|
||||
|
||||
if size := c.Request.FormValue("pageSize"); size != "" {
|
||||
pageSize = tools.StrToInt(err, size)
|
||||
pageSize, err = tools.StringToInt(size)
|
||||
}
|
||||
if index := c.Request.FormValue("pageIndex"); index != "" {
|
||||
pageIndex = tools.StrToInt(err, index)
|
||||
pageIndex, err = tools.StringToInt(index)
|
||||
}
|
||||
|
||||
data.CateId = c.Request.FormValue("cateId")
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
package sysjob
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/service"
|
||||
"go-admin/app/jobs"
|
||||
"go-admin/common/apis"
|
||||
"go-admin/common/dto"
|
||||
"go-admin/common/log"
|
||||
"go-admin/tools"
|
||||
"go-admin/tools/app"
|
||||
"go-admin/tools/app/msg"
|
||||
)
|
||||
|
||||
type SysJob struct {
|
||||
@@ -73,56 +68,3 @@ func (e *SysJob) StartJobForService(c *gin.Context) {
|
||||
}
|
||||
app.OK(c, nil, s.Msg)
|
||||
}
|
||||
|
||||
func RemoveJob(c *gin.Context) {
|
||||
var data models.SysJob
|
||||
var v dto.GeneralDelDto
|
||||
err := c.BindUri(&v)
|
||||
tools.HasError(err, "", 500)
|
||||
data.JobId = v.Id
|
||||
err = data.Get(data.JobId)
|
||||
tools.HasError(err, "", 500)
|
||||
cn := jobs.Remove(data.EntryId)
|
||||
|
||||
select {
|
||||
case res := <-cn:
|
||||
if res {
|
||||
_, _ = data.RemoveEntryID(data.EntryId)
|
||||
app.OK(c, nil, msg.DeletedSuccess)
|
||||
}
|
||||
case <-time.After(time.Second * 1):
|
||||
app.OK(c, nil, msg.TimeOut)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func StartJob(c *gin.Context) {
|
||||
var data models.SysJob
|
||||
var v dto.GeneralGetDto
|
||||
err := c.BindUri(&v)
|
||||
tools.HasError(err, "", 500)
|
||||
data.JobId = v.Id
|
||||
err = data.Get(data.JobId)
|
||||
tools.HasError(err, "", 500)
|
||||
if data.JobType == 1 {
|
||||
var j = &jobs.HttpJob{}
|
||||
j.InvokeTarget = data.InvokeTarget
|
||||
j.CronExpression = data.CronExpression
|
||||
j.JobId = data.JobId
|
||||
j.Name = data.JobName
|
||||
data.EntryId, err = jobs.AddJob(j)
|
||||
} else {
|
||||
var j = &jobs.ExecJob{}
|
||||
j.InvokeTarget = data.InvokeTarget
|
||||
j.CronExpression = data.CronExpression
|
||||
j.JobId = data.JobId
|
||||
j.Name = data.JobName
|
||||
j.Args = data.Args
|
||||
data.EntryId, err = jobs.AddJob(j)
|
||||
}
|
||||
|
||||
tools.HasError(err, "", 500)
|
||||
err = data.Update(data.JobId)
|
||||
tools.HasError(err, "", 500)
|
||||
app.OK(c, nil, msg.DeletedSuccess)
|
||||
}
|
||||
@@ -30,11 +30,11 @@ func GetConfigList(c *gin.Context) {
|
||||
var pageIndex = 1
|
||||
|
||||
if size := c.Request.FormValue("pageSize"); size != "" {
|
||||
pageSize = tools.StrToInt(err, size)
|
||||
pageSize, err = tools.StringToInt(size)
|
||||
}
|
||||
|
||||
if index := c.Request.FormValue("pageIndex"); index != "" {
|
||||
pageIndex = tools.StrToInt(err, index)
|
||||
pageIndex, err = tools.StringToInt(index)
|
||||
}
|
||||
|
||||
data.ConfigKey = c.Request.FormValue("configKey")
|
||||
|
||||
@@ -29,11 +29,11 @@ func GetDictDataList(c *gin.Context) {
|
||||
var pageIndex = 1
|
||||
|
||||
if size := c.Request.FormValue("pageSize"); size != "" {
|
||||
pageSize = tools.StrToInt(err, size)
|
||||
pageSize, err = tools.StringToInt(size)
|
||||
}
|
||||
|
||||
if index := c.Request.FormValue("pageIndex"); index != "" {
|
||||
pageIndex = tools.StrToInt(err, index)
|
||||
pageIndex, err = tools.StringToInt(index)
|
||||
}
|
||||
|
||||
data.DictLabel = c.Request.FormValue("dictLabel")
|
||||
|
||||
@@ -29,11 +29,11 @@ func GetDictTypeList(c *gin.Context) {
|
||||
var pageIndex = 1
|
||||
|
||||
if size := c.Request.FormValue("pageSize"); size != "" {
|
||||
pageSize = tools.StrToInt(err, size)
|
||||
pageSize, err = tools.StringToInt(size)
|
||||
}
|
||||
|
||||
if index := c.Request.FormValue("pageIndex"); index != "" {
|
||||
pageIndex = tools.StrToInt(err, index)
|
||||
pageIndex, err = tools.StringToInt(index)
|
||||
}
|
||||
|
||||
data.DictName = c.Request.FormValue("dictName")
|
||||
|
||||
@@ -25,11 +25,11 @@ func GetPostList(c *gin.Context) {
|
||||
var pageIndex = 1
|
||||
|
||||
if size := c.Request.FormValue("pageSize"); size != "" {
|
||||
pageSize = tools.StrToInt(err, size)
|
||||
pageSize, err = tools.StringToInt(size)
|
||||
}
|
||||
|
||||
if index := c.Request.FormValue("pageIndex"); index != "" {
|
||||
pageIndex = tools.StrToInt(err, index)
|
||||
pageIndex, err = tools.StringToInt(index)
|
||||
}
|
||||
|
||||
id := c.Request.FormValue("postId")
|
||||
|
||||
@@ -27,11 +27,11 @@ func GetRoleList(c *gin.Context) {
|
||||
var pageIndex = 1
|
||||
|
||||
if size := c.Request.FormValue("pageSize"); size != "" {
|
||||
pageSize = tools.StrToInt(err, size)
|
||||
pageSize, err = tools.StringToInt(size)
|
||||
}
|
||||
|
||||
if index := c.Request.FormValue("pageIndex"); index != "" {
|
||||
pageIndex = tools.StrToInt(err, index)
|
||||
pageIndex, err = tools.StringToInt(index)
|
||||
}
|
||||
|
||||
data.RoleKey = c.Request.FormValue("roleKey")
|
||||
|
||||
@@ -27,12 +27,12 @@ func GetSysUserList(c *gin.Context) {
|
||||
|
||||
size := c.Request.FormValue("pageSize")
|
||||
if size != "" {
|
||||
pageSize = tools.StrToInt(err, size)
|
||||
pageSize, err = tools.StringToInt(size)
|
||||
}
|
||||
|
||||
index := c.Request.FormValue("pageIndex")
|
||||
if index != "" {
|
||||
pageIndex = tools.StrToInt(err, index)
|
||||
pageIndex, err = tools.StringToInt(index)
|
||||
}
|
||||
|
||||
data.Username = c.Request.FormValue("username")
|
||||
|
||||
@@ -25,11 +25,11 @@ func GetDBColumnList(c *gin.Context) {
|
||||
var pageIndex = 1
|
||||
|
||||
if size := c.Request.FormValue("pageSize"); size != "" {
|
||||
pageSize = tools2.StrToInt(err, size)
|
||||
pageSize, err = tools2.StringToInt(size)
|
||||
}
|
||||
|
||||
if index := c.Request.FormValue("pageIndex"); index != "" {
|
||||
pageIndex = tools2.StrToInt(err, index)
|
||||
pageIndex, err = tools2.StringToInt(index)
|
||||
}
|
||||
|
||||
data.TableName = c.Request.FormValue("tableName")
|
||||
|
||||
@@ -32,11 +32,11 @@ func GetDBTableList(c *gin.Context) {
|
||||
}
|
||||
|
||||
if size := c.Request.FormValue("pageSize"); size != "" {
|
||||
pageSize = tools2.StrToInt(err, size)
|
||||
pageSize, err = tools2.StringToInt(size)
|
||||
}
|
||||
|
||||
if index := c.Request.FormValue("pageIndex"); index != "" {
|
||||
pageIndex = tools2.StrToInt(err, index)
|
||||
pageIndex, err = tools2.StringToInt(index)
|
||||
}
|
||||
|
||||
data.TableName = c.Request.FormValue("tableName")
|
||||
|
||||
@@ -151,6 +151,120 @@ func GenCodeV2(c *gin.Context) {
|
||||
app.OK(c, "", "Code generated successfully!")
|
||||
}
|
||||
|
||||
func GenCodeV3(c *gin.Context) {
|
||||
table := tools.SysTables{}
|
||||
id, err := tools2.StringToInt(c.Param("tableId"))
|
||||
tools2.HasError(err, "", -1)
|
||||
table.TableId = id
|
||||
tab, _ := table.Get()
|
||||
|
||||
if tab.IsActions == 1 {
|
||||
ActionsGenV3(tab)
|
||||
} else {
|
||||
NOActionsGenV3(tab)
|
||||
}
|
||||
|
||||
app.OK(c, "", "Code generated successfully!")
|
||||
}
|
||||
|
||||
func NOActionsGenV3(tab tools.SysTables) {
|
||||
|
||||
basePath := "template/v3/"
|
||||
routerFile := basePath + "no_actions/router_check_role.go.template"
|
||||
|
||||
if tab.IsAuth == 2 {
|
||||
routerFile = basePath + "no_actions/router_no_check_role.go.template"
|
||||
}
|
||||
|
||||
t1, err := template.ParseFiles(basePath + "model.go.template")
|
||||
tools2.HasError(err, "", -1)
|
||||
t2, err := template.ParseFiles(basePath + "no_actions/apis.go.template")
|
||||
tools2.HasError(err, "", -1)
|
||||
t3, err := template.ParseFiles(routerFile)
|
||||
tools2.HasError(err, "", -1)
|
||||
t4, err := template.ParseFiles(basePath + "js.go.template")
|
||||
tools2.HasError(err, "", -1)
|
||||
t5, err := template.ParseFiles(basePath + "vue.go.template")
|
||||
tools2.HasError(err, "", -1)
|
||||
t6, err := template.ParseFiles(basePath + "dto.go.template")
|
||||
tools2.HasError(err, "", -1)
|
||||
t7, err := template.ParseFiles(basePath + "no_actions/service.go.template")
|
||||
tools2.HasError(err, "", -1)
|
||||
|
||||
_ = tools2.PathCreate("./app/" + tab.PackageName + "/apis/" + tab.ModuleName)
|
||||
_ = tools2.PathCreate("./app/" + tab.PackageName + "/models/")
|
||||
_ = tools2.PathCreate("./app/" + tab.PackageName + "/router/")
|
||||
_ = tools2.PathCreate("./app/" + tab.PackageName + "/service/dto/")
|
||||
_ = tools2.PathCreate(config.GenConfig.FrontPath + "/api/")
|
||||
_ = tools2.PathCreate(config.GenConfig.FrontPath + "/views/" + tab.BusinessName)
|
||||
|
||||
var b1 bytes.Buffer
|
||||
err = t1.Execute(&b1, tab)
|
||||
var b2 bytes.Buffer
|
||||
err = t2.Execute(&b2, tab)
|
||||
var b3 bytes.Buffer
|
||||
err = t3.Execute(&b3, tab)
|
||||
var b4 bytes.Buffer
|
||||
err = t4.Execute(&b4, tab)
|
||||
var b5 bytes.Buffer
|
||||
err = t5.Execute(&b5, tab)
|
||||
var b6 bytes.Buffer
|
||||
err = t6.Execute(&b6, tab)
|
||||
var b7 bytes.Buffer
|
||||
err = t7.Execute(&b7, tab)
|
||||
tools2.FileCreate(b1, "./app/"+tab.PackageName+"/models/"+tab.BusinessName+".go")
|
||||
tools2.FileCreate(b2, "./app/"+tab.PackageName+"/apis/"+tab.ModuleName+"/"+tab.BusinessName+".go")
|
||||
tools2.FileCreate(b3, "./app/"+tab.PackageName+"/router/"+tab.BusinessName+".go")
|
||||
tools2.FileCreate(b4, config.GenConfig.FrontPath+"/api/"+tab.BusinessName+".js")
|
||||
tools2.FileCreate(b5, config.GenConfig.FrontPath+"/views/"+tab.BusinessName+"/index.vue")
|
||||
tools2.FileCreate(b6, "./app/"+tab.PackageName+"/service/dto/"+tab.BusinessName+".go")
|
||||
tools2.FileCreate(b7, "./app/"+tab.PackageName+"/service/"+tab.BusinessName+".go")
|
||||
|
||||
}
|
||||
|
||||
func ActionsGenV3(tab tools.SysTables) {
|
||||
basePath := "template/v3/"
|
||||
routerFile := basePath + "actions/router_check_role.go.template"
|
||||
|
||||
if tab.IsAuth == 2 {
|
||||
routerFile = basePath + "actions/router_no_check_role.go.template"
|
||||
}
|
||||
|
||||
t1, err := template.ParseFiles(basePath + "model.go.template")
|
||||
tools2.HasError(err, "", -1)
|
||||
t3, err := template.ParseFiles(routerFile)
|
||||
tools2.HasError(err, "", -1)
|
||||
t4, err := template.ParseFiles(basePath + "js.go.template")
|
||||
tools2.HasError(err, "", -1)
|
||||
t5, err := template.ParseFiles(basePath + "vue.go.template")
|
||||
tools2.HasError(err, "", -1)
|
||||
t6, err := template.ParseFiles(basePath + "dto.go.template")
|
||||
tools2.HasError(err, "", -1)
|
||||
|
||||
_ = tools2.PathCreate("./app/" + tab.PackageName + "/models/")
|
||||
_ = tools2.PathCreate("./app/" + tab.PackageName + "/router/")
|
||||
_ = tools2.PathCreate("./app/" + tab.PackageName + "/service/dto/")
|
||||
_ = tools2.PathCreate(config.GenConfig.FrontPath + "/api/")
|
||||
_ = tools2.PathCreate(config.GenConfig.FrontPath + "/views/" + tab.BusinessName)
|
||||
|
||||
var b1 bytes.Buffer
|
||||
err = t1.Execute(&b1, tab)
|
||||
var b3 bytes.Buffer
|
||||
err = t3.Execute(&b3, tab)
|
||||
var b4 bytes.Buffer
|
||||
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, "./app/"+tab.PackageName+"/models/"+tab.BusinessName+".go")
|
||||
tools2.FileCreate(b3, "./app/"+tab.PackageName+"/router/"+tab.BusinessName+".go")
|
||||
tools2.FileCreate(b4, config.GenConfig.FrontPath+"/api/"+tab.BusinessName+".js")
|
||||
tools2.FileCreate(b5, config.GenConfig.FrontPath+"/views/"+tab.BusinessName+"/index.vue")
|
||||
tools2.FileCreate(b6, "./app/"+tab.PackageName+"/service/dto/"+tab.BusinessName+".go")
|
||||
}
|
||||
|
||||
func NOActionsGen(tab tools.SysTables) {
|
||||
routerfile := "template/routercheckrole.go.template"
|
||||
|
||||
|
||||
Reference in new issue
Block a user