mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-24 19:17:43 +00:00
Compare commits
31
Commits
v2.0.0-beta.7
...
v2.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84e06395a5 | ||
|
|
411b85afcd | ||
|
|
57d128144d | ||
|
|
a7fa7e079b | ||
|
|
2781e413dc | ||
|
|
41d8daac97 | ||
|
|
dd22d55ee7 | ||
|
|
32a1bd2511 | ||
|
|
1130d20f14 | ||
|
|
90b17e995a | ||
|
|
1c41b0ec72 | ||
|
|
3f90605589 | ||
|
|
c1347fbb5d | ||
|
|
0d1cb2ee33 | ||
|
|
b6be297a1e | ||
|
|
b9b3cbee93 | ||
|
|
37d318b4d9 | ||
|
|
5368cfbcb8 | ||
|
|
72a4ba077c | ||
|
|
fba03625d0 | ||
|
|
007807e776 | ||
|
|
f2ae95d932 | ||
|
|
25d7323ed1 | ||
|
|
f7e737534d | ||
|
|
760c6b2814 | ||
|
|
d0f49ef8c7 | ||
|
|
1295b1fd35 | ||
|
|
eb8062d19b | ||
|
|
d82129d364 | ||
|
|
16923017b2 | ||
|
|
f4396e7e83 |
+2
-2
@@ -232,14 +232,14 @@ npm run dev
|
||||
## 📨 互动
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<tr>
|
||||
<td><img src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/wx.png" width="180px"></td>
|
||||
<td><img src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/qq.png" width="200px"></td>
|
||||
<td><img src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/qq2.png" width="200px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>微信</td>
|
||||
<td>此群已满</td>
|
||||
<td><a target="_blank" href="https://qm.qq.com/cgi-bin/qm/qr?k=I8ZMqsExqCHpyu8SL4rbya700rBBXYLO&jump_from=webapi"><img border="0" src="//pub.idqqimg.com/wpa/images/group.png" alt="go-admin技术交流甲号" title="go-admin技术交流甲号"></a></td>
|
||||
<td><a target="_blank" href="https://shang.qq.com/wpa/qunwpa?idkey=0f2bf59f5f2edec6a4550c364242c0641f870aa328e468c4ee4b7dbfb392627b"><img border="0" src="https://pub.idqqimg.com/wpa/images/group.png" alt="go-admin技术交流乙号" title="go-admin技术交流乙号"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -92,7 +92,7 @@ func (e SysApi) Get(c *gin.Context) {
|
||||
// @Tags 接口管理
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.SysApiControl true "body"
|
||||
// @Param data body dto.SysApiUpdateReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "修改成功"}"
|
||||
// @Router /api/v1/sys-api/{id} [put]
|
||||
// @Security Bearer
|
||||
@@ -122,7 +122,7 @@ func (e SysApi) Update(c *gin.Context) {
|
||||
// @Summary 删除接口管理
|
||||
// @Description 删除接口管理
|
||||
// @Tags 接口管理
|
||||
// @Param ids body []int false "ids"
|
||||
// @Param data body dto.SysApiDeleteReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "删除成功"}"
|
||||
// @Router /api/v1/sys-api [delete]
|
||||
// @Security Bearer
|
||||
|
||||
@@ -31,7 +31,7 @@ type SysDictType struct {
|
||||
// @Security Bearer
|
||||
func (e SysDictType) GetPage(c *gin.Context) {
|
||||
s := service.SysDictType{}
|
||||
req := dto.SysDictTypeSearch{}
|
||||
req :=dto.SysDictTypeSearch{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
@@ -62,7 +62,7 @@ func (e SysDictType) GetPage(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysDictType) Get(c *gin.Context) {
|
||||
s := service.SysDictType{}
|
||||
req := dto.SysDictTypeById{}
|
||||
req :=dto.SysDictTypeById{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, nil).
|
||||
@@ -95,7 +95,7 @@ func (e SysDictType) Get(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysDictType) Insert(c *gin.Context) {
|
||||
s := service.SysDictType{}
|
||||
req := dto.SysDictTypeControl{}
|
||||
req :=dto.SysDictTypeControl{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
@@ -129,7 +129,7 @@ func (e SysDictType) Insert(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysDictType) Update(c *gin.Context) {
|
||||
s := service.SysDictType{}
|
||||
req := dto.SysDictTypeControl{}
|
||||
req :=dto.SysDictTypeControl{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
@@ -160,7 +160,7 @@ func (e SysDictType) Update(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysDictType) Delete(c *gin.Context) {
|
||||
s := service.SysDictType{}
|
||||
req := dto.SysDictTypeById{}
|
||||
req :=dto.SysDictTypeById{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
@@ -192,7 +192,7 @@ func (e SysDictType) Delete(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysDictType) GetAll(c *gin.Context) {
|
||||
s := service.SysDictType{}
|
||||
req := dto.SysDictTypeSearch{}
|
||||
req :=dto.SysDictTypeSearch{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
|
||||
"go-admin/app/admin/models"
|
||||
|
||||
"go-admin/app/admin/service"
|
||||
@@ -30,7 +29,7 @@ type SysLoginLog struct {
|
||||
// @Security Bearer
|
||||
func (e SysLoginLog) GetPage(c *gin.Context) {
|
||||
s := service.SysLoginLog{}
|
||||
req := dto.SysLoginLogSearch {}
|
||||
req :=dto.SysLoginLogSearch {}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
@@ -61,10 +60,10 @@ func (e SysLoginLog) GetPage(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysLoginLog) Get(c *gin.Context) {
|
||||
s := service.SysLoginLog{}
|
||||
req := dto.SysLoginLogById{}
|
||||
req :=dto.SysLoginLogGetReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
@@ -91,7 +90,7 @@ func (e SysLoginLog) Get(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysLoginLog) Delete(c *gin.Context) {
|
||||
s := service.SysLoginLog{}
|
||||
req := dto.SysLoginLogById{}
|
||||
req :=dto.SysLoginLogDeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
@@ -102,7 +101,6 @@ func (e SysLoginLog) Delete(c *gin.Context) {
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
req.SetUpdateBy(user.GetUserId(c))
|
||||
err = s.Remove(&req)
|
||||
if err != nil {
|
||||
e.Error(500, err, "删除失败")
|
||||
|
||||
@@ -254,7 +254,7 @@ func (e SysMenu) GetMenuRole(c *gin.Context) {
|
||||
func (e SysMenu) GetMenuTreeSelect(c *gin.Context) {
|
||||
m := service.SysMenu{}
|
||||
r := service.SysRole{}
|
||||
req := dto.SelectRole{}
|
||||
req :=dto.SelectRole{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
MakeService(&m.Service).
|
||||
|
||||
@@ -65,7 +65,7 @@ func (e SysOperaLog) GetPage(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysOperaLog) Get(c *gin.Context) {
|
||||
s := new(service.SysOperaLog)
|
||||
req := dto.SysOperaLogById{}
|
||||
req :=dto.SysOperaLogGetReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, nil).
|
||||
@@ -96,7 +96,7 @@ func (e SysOperaLog) Get(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysOperaLog) Delete(c *gin.Context) {
|
||||
s := new(service.SysOperaLog)
|
||||
req := dto.SysOperaLogById{}
|
||||
req :=dto.SysOperaLogDeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
|
||||
@@ -30,7 +30,7 @@ type SysPost struct {
|
||||
// @Security Bearer
|
||||
func (e SysPost) GetPage(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostPageReq{}
|
||||
req :=dto.SysPostPageReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
@@ -64,7 +64,7 @@ func (e SysPost) GetPage(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysPost) Get(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostGetReq{}
|
||||
req :=dto.SysPostGetReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, nil).
|
||||
@@ -99,7 +99,7 @@ func (e SysPost) Get(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysPost) Insert(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostInsertReq{}
|
||||
req :=dto.SysPostInsertReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
@@ -132,7 +132,7 @@ func (e SysPost) Insert(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysPost) Update(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostUpdateReq{}
|
||||
req :=dto.SysPostUpdateReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
@@ -165,7 +165,7 @@ func (e SysPost) Update(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysPost) Delete(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostDeleteReq{}
|
||||
req :=dto.SysPostDeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
|
||||
+12
-12
@@ -30,7 +30,7 @@ type SysUser struct {
|
||||
// @Security Bearer
|
||||
func (e SysUser) GetPage(c *gin.Context) {
|
||||
s := service.SysUser{}
|
||||
req := dto.SysUserGetPageReq{}
|
||||
req :=dto.SysUserGetPageReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
@@ -67,7 +67,7 @@ func (e SysUser) GetPage(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysUser) Get(c *gin.Context) {
|
||||
s := service.SysUser{}
|
||||
req := dto.SysUserById{}
|
||||
req :=dto.SysUserById{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, nil).
|
||||
@@ -101,7 +101,7 @@ func (e SysUser) Get(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysUser) Insert(c *gin.Context) {
|
||||
s := service.SysUser{}
|
||||
req := dto.SysUserControl{}
|
||||
req :=dto.SysUserInsertReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
@@ -136,7 +136,7 @@ func (e SysUser) Insert(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysUser) Update(c *gin.Context) {
|
||||
s := service.SysUser{}
|
||||
req := dto.SysUserControl{}
|
||||
req :=dto.SysUserUpdateReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
@@ -171,7 +171,7 @@ func (e SysUser) Update(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysUser) Delete(c *gin.Context) {
|
||||
s := service.SysUser{}
|
||||
req := dto.SysUserById{}
|
||||
req :=dto.SysUserById{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
@@ -208,7 +208,7 @@ func (e SysUser) Delete(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysUser) InsetAvatar(c *gin.Context) {
|
||||
s := service.SysUser{}
|
||||
req := dto.SysUserControl{}
|
||||
req :=dto.UpdateSysUserAvatarReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
MakeService(&s.Service).
|
||||
@@ -237,7 +237,7 @@ func (e SysUser) InsetAvatar(c *gin.Context) {
|
||||
req.UserId = p.UserId
|
||||
req.Avatar = "/" + filPath
|
||||
|
||||
err = s.Update(&req, p)
|
||||
err = s.UpdateSysUserAvatar(&req, p)
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
return
|
||||
@@ -257,7 +257,7 @@ func (e SysUser) InsetAvatar(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysUser) UpdateStatus(c *gin.Context) {
|
||||
s := service.SysUser{}
|
||||
req := dto.UpdateSysUserStatusReq{}
|
||||
req :=dto.UpdateSysUserStatusReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
@@ -294,7 +294,7 @@ func (e SysUser) UpdateStatus(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysUser) ResetPwd(c *gin.Context) {
|
||||
s := service.SysUser{}
|
||||
req := dto.ResetSysUserPwdReq{}
|
||||
req :=dto.ResetSysUserPwdReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
@@ -331,7 +331,7 @@ func (e SysUser) ResetPwd(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysUser) UpdatePwd(c *gin.Context) {
|
||||
s := service.SysUser{}
|
||||
req := dto.PassWord{}
|
||||
req :=dto.PassWord{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
@@ -364,7 +364,7 @@ func (e SysUser) UpdatePwd(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysUser) GetProfile(c *gin.Context) {
|
||||
s := service.SysUser{}
|
||||
req := dto.SysUserById{}
|
||||
req :=dto.SysUserById{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
MakeService(&s.Service).
|
||||
@@ -401,7 +401,7 @@ func (e SysUser) GetProfile(c *gin.Context) {
|
||||
// @Router /api/v1/getinfo [get]
|
||||
// @Security Bearer
|
||||
func (e SysUser) GetInfo(c *gin.Context) {
|
||||
req := dto.SysUserById{}
|
||||
req :=dto.SysUserById{}
|
||||
s := service.SysUser{}
|
||||
r := service.SysRole{}
|
||||
err := e.MakeContext(c).
|
||||
|
||||
@@ -74,6 +74,10 @@ func SaveOperaLog(message storage.Messager) (err error) {
|
||||
// Log writing to the database ignores error
|
||||
return nil
|
||||
}
|
||||
// 超出100个字符返回值截断
|
||||
if len(l.JsonResult) > 100 {
|
||||
l.JsonResult = l.JsonResult[:100]
|
||||
}
|
||||
err = db.Create(&l).Error
|
||||
if err != nil {
|
||||
log.Errorf("db create error, %s", err.Error())
|
||||
|
||||
@@ -77,10 +77,20 @@ func (s *SysApiUpdateReq) GetId() interface{} {
|
||||
|
||||
// SysApiGetReq 功能获取请求参数
|
||||
type SysApiGetReq struct {
|
||||
dto.ObjectGetReq
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *SysApiGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
|
||||
// SysApiDeleteReq 功能删除请求参数
|
||||
type SysApiDeleteReq struct {
|
||||
dto.ObjectDeleteReq
|
||||
Ids []int `json:"ids"`
|
||||
}
|
||||
|
||||
func (s *SysApiDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ type SysDeptControl struct {
|
||||
DeptPath string `json:"deptPath" comment:""` //路径
|
||||
DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"` //部门名称
|
||||
Sort int `json:"sort" comment:"排序" vd:"?"` //排序
|
||||
Leader string `json:"leader,required" comment:"负责人" vd:"@:len($)>0;msg:validation failed:该字段不能为空"` //负责人
|
||||
Leader string `json:"leader" comment:"负责人" vd:"@:len($)>0; msg:'leader不能为空'"` //负责人
|
||||
Phone string `json:"phone" comment:"手机" vd:"?"` //手机
|
||||
Email string `json:"email" comment:"邮箱" vd:"?"` //邮箱
|
||||
Status int `json:"status" comment:"状态" vd:"$>0"` //状态
|
||||
|
||||
@@ -61,21 +61,19 @@ func (s *SysLoginLogControl) GetId() interface{} {
|
||||
return s.ID
|
||||
}
|
||||
|
||||
type SysLoginLogById struct {
|
||||
Id int `uri:"id"`
|
||||
Ids []int `json:"ids"`
|
||||
common.ControlBy
|
||||
type SysLoginLogGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *SysLoginLogById) GetId() interface{} {
|
||||
func (s *SysLoginLogGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysLoginLogById) Generate() *SysLoginLogById {
|
||||
cp := *s
|
||||
return &cp
|
||||
// SysLoginLogDeleteReq 功能删除请求参数
|
||||
type SysLoginLogDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
}
|
||||
|
||||
func (s *SysLoginLogById) GenerateM() (*models.SysLoginLog, error) {
|
||||
return &models.SysLoginLog{}, nil
|
||||
func (s *SysLoginLogDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
@@ -79,19 +79,19 @@ func (s *SysOperaLogControl) GetId() interface{} {
|
||||
return s.ID
|
||||
}
|
||||
|
||||
type SysOperaLogById struct {
|
||||
Id int `uri:"id"`
|
||||
Ids []int `json:"ids"`
|
||||
type SysOperaLogGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *SysOperaLogById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
func (s *SysOperaLogGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysOperaLogById) SetUpdateBy(id int) {
|
||||
// SysOperaLogDeleteReq 功能删除请求参数
|
||||
type SysOperaLogDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
}
|
||||
|
||||
func (s *SysOperaLogDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
|
||||
@@ -54,9 +54,26 @@ func (s *ResetSysUserPwdReq) Generate(model *models.SysUser) {
|
||||
model.Password = s.Password
|
||||
}
|
||||
|
||||
type UpdateSysUserAvatarReq struct {
|
||||
UserId int `json:"userId" comment:"用户ID" vd:"required"` // 用户ID
|
||||
Avatar string `json:"avatar" comment:"头像" vd:"required"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *UpdateSysUserAvatarReq) GetId() interface{} {
|
||||
return s.UserId
|
||||
}
|
||||
|
||||
func (s *UpdateSysUserAvatarReq) Generate(model *models.SysUser) {
|
||||
if s.UserId != 0 {
|
||||
model.UserId = s.UserId
|
||||
}
|
||||
model.Avatar = s.Avatar
|
||||
}
|
||||
|
||||
type UpdateSysUserStatusReq struct {
|
||||
UserId int `json:"userId" comment:"用户ID" binding:"required"` // 用户ID
|
||||
Status string `json:"status" comment:"状态" binding:"required"`
|
||||
UserId int `json:"userId" comment:"用户ID" vd:"required"` // 用户ID
|
||||
Status string `json:"status" comment:"状态" vd:"required"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
@@ -71,24 +88,24 @@ func (s *UpdateSysUserStatusReq) Generate(model *models.SysUser) {
|
||||
model.Status = s.Status
|
||||
}
|
||||
|
||||
type SysUserControl struct {
|
||||
type SysUserInsertReq struct {
|
||||
UserId int `json:"userId" comment:"用户ID"` // 用户ID
|
||||
Username string `json:"username" comment:"用户名" binding:"required"`
|
||||
Username string `json:"username" comment:"用户名" vd:"required"`
|
||||
Password string `json:"password" comment:"密码"`
|
||||
NickName string `json:"nickName" comment:"昵称" binding:"required"`
|
||||
Phone string `json:"phone" comment:"手机号" binding:"required"`
|
||||
NickName string `json:"nickName" comment:"昵称" vd:"required"`
|
||||
Phone string `json:"phone" comment:"手机号" vd:"required"`
|
||||
RoleId int `json:"roleId" comment:"角色ID"`
|
||||
Avatar string `json:"avatar" comment:"头像"`
|
||||
Sex string `json:"sex" comment:"性别"`
|
||||
Email string `json:"email" comment:"邮箱" binding:"required,email"`
|
||||
DeptId int `json:"deptId" comment:"部门" binding:"required"`
|
||||
Email string `json:"email" comment:"邮箱" vd:"required,email"`
|
||||
DeptId int `json:"deptId" comment:"部门" vd:"required"`
|
||||
PostId int `json:"postId" comment:"岗位"`
|
||||
Remark string `json:"remark" comment:"备注"`
|
||||
Status string `json:"status" comment:"状态" binding:"required" default:"1"`
|
||||
Status string `json:"status" comment:"状态" vd:"required" default:"1"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysUserControl) Generate(model *models.SysUser) {
|
||||
func (s *SysUserInsertReq) Generate(model *models.SysUser) {
|
||||
if s.UserId != 0 {
|
||||
model.UserId = s.UserId
|
||||
}
|
||||
@@ -106,7 +123,44 @@ func (s *SysUserControl) Generate(model *models.SysUser) {
|
||||
model.Status = s.Status
|
||||
}
|
||||
|
||||
func (s *SysUserControl) GetId() interface{} {
|
||||
func (s *SysUserInsertReq) GetId() interface{} {
|
||||
return s.UserId
|
||||
}
|
||||
|
||||
type SysUserUpdateReq struct {
|
||||
UserId int `json:"userId" comment:"用户ID"` // 用户ID
|
||||
Username string `json:"username" comment:"用户名" vd:"required"`
|
||||
NickName string `json:"nickName" comment:"昵称" vd:"required"`
|
||||
Phone string `json:"phone" comment:"手机号" vd:"required"`
|
||||
RoleId int `json:"roleId" comment:"角色ID"`
|
||||
Avatar string `json:"avatar" comment:"头像"`
|
||||
Sex string `json:"sex" comment:"性别"`
|
||||
Email string `json:"email" comment:"邮箱" vd:"required,email"`
|
||||
DeptId int `json:"deptId" comment:"部门" vd:"required"`
|
||||
PostId int `json:"postId" comment:"岗位"`
|
||||
Remark string `json:"remark" comment:"备注"`
|
||||
Status string `json:"status" comment:"状态" vd:"required" default:"1"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysUserUpdateReq) Generate(model *models.SysUser) {
|
||||
if s.UserId != 0 {
|
||||
model.UserId = s.UserId
|
||||
}
|
||||
model.Username = s.Username
|
||||
model.NickName = s.NickName
|
||||
model.Phone = s.Phone
|
||||
model.RoleId = s.RoleId
|
||||
model.Avatar = s.Avatar
|
||||
model.Sex = s.Sex
|
||||
model.Email = s.Email
|
||||
model.DeptId = s.DeptId
|
||||
model.PostId = s.PostId
|
||||
model.Remark = s.Remark
|
||||
model.Status = s.Status
|
||||
}
|
||||
|
||||
func (s *SysUserUpdateReq) GetId() interface{} {
|
||||
return s.UserId
|
||||
}
|
||||
|
||||
@@ -129,6 +183,6 @@ func (s *SysUserById) GenerateM() (common.ActiveRecord, error) {
|
||||
|
||||
// PassWord 密码
|
||||
type PassWord struct {
|
||||
NewPassword string `json:"newPassword" binding:"required"`
|
||||
OldPassword string `json:"oldPassword" binding:"required"`
|
||||
NewPassword string `json:"newPassword" vd:"required"`
|
||||
OldPassword string `json:"oldPassword" vd:"required"`
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ func (e *SysLoginLog) GetPage(c *dto.SysLoginLogSearch, list *[]models.SysLoginL
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSysLoginLog 获取SysLoginLog对象
|
||||
func (e *SysLoginLog) Get(d *dto.SysLoginLogById, model *models.SysLoginLog) error {
|
||||
// Get 获取SysLoginLog对象
|
||||
func (e *SysLoginLog) Get(d *dto.SysLoginLogGetReq, model *models.SysLoginLog) error {
|
||||
var err error
|
||||
db := e.Orm.First(model, d.GetId())
|
||||
err = db.Error
|
||||
@@ -52,7 +52,7 @@ func (e *SysLoginLog) Get(d *dto.SysLoginLogById, model *models.SysLoginLog) err
|
||||
}
|
||||
|
||||
// Remove 删除SysLoginLog
|
||||
func (e *SysLoginLog) Remove(c *dto.SysLoginLogById) error {
|
||||
func (e *SysLoginLog) Remove(c *dto.SysLoginLogDeleteReq) error {
|
||||
var err error
|
||||
var data models.SysLoginLog
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ func (e *SysOperaLog) GetPage(c *dto.SysOperaLogGetPageReq, list *[]models.SysOp
|
||||
}
|
||||
|
||||
// Get 获取SysOperaLog对象
|
||||
func (e *SysOperaLog) Get(d *dto.SysOperaLogById, model *models.SysOperaLog) error {
|
||||
func (e *SysOperaLog) Get(d *dto.SysOperaLogGetReq, model *models.SysOperaLog) error {
|
||||
var data models.SysOperaLog
|
||||
|
||||
err := e.Orm.Model(&data).
|
||||
@@ -67,7 +67,7 @@ func (e *SysOperaLog) Insert(model *models.SysOperaLog) error {
|
||||
}
|
||||
|
||||
// Remove 删除SysOperaLog
|
||||
func (e *SysOperaLog) Remove(d *dto.SysOperaLogById) error {
|
||||
func (e *SysOperaLog) Remove(d *dto.SysOperaLogDeleteReq) error {
|
||||
var err error
|
||||
var data models.SysOperaLog
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ func (e *SysUser) Get(d *dto.SysUserById, p *actions.DataPermission, model *mode
|
||||
}
|
||||
|
||||
// Insert 创建SysUser对象
|
||||
func (e *SysUser) Insert(c *dto.SysUserControl) error {
|
||||
func (e *SysUser) Insert(c *dto.SysUserInsertReq) error {
|
||||
var err error
|
||||
var data models.SysUser
|
||||
var i int64
|
||||
@@ -84,7 +84,31 @@ func (e *SysUser) Insert(c *dto.SysUserControl) error {
|
||||
}
|
||||
|
||||
// Update 修改SysUser对象
|
||||
func (e *SysUser) Update(c *dto.SysUserControl, p *actions.DataPermission) error {
|
||||
func (e *SysUser) Update(c *dto.SysUserUpdateReq, p *actions.DataPermission) error {
|
||||
var err error
|
||||
var model models.SysUser
|
||||
db := e.Orm.Scopes(
|
||||
actions.Permission(model.TableName(), p),
|
||||
).First(&model, c.GetId())
|
||||
if err = db.Error; err != nil {
|
||||
e.Log.Errorf("Service UpdateSysUser error: %s", err)
|
||||
return err
|
||||
}
|
||||
if db.RowsAffected == 0 {
|
||||
return errors.New("无权更新该数据")
|
||||
|
||||
}
|
||||
c.Generate(&model)
|
||||
err = e.Orm.Save(&model).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("Service UpdateSysUser error: %s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateSysUserAvatar 更新用户头像
|
||||
func (e *SysUser) UpdateSysUserAvatar(c *dto.UpdateSysUserAvatarReq, p *actions.DataPermission) error {
|
||||
var err error
|
||||
var model models.SysUser
|
||||
db := e.Orm.Scopes(
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package apis
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/shirou/gopsutil/host"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
@@ -23,6 +27,20 @@ type ServerMonitor struct {
|
||||
api.Api
|
||||
}
|
||||
|
||||
//获取相差时间
|
||||
func GetHourDiffer(startTime, endTime string) int64 {
|
||||
var hour int64
|
||||
t1, err := time.ParseInLocation("2006-01-02 15:04:05", startTime, time.Local)
|
||||
t2, err := time.ParseInLocation("2006-01-02 15:04:05", endTime, time.Local)
|
||||
if err == nil && t1.Before(t2) {
|
||||
diff := t2.Unix() - t1.Unix() //
|
||||
hour = diff / 3600
|
||||
return hour
|
||||
} else {
|
||||
return hour
|
||||
}
|
||||
}
|
||||
|
||||
// ServerInfo 获取系统信息
|
||||
// @Summary 系统信息
|
||||
// @Description 获取JSON
|
||||
@@ -33,6 +51,7 @@ type ServerMonitor struct {
|
||||
func (e ServerMonitor) ServerInfo(c *gin.Context) {
|
||||
e.Context = c
|
||||
|
||||
sysInfo, err := host.Info()
|
||||
osDic := make(map[string]interface{}, 0)
|
||||
osDic["goOs"] = runtime.GOOS
|
||||
osDic["arch"] = runtime.GOARCH
|
||||
@@ -42,6 +61,8 @@ func (e ServerMonitor) ServerInfo(c *gin.Context) {
|
||||
osDic["numGoroutine"] = runtime.NumGoroutine()
|
||||
osDic["ip"] = pkg.GetLocaHonst()
|
||||
osDic["projectDir"] = pkg.GetCurrentPath()
|
||||
osDic["hostName"] = sysInfo.Hostname
|
||||
osDic["time"] = time.Now().Format("2006-01-02 15:04:05")
|
||||
|
||||
dis, _ := disk.Usage("/")
|
||||
diskTotalGB := int(dis.Total) / GB
|
||||
@@ -67,11 +88,29 @@ func (e ServerMonitor) ServerInfo(c *gin.Context) {
|
||||
cpuDic["Percent"] = pkg.Round(percent[0], 2)
|
||||
cpuDic["cpuNum"], _ = cpu.Counts(false)
|
||||
|
||||
//服务器磁盘信息
|
||||
disklist := make([]disk.UsageStat, 0)
|
||||
//所有分区
|
||||
diskInfo, err := disk.Partitions(true)
|
||||
if err == nil {
|
||||
for _, p := range diskInfo {
|
||||
diskDetail, err := disk.Usage(p.Mountpoint)
|
||||
if err == nil {
|
||||
diskDetail.UsedPercent, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", diskDetail.UsedPercent), 64)
|
||||
diskDetail.Total = diskDetail.Total / 1024 / 1024
|
||||
diskDetail.Used = diskDetail.Used / 1024 / 1024
|
||||
diskDetail.Free = diskDetail.Free / 1024 / 1024
|
||||
disklist = append(disklist, *diskDetail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
e.Custom(gin.H{
|
||||
"code": 200,
|
||||
"os": osDic,
|
||||
"mem": memDic,
|
||||
"cpu": cpuDic,
|
||||
"disk": diskDic,
|
||||
"diskList": disklist,
|
||||
})
|
||||
}
|
||||
|
||||
+31
-100
@@ -83,7 +83,7 @@ func (e Gen) Preview(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
tab, _ := table.Get(db)
|
||||
tab, _ := table.Get(db,false)
|
||||
var b1 bytes.Buffer
|
||||
err = t1.Execute(&b1, tab)
|
||||
var b2 bytes.Buffer
|
||||
@@ -129,13 +129,9 @@ func (e Gen) GenCode(c *gin.Context) {
|
||||
}
|
||||
|
||||
table.TableId = id
|
||||
tab, _ := table.Get(db)
|
||||
tab, _ := table.Get(db,false)
|
||||
|
||||
if tab.IsActions == 1 {
|
||||
e.ActionsGen(c, tab)
|
||||
} else {
|
||||
e.NOActionsGen(c, tab)
|
||||
}
|
||||
e.NOActionsGen(c, tab)
|
||||
|
||||
e.OK("", "Code generated successfully!")
|
||||
}
|
||||
@@ -159,7 +155,7 @@ func (e Gen) GenApiToFile(c *gin.Context) {
|
||||
}
|
||||
|
||||
table.TableId = id
|
||||
tab, _ := table.Get(db)
|
||||
tab, _ := table.Get(db,false)
|
||||
e.genApiToFile(c, tab)
|
||||
|
||||
e.OK("", "Code generated successfully!")
|
||||
@@ -168,6 +164,7 @@ func (e Gen) GenApiToFile(c *gin.Context) {
|
||||
func (e Gen) NOActionsGen(c *gin.Context, tab tools.SysTables) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
tab.MLTBName = strings.Replace(tab.TBName, "_", "-", -1)
|
||||
|
||||
basePath := "template/v4/"
|
||||
routerFile := basePath + "no_actions/router_check_role.go.template"
|
||||
@@ -223,8 +220,13 @@ func (e Gen) NOActionsGen(c *gin.Context, tab tools.SysTables) {
|
||||
_ = pkg.PathCreate("./app/" + tab.PackageName + "/models/")
|
||||
_ = pkg.PathCreate("./app/" + tab.PackageName + "/router/")
|
||||
_ = pkg.PathCreate("./app/" + tab.PackageName + "/service/dto/")
|
||||
_ = pkg.PathCreate(config.GenConfig.FrontPath + "/api/")
|
||||
_ = pkg.PathCreate(config.GenConfig.FrontPath + "/views/" + tab.ModuleFrontName)
|
||||
_ = pkg.PathCreate(config.GenConfig.FrontPath + "/api/" + tab.PackageName + "/")
|
||||
err = pkg.PathCreate(config.GenConfig.FrontPath + "/views/" + tab.PackageName + "/" + tab.MLTBName + "/")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, fmt.Sprintf("views目录创建失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
var b1 bytes.Buffer
|
||||
err = t1.Execute(&b1, tab)
|
||||
@@ -240,13 +242,13 @@ func (e Gen) NOActionsGen(c *gin.Context, tab tools.SysTables) {
|
||||
err = t6.Execute(&b6, tab)
|
||||
var b7 bytes.Buffer
|
||||
err = t7.Execute(&b7, tab)
|
||||
pkg.FileCreate(b1, "./app/"+tab.PackageName+"/models/"+tab.ModuleName+".go")
|
||||
pkg.FileCreate(b2, "./app/"+tab.PackageName+"/apis/"+tab.ModuleName+".go")
|
||||
pkg.FileCreate(b3, "./app/"+tab.PackageName+"/router/"+tab.ModuleName+".go")
|
||||
pkg.FileCreate(b4, config.GenConfig.FrontPath+"/api/"+tab.ModuleFrontName+".js")
|
||||
pkg.FileCreate(b5, config.GenConfig.FrontPath+"/views/"+tab.ModuleFrontName+"/index.vue")
|
||||
pkg.FileCreate(b6, "./app/"+tab.PackageName+"/service/dto/"+tab.ModuleName+".go")
|
||||
pkg.FileCreate(b7, "./app/"+tab.PackageName+"/service/"+tab.ModuleName+".go")
|
||||
pkg.FileCreate(b1, "./app/"+tab.PackageName+"/models/"+tab.TBName+".go")
|
||||
pkg.FileCreate(b2, "./app/"+tab.PackageName+"/apis/"+tab.TBName+".go")
|
||||
pkg.FileCreate(b3, "./app/"+tab.PackageName+"/router/"+tab.TBName+".go")
|
||||
pkg.FileCreate(b4, config.GenConfig.FrontPath+"/api/"+tab.PackageName+"/"+tab.MLTBName+".js")
|
||||
pkg.FileCreate(b5, config.GenConfig.FrontPath+"/views/"+tab.PackageName+"/"+tab.MLTBName+"/index.vue")
|
||||
pkg.FileCreate(b6, "./app/"+tab.PackageName+"/service/dto/"+tab.TBName+".go")
|
||||
pkg.FileCreate(b7, "./app/"+tab.PackageName+"/service/"+tab.TBName+".go")
|
||||
|
||||
}
|
||||
|
||||
@@ -279,78 +281,6 @@ func (e Gen) genApiToFile(c *gin.Context, tab tools.SysTables) {
|
||||
|
||||
}
|
||||
|
||||
func (e Gen) ActionsGen(c *gin.Context, tab tools.SysTables) {
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
basePath := "template/v4/"
|
||||
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")
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, fmt.Sprintf("model模版解析失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t3, err := template.ParseFiles(routerFile)
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, fmt.Sprintf("路由模版解析失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t4, err := template.ParseFiles(basePath + "js.go.template")
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, fmt.Sprintf("js模版解析失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t5, err := template.ParseFiles(basePath + "vue.go.template")
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, fmt.Sprintf("vue模版解析失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t6, err := template.ParseFiles(basePath + "dto.go.template")
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, fmt.Sprintf("dto模版解析失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
_ = pkg.PathCreate("./app/" + tab.PackageName + "/models/")
|
||||
_ = pkg.PathCreate("./app/" + tab.PackageName + "/router/")
|
||||
_ = pkg.PathCreate("./app/" + tab.PackageName + "/service/dto/")
|
||||
_ = pkg.PathCreate(config.GenConfig.FrontPath + "/api/")
|
||||
_ = pkg.PathCreate(config.GenConfig.FrontPath + "/views/" + tab.ModuleFrontName)
|
||||
|
||||
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)
|
||||
|
||||
pkg.FileCreate(b1, "./app/"+tab.PackageName+"/models/"+tab.ModuleName+".go")
|
||||
pkg.FileCreate(b3, "./app/"+tab.PackageName+"/router/"+tab.ModuleName+".go")
|
||||
pkg.FileCreate(b4, config.GenConfig.FrontPath+"/api/"+tab.ModuleFrontName+".js")
|
||||
pkg.FileCreate(b5, config.GenConfig.FrontPath+"/views/"+tab.ModuleFrontName+"/index.vue")
|
||||
pkg.FileCreate(b6, "./app/"+tab.PackageName+"/service/dto/"+tab.ModuleName+".go")
|
||||
}
|
||||
|
||||
func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
s := service.SysMenu{}
|
||||
err := e.MakeContext(c).
|
||||
@@ -365,19 +295,20 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
|
||||
table := tools.SysTables{}
|
||||
id, err := pkg.StringToInt(c.Param("tableId"))
|
||||
if err != nil{
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500,err,fmt.Sprintf("tableId参数解析失败!错误详情:%s", err.Error()))
|
||||
e.Error(500, err, fmt.Sprintf("tableId参数解析失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
table.TableId = id
|
||||
tab, _ := table.Get(e.Orm)
|
||||
tab, _ := table.Get(e.Orm,true)
|
||||
tab.MLTBName = strings.Replace(tab.TBName, "_", "-", -1)
|
||||
|
||||
Mmenu := dto.SysMenuControl{}
|
||||
Mmenu.Title = tab.TableComment
|
||||
Mmenu.Icon = "pass"
|
||||
Mmenu.Path = "/" + strings.Replace(tab.TBName, "_", "-", -1)
|
||||
Mmenu.Path = "/" + tab.MLTBName
|
||||
Mmenu.MenuType = "M"
|
||||
Mmenu.Action = "无"
|
||||
Mmenu.ParentId = 0
|
||||
@@ -393,13 +324,13 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
Cmenu.MenuName = tab.ClassName + "Manage"
|
||||
Cmenu.Title = tab.TableComment
|
||||
Cmenu.Icon = "pass"
|
||||
Cmenu.Path = tab.TBName
|
||||
Cmenu.Path = "/" + tab.PackageName + "/" + tab.MLTBName
|
||||
Cmenu.MenuType = "C"
|
||||
Cmenu.Action = "无"
|
||||
Cmenu.Permission = tab.PackageName + ":" + tab.ModuleFrontName + ":list"
|
||||
Cmenu.Permission = tab.PackageName + ":" + tab.BusinessName + ":list"
|
||||
Cmenu.ParentId = Mmenu.MenuId
|
||||
Cmenu.NoCache = false
|
||||
Cmenu.Component = "/" + tab.ModuleFrontName + "/index"
|
||||
Cmenu.Component = "/" + tab.PackageName + "/" + tab.MLTBName + "/index"
|
||||
Cmenu.Sort = 0
|
||||
Cmenu.Visible = "0"
|
||||
Cmenu.IsFrame = "0"
|
||||
@@ -414,7 +345,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
MList.Path = tab.TBName
|
||||
MList.MenuType = "F"
|
||||
MList.Action = "无"
|
||||
MList.Permission = tab.PackageName + ":" + tab.ModuleFrontName + ":query"
|
||||
MList.Permission = tab.PackageName + ":" + tab.BusinessName + ":query"
|
||||
MList.ParentId = Cmenu.MenuId
|
||||
MList.NoCache = false
|
||||
MList.Sort = 0
|
||||
@@ -431,7 +362,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
MCreate.Path = tab.TBName
|
||||
MCreate.MenuType = "F"
|
||||
MCreate.Action = "无"
|
||||
MCreate.Permission = tab.PackageName + ":" + tab.ModuleFrontName + ":add"
|
||||
MCreate.Permission = tab.PackageName + ":" + tab.BusinessName + ":add"
|
||||
MCreate.ParentId = Cmenu.MenuId
|
||||
MCreate.NoCache = false
|
||||
MCreate.Sort = 0
|
||||
@@ -448,7 +379,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
MUpdate.Path = tab.TBName
|
||||
MUpdate.MenuType = "F"
|
||||
MUpdate.Action = "无"
|
||||
MUpdate.Permission = tab.PackageName + ":" + tab.ModuleFrontName + ":edit"
|
||||
MUpdate.Permission = tab.PackageName + ":" + tab.BusinessName + ":edit"
|
||||
MUpdate.ParentId = Cmenu.MenuId
|
||||
MUpdate.NoCache = false
|
||||
MUpdate.Sort = 0
|
||||
@@ -465,7 +396,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
MDelete.Path = tab.TBName
|
||||
MDelete.MenuType = "F"
|
||||
MDelete.Action = "无"
|
||||
MDelete.Permission = tab.PackageName + ":" + tab.ModuleFrontName + ":remove"
|
||||
MDelete.Permission = tab.PackageName + ":" + tab.BusinessName + ":remove"
|
||||
MDelete.ParentId = Cmenu.MenuId
|
||||
MDelete.NoCache = false
|
||||
MDelete.Sort = 0
|
||||
|
||||
@@ -79,7 +79,7 @@ func (e SysTable) Get(c *gin.Context) {
|
||||
|
||||
var data tools.SysTables
|
||||
data.TableId, _ = pkg.StringToInt(c.Param("tableId"))
|
||||
result, err := data.Get(db)
|
||||
result, err := data.Get(db,true)
|
||||
if err != nil {
|
||||
log.Errorf("Get error, %s", err.Error())
|
||||
e.Error(500, err, "")
|
||||
@@ -106,7 +106,7 @@ func (e SysTable) GetSysTablesInfo(c *gin.Context) {
|
||||
if c.Request.FormValue("tableName") != "" {
|
||||
data.TBName = c.Request.FormValue("tableName")
|
||||
}
|
||||
result, err := data.Get(db)
|
||||
result, err := data.Get(db,true)
|
||||
if err != nil {
|
||||
log.Errorf("Get error, %s", err.Error())
|
||||
e.Error(500, err, "抱歉未找到相关信息")
|
||||
@@ -202,15 +202,23 @@ func genTableInit(tx *gorm.DB, tablesList []string, i int, c *gin.Context) (tool
|
||||
for i := 0; i < len(tablenamelist); i++ {
|
||||
strStart := string([]byte(tablenamelist[i])[:1])
|
||||
strend := string([]byte(tablenamelist[i])[1:])
|
||||
// 大驼峰表名 结构体使用
|
||||
data.ClassName += strings.ToUpper(strStart) + strend
|
||||
// 小驼峰表名 js函数名和权限标识使用
|
||||
if i == 0 {
|
||||
data.BusinessName += strings.ToLower(strStart) + strend
|
||||
} else {
|
||||
data.BusinessName += strings.ToUpper(strStart) + strend
|
||||
}
|
||||
//data.PackageName += strings.ToLower(strStart) + strings.ToLower(strend)
|
||||
data.ModuleName += strings.ToLower(strStart) + strings.ToLower(strend)
|
||||
//data.ModuleName += strings.ToLower(strStart) + strings.ToLower(strend)
|
||||
}
|
||||
data.ModuleFrontName = strings.ReplaceAll(data.ModuleName, "_", "-")
|
||||
//data.ModuleFrontName = strings.ReplaceAll(data.ModuleName, "_", "-")
|
||||
data.PackageName = "admin"
|
||||
data.TplCategory = "crud"
|
||||
data.Crud = true
|
||||
|
||||
// 中横线表名称,接口路径、前端文件夹名称和js名称使用
|
||||
data.ModuleName = strings.Replace(data.TBName, "_", "-", -1)
|
||||
dbcolumn, err := dbColumn.GetList(tx)
|
||||
data.CreateBy = 0
|
||||
data.TableComment = dbtable.TableComment
|
||||
@@ -219,7 +227,7 @@ func genTableInit(tx *gorm.DB, tablesList []string, i int, c *gin.Context) (tool
|
||||
}
|
||||
|
||||
data.FunctionName = data.TableComment
|
||||
data.BusinessName = data.ModuleName
|
||||
//data.BusinessName = data.ModuleName
|
||||
data.IsLogicalDelete = "1"
|
||||
data.LogicalDelete = true
|
||||
data.LogicalDeleteColumn = "is_del"
|
||||
@@ -350,4 +358,4 @@ func (e SysTable) Delete(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
e.OK(nil, "删除成功")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,12 +51,20 @@ func (SysColumns) TableName() string {
|
||||
return "sys_columns"
|
||||
}
|
||||
|
||||
func (e *SysColumns) GetList(tx *gorm.DB) ([]SysColumns, error) {
|
||||
func (e *SysColumns) GetList(tx *gorm.DB, exclude bool) ([]SysColumns, error) {
|
||||
var doc []SysColumns
|
||||
|
||||
table := tx.Table("sys_columns")
|
||||
|
||||
table = table.Where("table_id = ?", e.TableId)
|
||||
table = table.Where("table_id = ? ", e.TableId)
|
||||
if exclude {
|
||||
notIn := make([]string, 6)
|
||||
notIn = append(notIn, "id")
|
||||
notIn = append(notIn, "create_by")
|
||||
notIn = append(notIn, "update_by")
|
||||
notIn = append(notIn, "created_at")
|
||||
notIn = append(notIn, "updated_at")
|
||||
notIn = append(notIn, "deleted_at")
|
||||
table = table.Where(" column_name not in(?)", notIn)
|
||||
}
|
||||
|
||||
if err := table.Find(&doc).Error; err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
type SysTables struct {
|
||||
TableId int `gorm:"primaryKey;autoIncrement" json:"tableId"` //表编码
|
||||
TBName string `gorm:"column:table_name;size:255;" json:"tableName"` //表名称
|
||||
MLTBName string `gorm:"-" json:"-"` //表名称
|
||||
TableComment string `gorm:"size:255;" json:"tableComment"` //表备注
|
||||
ClassName string `gorm:"size:255;" json:"className"` //类名
|
||||
TplCategory string `gorm:"size:255;" json:"tplCategory"` //
|
||||
@@ -77,7 +78,7 @@ func (e *SysTables) GetPage(tx *gorm.DB, pageSize int, pageIndex int) ([]SysTabl
|
||||
return doc, int(count), nil
|
||||
}
|
||||
|
||||
func (e *SysTables) Get(tx *gorm.DB) (SysTables, error) {
|
||||
func (e *SysTables) Get(tx *gorm.DB, exclude bool) (SysTables, error) {
|
||||
var doc SysTables
|
||||
var err error
|
||||
table := tx.Table("sys_tables")
|
||||
@@ -97,7 +98,7 @@ func (e *SysTables) Get(tx *gorm.DB) (SysTables, error) {
|
||||
}
|
||||
var col SysColumns
|
||||
col.TableId = doc.TableId
|
||||
if doc.Columns, err = col.GetList(tx); err != nil {
|
||||
if doc.Columns, err = col.GetList(tx, exclude); err != nil {
|
||||
return doc, err
|
||||
}
|
||||
|
||||
@@ -126,7 +127,7 @@ func (e *SysTables) GetTree(tx *gorm.DB) ([]SysTables, error) {
|
||||
var col SysColumns
|
||||
//col.FkCol = append(col.FkCol, SysColumns{ColumnId: 0, ColumnName: "请选择"})
|
||||
col.TableId = doc[i].TableId
|
||||
if doc[i].Columns, err = col.GetList(tx); err != nil {
|
||||
if doc[i].Columns, err = col.GetList(tx, false); err != nil {
|
||||
return doc, err
|
||||
}
|
||||
|
||||
@@ -188,16 +189,17 @@ func (e *SysTables) Update(tx *gorm.DB) (update SysTables, err error) {
|
||||
t, ok := tableMap[e.Columns[i].FkTableName]
|
||||
if ok {
|
||||
e.Columns[i].FkTableNameClass = t.ClassName
|
||||
e.Columns[i].FkTableNamePackage = t.ModuleName
|
||||
t.MLTBName = strings.Replace(t.TBName, "_", "-", -1)
|
||||
e.Columns[i].FkTableNamePackage = t.MLTBName
|
||||
} else {
|
||||
tableNameList := strings.Split(e.Columns[i].FkTableName, "_")
|
||||
e.Columns[i].FkTableNameClass = ""
|
||||
e.Columns[i].FkTableNamePackage = ""
|
||||
//e.Columns[i].FkTableNamePackage = ""
|
||||
for a := 0; a < len(tableNameList); a++ {
|
||||
strStart := string([]byte(tableNameList[a])[:1])
|
||||
strEnd := string([]byte(tableNameList[a])[1:])
|
||||
e.Columns[i].FkTableNameClass += strings.ToUpper(strStart) + strEnd
|
||||
e.Columns[i].FkTableNamePackage += strings.ToLower(strStart) + strings.ToLower(strEnd)
|
||||
//e.Columns[i].FkTableNamePackage += strings.ToLower(strStart) + strings.ToLower(strEnd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/utils"
|
||||
"github.com/spf13/cobra"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var (
|
||||
appName string
|
||||
StartCmd = &cobra.Command{
|
||||
Use: "createapp",
|
||||
Short: "Create a new app",
|
||||
Long: "Use when you need to create a new app",
|
||||
Example: "go-admin createapp -n admin",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
run()
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
StartCmd.PersistentFlags().StringVarP(&appName, "name", "n", "", "Start server with provided configuration file")
|
||||
}
|
||||
|
||||
func run() {
|
||||
|
||||
fmt.Println(`start init`)
|
||||
//1. 读取配置
|
||||
|
||||
fmt.Println(`generate migration file`)
|
||||
_ = genFile()
|
||||
|
||||
}
|
||||
|
||||
func genFile() error {
|
||||
if appName == "" {
|
||||
return errors.New("arg `name` invalid :name is empty")
|
||||
}
|
||||
path := "app/"
|
||||
appPath := path + appName
|
||||
err := utils.IsNotExistMkDir(appPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
apiPath := appPath + "/apis/"
|
||||
err = utils.IsNotExistMkDir(apiPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
modelsPath := appPath + "/models/"
|
||||
err = utils.IsNotExistMkDir(modelsPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
routerPath := appPath + "/router/"
|
||||
err = utils.IsNotExistMkDir(routerPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
servicePath := appPath + "/service/"
|
||||
err = utils.IsNotExistMkDir(servicePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dtoPath := appPath + "/service/dto/"
|
||||
err = utils.IsNotExistMkDir(dtoPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
t1, err := template.ParseFiles("template/cmd_api.template")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m := map[string]string{}
|
||||
m["appName"] = appName
|
||||
var b1 bytes.Buffer
|
||||
err = t1.Execute(&b1, m)
|
||||
pkg.FileCreate(b1, "./cmd/api/"+appName+".go")
|
||||
t2, err := template.ParseFiles("template/router.template")
|
||||
var b2 bytes.Buffer
|
||||
err = t2.Execute(&b2, nil)
|
||||
pkg.FileCreate(b2, appPath+"/router/router.go")
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package models
|
||||
|
||||
type TbDemo struct {
|
||||
Model
|
||||
Name string `json:"name" gorm:"type:varchar(128);comment:名称"`
|
||||
ModelTime
|
||||
ControlBy
|
||||
}
|
||||
|
||||
func (TbDemo) TableName() string {
|
||||
return "tb_demo"
|
||||
}
|
||||
@@ -35,6 +35,7 @@ func _1599190683659Tables(db *gorm.DB, version string) error {
|
||||
new(models.SysJob),
|
||||
new(models.SysConfig),
|
||||
new(models.SysApi),
|
||||
new(models.TbDemo),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -2,7 +2,7 @@ package global
|
||||
|
||||
const (
|
||||
// Version go-admin version info
|
||||
Version = "2.0.0-beta.7"
|
||||
Version = "2.0.0"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -23,6 +23,5 @@ func GetClientIP(c *gin.Context) string {
|
||||
if ClientIP != "127.0.0.1" {
|
||||
ip = ClientIP
|
||||
}
|
||||
//fmt.Println("ip:", ip)
|
||||
return ip
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package middleware
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"go-admin/common"
|
||||
gaConfig "go-admin/config"
|
||||
@@ -56,16 +57,16 @@ func LoggerToFile() gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
//rt, bl := c.Get("result")
|
||||
rt, bl := c.Get("result")
|
||||
var result = ""
|
||||
//if bl {
|
||||
// rb, err := json.Marshal(rt)
|
||||
// if err != nil {
|
||||
// log.Warnf("json Marshal result error, %s", err.Error())
|
||||
// } else {
|
||||
// result = string(rb)
|
||||
// }
|
||||
//}
|
||||
if bl {
|
||||
rb, err := json.Marshal(rt)
|
||||
if err != nil {
|
||||
log.Warnf("json Marshal result error, %s", err.Error())
|
||||
} else {
|
||||
result = string(rb)
|
||||
}
|
||||
}
|
||||
|
||||
st, bl := c.Get("status")
|
||||
var statusBus = 0
|
||||
|
||||
+2
-2
@@ -199,7 +199,7 @@ COMMIT;
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO `sys_menu` VALUES (2, 'Admin', '系统管理', 'api-server', '/admin', '/0/2', 'M', '无', '', 0, 1, '', 'Layout', 10, '0', '1', 0, 1, '2021-05-20 21:58:45.679', '2021-06-17 11:48:40.703', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (3, 'SysUserManage', '管理员管理', 'user', '/admin/sys-user', '/0/2/3', 'C', '无', 'admin:sysUser:list', 2, 0, '', '/admin/sys-user/index', 10, '0', '1', 0, 1, '2021-05-20 22:08:44.526', '2021-06-17 20:31:14.305', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (3, 'SysUserManage', '用户管理', 'user', '/admin/sys-user', '/0/2/3', 'C', '无', 'admin:sysUser:list', 2, 0, '', '/admin/sys-user/index', 10, '0', '1', 0, 1, '2021-05-20 22:08:44.526', '2021-06-17 20:31:14.305', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (43, '', '新增管理员1', 'app-group-fill', '', '/0/2/3/43', 'F', 'POST', 'admin:sysUser:add', 3, 0, '', '', 10, '0', '1', 0, 1, '2021-05-20 22:08:44.526', '2021-06-17 20:31:14.305', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (44, '', '查询管理员', 'app-group-fill', '', '/0/2/3/44', 'F', 'GET', 'admin:sysUser:query', 3, 0, '', '', 40, '0', '1', 0, 1, '2021-05-20 22:08:44.526', '2021-06-17 20:31:14.305', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (45, '', '修改管理员', 'app-group-fill', '', '/0/2/3/45', 'F', 'PUT', 'admin:sysUser:edit', 3, 0, '', '', 30, '0', '1', 0, 1, '2021-05-20 22:08:44.526', '2021-06-17 20:31:14.305', NULL);
|
||||
@@ -363,4 +363,4 @@ COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
-- 数据完成 ;
|
||||
-- 数据完成 ;
|
||||
|
||||
+7
-6
@@ -48,11 +48,12 @@ settings:
|
||||
demo:
|
||||
name: data
|
||||
cache:
|
||||
redis:
|
||||
addr: 127.0.0.1:6379
|
||||
password: xxxxxx
|
||||
db: 2
|
||||
# memory: '' key存在即可
|
||||
# redis:
|
||||
# addr: 127.0.0.1:6379
|
||||
# password: xxxxxx
|
||||
# db: 2
|
||||
# key存在即可
|
||||
memory: ''
|
||||
queue:
|
||||
memory:
|
||||
poolSize: 100
|
||||
@@ -69,4 +70,4 @@ settings:
|
||||
# blockingTimeout: 5
|
||||
# reclaimInterval: 1
|
||||
locker:
|
||||
redis:
|
||||
redis:
|
||||
|
||||
@@ -6,11 +6,11 @@ require (
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
|
||||
github.com/alibaba/sentinel-golang v0.6.1
|
||||
github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5
|
||||
github.com/bytedance/go-tagexpr/v2 v2.7.10
|
||||
github.com/bytedance/go-tagexpr/v2 v2.7.12
|
||||
github.com/casbin/casbin/v2 v2.25.1
|
||||
github.com/gin-gonic/gin v1.7.1
|
||||
github.com/go-admin-team/go-admin-core v1.3.5-rc.6.0.20210629084023-dc3d0627688c
|
||||
github.com/go-admin-team/go-admin-core/sdk v1.3.5-rc.6.0.20210629084023-dc3d0627688c
|
||||
github.com/gin-gonic/gin v1.7.2
|
||||
github.com/go-admin-team/go-admin-core v1.3.6
|
||||
github.com/go-admin-team/go-admin-core/sdk v1.3.6
|
||||
github.com/google/uuid v1.2.0
|
||||
github.com/mssola/user_agent v0.5.2
|
||||
github.com/opentracing/opentracing-go v1.1.0
|
||||
@@ -28,7 +28,7 @@ require (
|
||||
gorm.io/driver/mysql v1.0.4-0.20201206014609-ae5fd10184f6
|
||||
gorm.io/driver/postgres v1.0.6-0.20201208020313-1ed927cfab53
|
||||
gorm.io/driver/sqlite v1.1.5-0.20201206014648-c84401fbe3ba
|
||||
gorm.io/gorm v1.21.10
|
||||
gorm.io/gorm v1.21.11
|
||||
)
|
||||
|
||||
//replace (
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package api
|
||||
|
||||
import "go-admin/app/{{.appName}}/router"
|
||||
|
||||
func init() {
|
||||
//注册路由 fixme 其他应用的路由,在本目录新建文件放在init方法
|
||||
AppRouters = append(AppRouters, router.InitRouter)
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package router
|
||||
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
_ "github.com/gin-gonic/gin"
|
||||
log "github.com/go-admin-team/go-admin-core/logger"
|
||||
"github.com/go-admin-team/go-admin-core/sdk"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
|
||||
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
|
||||
common "go-admin/common/middleware"
|
||||
"os"
|
||||
)
|
||||
|
||||
var (
|
||||
routerNoCheckRole = make([]func(*gin.RouterGroup), 0)
|
||||
routerCheckRole = make([]func(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware), 0)
|
||||
)
|
||||
|
||||
// InitRouter 路由初始化
|
||||
func InitRouter() {
|
||||
var r *gin.Engine
|
||||
h := sdk.Runtime.GetEngine()
|
||||
if h == nil {
|
||||
h = gin.New()
|
||||
sdk.Runtime.SetEngine(h)
|
||||
}
|
||||
switch h.(type) {
|
||||
case *gin.Engine:
|
||||
r = h.(*gin.Engine)
|
||||
default:
|
||||
log.Fatal("not support other engine")
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
r.Use(common.Sentinel()).
|
||||
Use(common.RequestId(pkg.TrafficKey))
|
||||
common.InitMiddleware(r)
|
||||
// the jwt middleware
|
||||
authMiddleware, err := common.AuthInit()
|
||||
if err != nil {
|
||||
log.Fatalf("JWT Init Error, %s", err.Error())
|
||||
}
|
||||
|
||||
// 注册业务路由
|
||||
InitBusinessRouter(r, authMiddleware)
|
||||
}
|
||||
|
||||
func InitBusinessRouter(r *gin.Engine, authMiddleware *jwt.GinJWTMiddleware) *gin.Engine {
|
||||
|
||||
// 无需认证的路由
|
||||
noCheckRoleRouter(r)
|
||||
// 需要认证的路由
|
||||
checkRoleRouter(r, authMiddleware)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// noCheckRoleRouter 无需认证的路由
|
||||
func noCheckRoleRouter(r *gin.Engine) {
|
||||
// 可根据业务需求来设置接口版本
|
||||
v := r.Group("")
|
||||
|
||||
for _, f := range routerNoCheckRole {
|
||||
f(v)
|
||||
}
|
||||
}
|
||||
|
||||
// checkRoleRouter 需要认证的路由
|
||||
func checkRoleRouter(r *gin.Engine, authMiddleware *jwtauth.GinJWTMiddleware) {
|
||||
// 可根据业务需求来设置接口版本
|
||||
v := r.Group("")
|
||||
|
||||
for _, f := range routerCheckRole {
|
||||
f(v, authMiddleware)
|
||||
}
|
||||
}
|
||||
+77
-23
@@ -1,16 +1,26 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
|
||||
"go-admin/app/{{.PackageName}}/models"
|
||||
"go-admin/common/dto"
|
||||
common "go-admin/common/models"
|
||||
|
||||
{{- $bb := false -}}
|
||||
{{- range .Columns -}}
|
||||
{{$z := .IsQuery}}
|
||||
{{- if ($z) }}
|
||||
{{if eq .GoType "time.Time"}}{{- $bb = true -}}{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- range .Columns -}}
|
||||
{{if eq .GoType "time.Time"}}{{- $bb = true -}}{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if eq $bb true -}}
|
||||
"time"
|
||||
{{- end }}
|
||||
)
|
||||
|
||||
type {{.ClassName}}Search struct {
|
||||
type {{.ClassName}}GetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
{{- $tablename := .TBName -}}
|
||||
{{- range .Columns -}}
|
||||
@@ -26,18 +36,18 @@ type {{.ClassName}}Order struct {
|
||||
{{- $tablename := .TBName -}}
|
||||
{{- range .Columns -}}
|
||||
{{.GoField}} {{.GoType}} `form:"{{.JsonField}}Order" search:"type:order;column:{{.ColumnName}};table:{{$tablename}}"`
|
||||
{{- end }}
|
||||
{{ end }}
|
||||
}
|
||||
|
||||
func (m *{{.ClassName}}Search) GetNeedSearch() interface{} {
|
||||
func (m *{{.ClassName}}GetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
type {{.ClassName}}Control struct {
|
||||
type {{.ClassName}}InsertReq struct {
|
||||
{{- range .Columns -}}
|
||||
{{$x := .Pk}}
|
||||
{{- if ($x) }}
|
||||
{{.GoField}} {{.GoType}} `uri:"{{.JsonField}}" comment:"{{.ColumnComment}}"` // {{.ColumnComment}}
|
||||
{{.GoField}} {{.GoType}} `json:"-" comment:"{{.ColumnComment}}"` // {{.ColumnComment}}
|
||||
{{- else if eq .GoField "CreatedAt" -}}
|
||||
{{- else if eq .GoField "UpdatedAt" -}}
|
||||
{{- else if eq .GoField "DeletedAt" -}}
|
||||
@@ -47,9 +57,10 @@ type {{.ClassName}}Control struct {
|
||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}Control) Generate(model *models.SysConfig) {
|
||||
func (s *{{.ClassName}}InsertReq) Generate(model *models.{{.ClassName}}) {
|
||||
{{- range .Columns -}}
|
||||
{{$x := .Pk}}
|
||||
{{- if ($x) }}
|
||||
@@ -67,24 +78,67 @@ func (s *{{.ClassName}}Control) Generate(model *models.SysConfig) {
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}Control) GetId() interface{} {
|
||||
func (s *{{.ClassName}}InsertReq) GetId() interface{} {
|
||||
return s.{{.PkGoField}}
|
||||
}
|
||||
|
||||
type {{.ClassName}}ById struct {
|
||||
Id int `uri:"id"`
|
||||
Ids []int `json:"ids"`
|
||||
type {{.ClassName}}UpdateReq struct {
|
||||
{{- range .Columns -}}
|
||||
{{$x := .Pk}}
|
||||
{{- if ($x) }}
|
||||
{{.GoField}} {{.GoType}} `uri:"{{.JsonField}}" comment:"{{.ColumnComment}}"` // {{.ColumnComment}}
|
||||
{{- else if eq .GoField "CreatedAt" -}}
|
||||
{{- else if eq .GoField "UpdatedAt" -}}
|
||||
{{- else if eq .GoField "DeletedAt" -}}
|
||||
{{- else if eq .GoField "CreateBy" -}}
|
||||
{{- else if eq .GoField "UpdateBy" -}}
|
||||
{{- else }}
|
||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}ById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
func (s *{{.ClassName}}UpdateReq) Generate(model *models.{{.ClassName}}) {
|
||||
{{- range .Columns -}}
|
||||
{{$x := .Pk}}
|
||||
{{- if ($x) }}
|
||||
if s.{{.GoField}} == 0 {
|
||||
model.Model = common.Model{ {{.GoField}}: s.{{.GoField}} }
|
||||
}
|
||||
{{- else if eq .GoField "CreatedAt" -}}
|
||||
{{- else if eq .GoField "UpdatedAt" -}}
|
||||
{{- else if eq .GoField "DeletedAt" -}}
|
||||
{{- else if eq .GoField "CreateBy" -}}
|
||||
{{- else if eq .GoField "UpdateBy" -}}
|
||||
{{- else }}
|
||||
model.{{.GoField}} = s.{{.GoField}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}ById) Generate() *{{.ClassName}}ById {
|
||||
o := *s
|
||||
return &o
|
||||
func (s *{{.ClassName}}UpdateReq) GetId() interface{} {
|
||||
return s.{{.PkGoField}}
|
||||
}
|
||||
|
||||
// {{.ClassName}}GetReq 功能获取请求参数
|
||||
type {{.ClassName}}GetReq struct {
|
||||
{{- range .Columns -}}
|
||||
{{$x := .Pk}}
|
||||
{{- if ($x) }}
|
||||
{{.GoField}} {{.GoType}} `uri:"{{.JsonField}}"`
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
}
|
||||
func (s *{{.ClassName}}GetReq) GetId() interface{} {
|
||||
return s.{{.PkGoField}}
|
||||
}
|
||||
|
||||
// {{.ClassName}}DeleteReq 功能删除请求参数
|
||||
type {{.ClassName}}DeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}DeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
package apis
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"net/http"
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
@@ -12,6 +11,7 @@ import (
|
||||
"go-admin/app/{{.PackageName}}/models"
|
||||
"go-admin/app/{{.PackageName}}/service"
|
||||
"go-admin/app/{{.PackageName}}/service/dto"
|
||||
"go-admin/common/actions"
|
||||
)
|
||||
|
||||
type {{.ClassName}} struct {
|
||||
@@ -35,11 +35,11 @@ type {{.ClassName}} struct {
|
||||
// @Router /api/v1/{{.ModuleName}} [get]
|
||||
// @Security Bearer
|
||||
func (e {{.ClassName}}) GetPage(c *gin.Context) {
|
||||
req := dto.{{.ClassName}}Search{}
|
||||
req := dto.{{.ClassName}}GetPageReq{}
|
||||
s := service.{{.ClassName}}{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
@@ -54,7 +54,7 @@ func (e {{.ClassName}}) GetPage(c *gin.Context) {
|
||||
|
||||
err = s.GetPage(&req, p, &list, &count)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("获取{{.TableComment}} %v 失败,\r\n失败信息 %s", req.Ids, err.Error()))
|
||||
e.Error(500, err, fmt.Sprintf("获取{{.TableComment}} 失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -69,12 +69,12 @@ func (e {{.ClassName}}) GetPage(c *gin.Context) {
|
||||
// @Success 200 {object} response.Response{data=models.{{.ClassName}}} "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/{{.ModuleName}}/{id} [get]
|
||||
// @Security Bearer
|
||||
func (e {{.ClassName}}) Get{{.ClassName}}(c *gin.Context) {
|
||||
req := dto.{{.ClassName}}ById{}
|
||||
func (e {{.ClassName}}) Get(c *gin.Context) {
|
||||
req := dto.{{.ClassName}}GetReq{}
|
||||
s := service.{{.ClassName}}{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, nil).
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
@@ -87,7 +87,7 @@ func (e {{.ClassName}}) Get{{.ClassName}}(c *gin.Context) {
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
err = s.Get(&req, p, &object)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("获取{{.TableComment}} %v 失败,\r\n失败信息 %s", req.Ids, err.Error()))
|
||||
e.Error(500, err, fmt.Sprintf("获取{{.TableComment}}失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -100,16 +100,16 @@ func (e {{.ClassName}}) Get{{.ClassName}}(c *gin.Context) {
|
||||
// @Tags {{.TableComment}}
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.{{.ClassName}}Control true "data"
|
||||
// @Param data body dto.{{.ClassName}}InsertReq true "data"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "添加成功"}"
|
||||
// @Router /api/v1/{{.ModuleName}} [post]
|
||||
// @Security Bearer
|
||||
func (e {{.ClassName}}) Insert(c *gin.Context) {
|
||||
req := dto.{{.ClassName}}Control{}
|
||||
req := dto.{{.ClassName}}InsertReq{}
|
||||
s := service.{{.ClassName}}{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
@@ -122,7 +122,7 @@ func (e {{.ClassName}}) Insert(c *gin.Context) {
|
||||
|
||||
err = s.Insert(&req)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("创建{{.TableComment}} %v 失败,\r\n失败信息 %s", req.Ids, err.Error()))
|
||||
e.Error(500, err, fmt.Sprintf("创建{{.TableComment}} 失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -135,16 +135,16 @@ func (e {{.ClassName}}) Insert(c *gin.Context) {
|
||||
// @Tags {{.TableComment}}
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.{{.ClassName}}Control true "body"
|
||||
// @Param data body dto.{{.ClassName}}UpdateReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "修改成功"}"
|
||||
// @Router /api/v1/{{.ModuleName}}/{id} [put]
|
||||
// @Security Bearer
|
||||
func (e {{.ClassName}}) Update(c *gin.Context) {
|
||||
req := dto.{{.ClassName}}Control){}
|
||||
req := dto.{{.ClassName}}UpdateReq{}
|
||||
s := service.{{.ClassName}}{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
@@ -157,10 +157,10 @@ func (e {{.ClassName}}) Update(c *gin.Context) {
|
||||
|
||||
err = s.Update(&req, p)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("修改{{.TableComment}} %v 失败,\r\n失败信息 %s", req.Ids, err.Error()))
|
||||
e.Error(500, err, fmt.Sprintf("修改{{.TableComment}} 失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK( object.GetId(), "修改成功")
|
||||
e.OK( req.GetId(), "修改成功")
|
||||
}
|
||||
|
||||
// Delete 删除{{.TableComment}}
|
||||
@@ -173,10 +173,10 @@ func (e {{.ClassName}}) Update(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e {{.ClassName}}) Delete(c *gin.Context) {
|
||||
s := service.{{.ClassName}}{}
|
||||
req := dto.{{.ClassName}}ById{}
|
||||
req := dto.{{.ClassName}}DeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
@@ -185,13 +185,13 @@ func (e {{.ClassName}}) Delete(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
req.SetUpdateBy(user.GetUserId(c))
|
||||
// req.SetUpdateBy(user.GetUserId(c))
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
err = s.Remove(&req, p)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("删除{{.TableComment}} %v 失败,\r\n失败信息 %s", req.Ids, err.Error()))
|
||||
e.Error(500, err, fmt.Sprintf("删除{{.TableComment}}失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK( control.GetId(), "删除成功")
|
||||
e.OK( req.GetId(), "删除成功")
|
||||
}
|
||||
@@ -15,12 +15,12 @@ func init() {
|
||||
// register{{.ClassName}}Router
|
||||
func register{{.ClassName}}Router(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
api := apis.{{.ClassName}}{}
|
||||
r := v1.Group("/{{.ModuleName}}").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
||||
r := v1.Group("/{{.MLTBName}}").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
||||
{
|
||||
r.GET("", api.Get{{.ClassName}}List)
|
||||
r.GET("/:id", api.Get{{.ClassName}})
|
||||
r.POST("", api.Insert{{.ClassName}})
|
||||
r.PUT("/:id", api.Update{{.ClassName}})
|
||||
r.DELETE("", api.Delete{{.ClassName}})
|
||||
r.GET("", api.GetPage)
|
||||
r.GET("/:id", api.Get)
|
||||
r.POST("", api.Insert)
|
||||
r.PUT("/:id", api.Update)
|
||||
r.DELETE("", api.Delete)
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,12 @@ func init() {
|
||||
// register{{.ClassName}}Router
|
||||
func register{{.ClassName}}Router(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
api := apis.{{.ClassName}}{}
|
||||
r := v1.Group("/{{.ModuleName}}").Use(authMiddleware.MiddlewareFunc())
|
||||
r := v1.Group("/{{.MLTBName}}").Use(authMiddleware.MiddlewareFunc())
|
||||
{
|
||||
r.GET("", api.Get{{.ClassName}})
|
||||
r.GET("/:id", api.Get{{.ClassName}})
|
||||
r.POST("", api.Insert{{.ClassName}})
|
||||
r.PUT("/:id", api.Update{{.ClassName}})
|
||||
r.DELETE("", api.Delete{{.ClassName}})
|
||||
r.GET("", api.GetPage)
|
||||
r.GET("/:id", api.Get)
|
||||
r.POST("", api.Insert)
|
||||
r.PUT("/:id", api.Update)
|
||||
r.DELETE("", api.Delete)
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"go-admin/app/{{.PackageName}}/models"
|
||||
"go-admin/app/{{.PackageName}}/service/dto"
|
||||
"go-admin/common/actions"
|
||||
cDto "go-admin/common/dto"
|
||||
)
|
||||
|
||||
@@ -16,7 +17,7 @@ type {{.ClassName}} struct {
|
||||
}
|
||||
|
||||
// GetPage 获取{{.ClassName}}列表
|
||||
func (e *{{.ClassName}}) GetPage(c *dto.{{.ClassName}}Search, p *actions.DataPermission, list *[]models.{{.ClassName}}, count *int64) error {
|
||||
func (e *{{.ClassName}}) GetPage(c *dto.{{.ClassName}}GetPageReq, p *actions.DataPermission, list *[]models.{{.ClassName}}, count *int64) error {
|
||||
var err error
|
||||
var data models.{{.ClassName}}
|
||||
|
||||
@@ -36,7 +37,7 @@ func (e *{{.ClassName}}) GetPage(c *dto.{{.ClassName}}Search, p *actions.DataPer
|
||||
}
|
||||
|
||||
// Get 获取{{.ClassName}}对象
|
||||
func (e *{{.ClassName}}) Get(d *dto.{{.ClassName}}ById, p *actions.DataPermission, model *models.{{.ClassName}}) error {
|
||||
func (e *{{.ClassName}}) Get(d *dto.{{.ClassName}}GetReq, p *actions.DataPermission, model *models.{{.ClassName}}) error {
|
||||
var data models.{{.ClassName}}
|
||||
|
||||
err := e.Orm.Model(&data).
|
||||
@@ -57,11 +58,11 @@ func (e *{{.ClassName}}) Get(d *dto.{{.ClassName}}ById, p *actions.DataPermissio
|
||||
}
|
||||
|
||||
// Insert 创建{{.ClassName}}对象
|
||||
func (e *{{.ClassName}}) Insert(c *dto.{{.ClassName}}Control) error {
|
||||
func (e *{{.ClassName}}) Insert(c *dto.{{.ClassName}}InsertReq) error {
|
||||
var err error
|
||||
var data models.{{.ClassName}}
|
||||
c.Generate(&data)
|
||||
err := e.Orm.Create(c&data).Error
|
||||
err = e.Orm.Create(&data).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("{{.ClassName}}Service Insert error:%s \r\n", err)
|
||||
return err
|
||||
@@ -70,29 +71,27 @@ func (e *{{.ClassName}}) Insert(c *dto.{{.ClassName}}Control) error {
|
||||
}
|
||||
|
||||
// Update 修改{{.ClassName}}对象
|
||||
func (e *{{.ClassName}}) Update(c *models.{{.ClassName}}, p *actions.DataPermission) error {
|
||||
func (e *{{.ClassName}}) Update(c *dto.{{.ClassName}}UpdateReq, p *actions.DataPermission) error {
|
||||
var err error
|
||||
var model = models.{{.ClassName}}
|
||||
var data = models.{{.ClassName}}{}
|
||||
e.Orm.Scopes(
|
||||
actions.Permission(data.TableName(), p),
|
||||
).First(&model, c.GetId())
|
||||
c.Generate(&model)
|
||||
).First(&data, c.GetId())
|
||||
c.Generate(&data)
|
||||
|
||||
db := e.Orm.Save(&model)
|
||||
db := e.Orm.Save(&data)
|
||||
if db.Error != nil {
|
||||
e.Log.Errorf("{{.ClassName}}Service Save error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
if db.RowsAffected == 0 {
|
||||
return errors.New("无权更新该数据")
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Remove{{.ClassName}} 删除{{.ClassName}}
|
||||
func (e *{{.ClassName}}) Remove(d *dto.{{.ClassName}}ById, p *actions.DataPermission) error {
|
||||
var err error
|
||||
// Remove 删除{{.ClassName}}
|
||||
func (e *{{.ClassName}}) Remove(d *dto.{{.ClassName}}DeleteReq, p *actions.DataPermission) error {
|
||||
var data models.{{.ClassName}}
|
||||
|
||||
db := e.Orm.Model(&data).
|
||||
|
||||
+21
-15
@@ -78,7 +78,7 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="{{.ModuleName}}List" @selection-change="handleSelectionChange">
|
||||
<el-table v-loading="loading" :data="{{.BusinessName}}List" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
{{- range .Columns -}}
|
||||
{{- $x := .IsList -}}
|
||||
@@ -153,11 +153,11 @@
|
||||
{{- $x := .IsInsert -}}
|
||||
{{- if (eq $x "1") -}}
|
||||
{{- if (.Pk) }}
|
||||
{{- else if eq .GoField "createdAt" -}}
|
||||
{{- else if eq .GoField "updatedAt" -}}
|
||||
{{- else if eq .GoField "deletedAt" -}}
|
||||
{{- else if eq .GoField "updateBy" -}}
|
||||
{{- else if eq .GoField "createBy" -}}
|
||||
{{- else if eq .GoField "CreatedAt" -}}
|
||||
{{- else if eq .GoField "UpdatedAt" -}}
|
||||
{{- else if eq .GoField "DeletedAt" -}}
|
||||
{{- else if eq .GoField "UpdateBy" -}}
|
||||
{{- else if eq .GoField "CreateBy" -}}
|
||||
{{- else }}
|
||||
<el-form-item label="{{.ColumnComment}}" prop="{{.JsonField}}">
|
||||
{{ if eq "input" .HtmlType -}}
|
||||
@@ -229,10 +229,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {add{{.ClassName}}, del{{.ClassName}}, get{{.ClassName}}, list{{.ClassName}}, update{{.ClassName}}} from '@/api/{{ .BusinessName}}'
|
||||
import {add{{.ClassName}}, del{{.ClassName}}, get{{.ClassName}}, list{{.ClassName}}, update{{.ClassName}}} from '@/api/{{ .PackageName}}/{{ .MLTBName}}'
|
||||
{{ $package:=.PackageName }}
|
||||
{{range .Columns}}
|
||||
{{- if ne .FkTableName "" -}}
|
||||
import {list{{.FkTableNameClass}} } from '@/api/{{ .FkTableNamePackage}}'
|
||||
import {list{{.FkTableNameClass}} } from '@/api/{{ $package }}/{{ .FkTableNamePackage}}'
|
||||
{{ end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -259,7 +260,7 @@
|
||||
isEdit: false,
|
||||
// 类型数据字典
|
||||
typeOptions: [],
|
||||
{{.ModuleName}}List: [],
|
||||
{{.BusinessName}}List: [],
|
||||
{{range .Columns}}
|
||||
{{- if ne .DictType "" -}}
|
||||
{{.JsonField}}Options: [],
|
||||
@@ -313,7 +314,7 @@
|
||||
getList() {
|
||||
this.loading = true
|
||||
list{{.ClassName}}(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
||||
this.{{.ModuleName}}List = response.data.list
|
||||
this.{{.BusinessName}}List = response.data.list
|
||||
this.total = response.data.count
|
||||
this.loading = false
|
||||
}
|
||||
@@ -423,7 +424,7 @@
|
||||
if (this.form.{{.PkJsonField}} !== undefined) {
|
||||
update{{.ClassName}}(this.form).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess('修改成功')
|
||||
this.msgSuccess(response.msg)
|
||||
this.open = false
|
||||
this.getList()
|
||||
} else {
|
||||
@@ -433,7 +434,7 @@
|
||||
} else {
|
||||
add{{.ClassName}}(this.form).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess('新增成功')
|
||||
this.msgSuccess(response.msg)
|
||||
this.open = false
|
||||
this.getList()
|
||||
} else {
|
||||
@@ -454,9 +455,14 @@
|
||||
type: 'warning'
|
||||
}).then(function () {
|
||||
return del{{.ClassName}}( { 'ids': Ids })
|
||||
}).then(() => {
|
||||
this.getList()
|
||||
this.msgSuccess('删除成功')
|
||||
}).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess(response.msg)
|
||||
this.open = false
|
||||
this.getList()
|
||||
} else {
|
||||
this.msgError(response.msg)
|
||||
}
|
||||
}).catch(function () {
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user