mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-25 03:21:46 +00:00
Compare commits
65
Commits
2.0.0-beta.6
...
v2.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25395b5006 | ||
|
|
2f516b49cf | ||
|
|
41ff26edc8 | ||
|
|
a1c6f586cf | ||
|
|
8b01126e0f | ||
|
|
e59d40af21 | ||
|
|
6b476bfab7 | ||
|
|
12429d4585 | ||
|
|
6fe2edbe89 | ||
|
|
cee6bd6abd | ||
|
|
4ac3350920 | ||
|
|
a45113258c | ||
|
|
4a2659573b | ||
|
|
c74080664f | ||
|
|
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 | ||
|
|
acee466fc8 | ||
|
|
862f24d8a7 | ||
|
|
e2cb033670 | ||
|
|
029c505501 | ||
|
|
dd5f0c52fb | ||
|
|
f80e64688e | ||
|
|
3fd34db3c1 | ||
|
|
0607d462d0 | ||
|
|
7f8c302405 | ||
|
|
c82c58443c | ||
|
|
9591be883f | ||
|
|
acdcd0c867 | ||
|
|
0f623521c4 | ||
|
|
91b93a3f48 | ||
|
|
32d123eb89 | ||
|
|
2025809d91 | ||
|
|
d552875e8a | ||
|
|
6994857f4b | ||
|
|
7ac941c1d0 | ||
|
|
7e9919e3ae |
+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>
|
||||
|
||||
@@ -10,6 +10,12 @@ type System struct {
|
||||
api.Api
|
||||
}
|
||||
|
||||
// GenerateCaptchaHandler 获取验证码
|
||||
// @Summary 获取验证码
|
||||
// @Description 获取验证码
|
||||
// @Tags 登陆
|
||||
// @Success 200 {object} response.Response{data=string,id=string,msg=string} "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/captcha [get]
|
||||
func (e System) GenerateCaptchaHandler(c *gin.Context) {
|
||||
err := e.MakeContext(c).Errors
|
||||
if err != nil {
|
||||
|
||||
@@ -33,7 +33,7 @@ $(function(){
|
||||
</html>
|
||||
`
|
||||
|
||||
func HelloWorld(c *gin.Context) {
|
||||
func GoAdmin(c *gin.Context) {
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
c.String(200, INDEX)
|
||||
}
|
||||
@@ -32,7 +32,7 @@ type SysApi struct {
|
||||
// @Security Bearer
|
||||
func (e SysApi) GetPage(c *gin.Context) {
|
||||
s := service.SysApi{}
|
||||
req := dto.SysApiSearch{}
|
||||
req := dto.SysApiGetPageReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
@@ -64,7 +64,7 @@ func (e SysApi) GetPage(c *gin.Context) {
|
||||
// @Router /api/v1/sys-api/{id} [get]
|
||||
// @Security Bearer
|
||||
func (e SysApi) Get(c *gin.Context) {
|
||||
req := dto.SysApiById{}
|
||||
req := dto.SysApiGetReq{}
|
||||
s := service.SysApi{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
@@ -92,12 +92,12 @@ 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
|
||||
func (e SysApi) Update(c *gin.Context) {
|
||||
req := dto.SysApiControl{}
|
||||
req := dto.SysApiUpdateReq{}
|
||||
s := service.SysApi{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
@@ -122,23 +122,22 @@ 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
|
||||
func (e SysApi) DeleteSysApi(c *gin.Context) {
|
||||
req := dto.SysApiById{}
|
||||
req := dto.SysApiDeleteReq{}
|
||||
s := service.SysApi{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
return
|
||||
}
|
||||
req.SetUpdateBy(user.GetUserId(c))
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
err = s.Remove(&req, p)
|
||||
if err != nil {
|
||||
|
||||
@@ -30,7 +30,7 @@ type SysConfig struct {
|
||||
// @Security Bearer
|
||||
func (e SysConfig) GetPage(c *gin.Context) {
|
||||
s := service.SysConfig{}
|
||||
req := dto.SysConfigSearch{}
|
||||
req := dto.SysConfigGetPageReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
@@ -60,7 +60,7 @@ func (e SysConfig) GetPage(c *gin.Context) {
|
||||
// @Router /api/v1/sys-config/{id} [get]
|
||||
// @Security Bearer
|
||||
func (e SysConfig) Get(c *gin.Context) {
|
||||
req := dto.SysConfigById{}
|
||||
req := dto.SysConfigGetReq{}
|
||||
s := service.SysConfig{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
@@ -158,7 +158,7 @@ func (e SysConfig) Update(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysConfig) Delete(c *gin.Context) {
|
||||
s := service.SysConfig{}
|
||||
req := dto.SysConfigById{}
|
||||
req := dto.SysConfigDeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
@@ -179,15 +179,14 @@ func (e SysConfig) Delete(c *gin.Context) {
|
||||
e.OK(req.GetId(), "删除成功")
|
||||
}
|
||||
|
||||
// GetSysConfigBySysApp 获取系统配置信息
|
||||
// @Summary 获取系统前台配置信息,主要注意这里不在验证数据权限
|
||||
// @Description 获取系统配置信息,主要注意这里不在验证数据权限
|
||||
// Get2SysApp 获取系统配置信息
|
||||
// @Summary 获取系统前台配置信息,主要注意这里不在验证权限
|
||||
// @Description 获取系统配置信息,主要注意这里不在验证权限
|
||||
// @Tags 配置管理
|
||||
// @Success 200 {object} response.Response{data=map[string]string} "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/app-config [get]
|
||||
// @Security Bearer
|
||||
func (e SysConfig) GetSysConfigBySysApp(c *gin.Context) {
|
||||
req := dto.SysConfigSearch{}
|
||||
func (e SysConfig) Get2SysApp(c *gin.Context) {
|
||||
req := dto.SysConfigGetToSysAppReq{}
|
||||
s := service.SysConfig{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
|
||||
+10
-10
@@ -29,10 +29,10 @@ type SysDept struct {
|
||||
// @Security Bearer
|
||||
func (e SysDept) GetPage(c *gin.Context) {
|
||||
s := service.SysDept{}
|
||||
req := dto.SysDeptSearch{}
|
||||
req := dto.SysDeptGetPageReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
@@ -50,17 +50,16 @@ func (e SysDept) GetPage(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Get
|
||||
// @Summary 部门列表数据
|
||||
// @Summary 获取部门数据
|
||||
// @Description 获取JSON
|
||||
// @Tags 部门
|
||||
// @Param deptId path string false "deptId"
|
||||
// @Param position query string false "position"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/dept/{deptId} [get]
|
||||
// @Security Bearer
|
||||
func (e SysDept) Get(c *gin.Context) {
|
||||
s := service.SysDept{}
|
||||
req := dto.SysDeptById{}
|
||||
req := dto.SysDeptGetReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
@@ -95,7 +94,7 @@ func (e SysDept) Get(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysDept) Insert(c *gin.Context) {
|
||||
s := service.SysDept{}
|
||||
req := dto.SysDeptControl{}
|
||||
req := dto.SysDeptInsertReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
@@ -131,10 +130,10 @@ func (e SysDept) Insert(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysDept) Update(c *gin.Context) {
|
||||
s := service.SysDept{}
|
||||
req := dto.SysDeptControl{}
|
||||
req := dto.SysDeptUpdateReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
@@ -159,9 +158,10 @@ func (e SysDept) Update(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
||||
// @Router /api/v1/dept [delete]
|
||||
// @Security Bearer
|
||||
func (e SysDept) Delete(c *gin.Context) {
|
||||
s := service.SysDept{}
|
||||
req := dto.SysDeptById{}
|
||||
req := dto.SysDeptDeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
@@ -184,7 +184,7 @@ func (e SysDept) Delete(c *gin.Context) {
|
||||
// Get2Tree 用户管理 左侧部门树
|
||||
func (e SysDept) Get2Tree(c *gin.Context) {
|
||||
s := service.SysDept{}
|
||||
req := dto.SysDeptSearch{}
|
||||
req := dto.SysDeptGetPageReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req,binding.Form).
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package apis
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"go-admin/app/admin/models"
|
||||
"net/http"
|
||||
|
||||
"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"
|
||||
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
||||
"go-admin/app/admin/models"
|
||||
|
||||
"go-admin/app/admin/service"
|
||||
"go-admin/app/admin/service/dto"
|
||||
@@ -32,7 +30,7 @@ type SysDictData struct {
|
||||
// @Security Bearer
|
||||
func (e SysDictData) GetPage(c *gin.Context) {
|
||||
s := service.SysDictData{}
|
||||
req := dto.SysDictDataSearch{}
|
||||
req := dto.SysDictDataGetPageReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
@@ -65,7 +63,7 @@ func (e SysDictData) GetPage(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysDictData) Get(c *gin.Context) {
|
||||
s := service.SysDictData{}
|
||||
req := dto.SysDictDataById{}
|
||||
req := dto.SysDictDataGetReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, nil).
|
||||
@@ -82,7 +80,7 @@ func (e SysDictData) Get(c *gin.Context) {
|
||||
err = s.Get(&req, &object)
|
||||
if err != nil {
|
||||
e.Logger.Warnf("Get error: %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "查询失败")
|
||||
e.Error(500, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -95,14 +93,13 @@ func (e SysDictData) Get(c *gin.Context) {
|
||||
// @Tags 字典数据
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.SysDictDataControl true "data"
|
||||
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Param data body dto.SysDictDataInsertReq true "data"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "添加成功"}"
|
||||
// @Router /api/v1/dict/data [post]
|
||||
// @Security Bearer
|
||||
func (e SysDictData) Insert(c *gin.Context) {
|
||||
s := service.SysDictData{}
|
||||
req := dto.SysDictDataControl{}
|
||||
req := dto.SysDictDataInsertReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
@@ -129,14 +126,13 @@ func (e SysDictData) Insert(c *gin.Context) {
|
||||
// @Tags 字典数据
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.SysDictDataControl true "body"
|
||||
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Param data body dto.SysDictDataUpdateReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "修改成功"}"
|
||||
// @Router /api/v1/dict/data/{dictCode} [put]
|
||||
// @Security Bearer
|
||||
func (e SysDictData) Update(c *gin.Context) {
|
||||
s := service.SysDictData{}
|
||||
req := dto.SysDictDataControl{}
|
||||
req := dto.SysDictDataUpdateReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
@@ -160,14 +156,13 @@ func (e SysDictData) Update(c *gin.Context) {
|
||||
// @Summary 删除字典数据
|
||||
// @Description 删除数据
|
||||
// @Tags 字典数据
|
||||
// @Param dictCode body dto.SysDictDataById true "body"
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
||||
// @Param dictCode body dto.SysDictDataDeleteReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "删除成功"}"
|
||||
// @Router /api/v1/dict/data [delete]
|
||||
// @Security Bearer
|
||||
func (e SysDictData) Delete(c *gin.Context) {
|
||||
s := service.SysDictData{}
|
||||
req := dto.SysDictDataById{}
|
||||
req := dto.SysDictDataDeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
@@ -187,21 +182,20 @@ func (e SysDictData) Delete(c *gin.Context) {
|
||||
e.OK(req.GetId(), "删除成功")
|
||||
}
|
||||
|
||||
// GetSysDictDataAll 数据字典根据key获取 业务页面使用
|
||||
// GetAll 数据字典根据key获取 业务页面使用
|
||||
// @Summary 数据字典根据key获取
|
||||
// @Description 数据字典根据key获取
|
||||
// @Tags 字典数据
|
||||
// @Param dictType query int true "dictType"
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
||||
// @Success 200 {object} response.Response{data=[]dto.SysDictDataGetAllResp} "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/dict-data/option-select [get]
|
||||
// @Security Bearer
|
||||
func (e SysDictData) GetSysDictDataAll(c *gin.Context) {
|
||||
func (e SysDictData) GetAll(c *gin.Context) {
|
||||
s := service.SysDictData{}
|
||||
req := dto.SysDictDataSearch{}
|
||||
req := dto.SysDictDataGetPageReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
@@ -215,5 +209,12 @@ func (e SysDictData) GetSysDictDataAll(c *gin.Context) {
|
||||
e.Error(500, err, "查询失败")
|
||||
return
|
||||
}
|
||||
e.OK(list, "查询成功")
|
||||
}
|
||||
l := make([]dto.SysDictDataGetAllResp, 0)
|
||||
for _, i := range list {
|
||||
d := dto.SysDictDataGetAllResp{}
|
||||
e.Translate(i, &d)
|
||||
l = append(l, d)
|
||||
}
|
||||
|
||||
e.OK(l,"查询成功")
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ type SysDictType struct {
|
||||
// @Security Bearer
|
||||
func (e SysDictType) GetPage(c *gin.Context) {
|
||||
s := service.SysDictType{}
|
||||
req := dto.SysDictTypeSearch{}
|
||||
req :=dto.SysDictTypeGetPageReq{}
|
||||
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.SysDictTypeGetReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, nil).
|
||||
@@ -88,14 +88,13 @@ func (e SysDictType) Get(c *gin.Context) {
|
||||
// @Tags 字典类型
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.SysDictTypeControl true "data"
|
||||
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Param data body dto.SysDictTypeInsertReq true "data"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/dict/type [post]
|
||||
// @Security Bearer
|
||||
func (e SysDictType) Insert(c *gin.Context) {
|
||||
s := service.SysDictType{}
|
||||
req := dto.SysDictTypeControl{}
|
||||
req :=dto.SysDictTypeInsertReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
@@ -122,14 +121,13 @@ func (e SysDictType) Insert(c *gin.Context) {
|
||||
// @Tags 字典类型
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.SysDictTypeControl true "body"
|
||||
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Param data body dto.SysDictTypeUpdateReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/dict/type/{dictId} [put]
|
||||
// @Security Bearer
|
||||
func (e SysDictType) Update(c *gin.Context) {
|
||||
s := service.SysDictType{}
|
||||
req := dto.SysDictTypeControl{}
|
||||
req :=dto.SysDictTypeUpdateReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
@@ -153,13 +151,13 @@ func (e SysDictType) Update(c *gin.Context) {
|
||||
// @Summary 删除字典类型
|
||||
// @Description 删除数据
|
||||
// @Tags 字典类型
|
||||
// @Param dictId path int true "dictId"
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
||||
// @Param dictCode body dto.SysDictTypeDeleteReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/dict/type [delete]
|
||||
// @Security Bearer
|
||||
func (e SysDictType) Delete(c *gin.Context) {
|
||||
s := service.SysDictType{}
|
||||
req := dto.SysDictTypeById{}
|
||||
req :=dto.SysDictTypeDeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
@@ -191,7 +189,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.SysDictTypeGetPageReq{}
|
||||
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.SysLoginLogGetPageReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
@@ -51,7 +50,7 @@ func (e SysLoginLog) GetPage(c *gin.Context) {
|
||||
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
// GetSysLoginLog 登录日志通过id获取
|
||||
// Get 登录日志通过id获取
|
||||
// @Summary 登录日志通过id获取
|
||||
// @Description 获取JSON
|
||||
// @Tags 登录日志
|
||||
@@ -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 {
|
||||
@@ -81,16 +80,17 @@ func (e SysLoginLog) Get(c *gin.Context) {
|
||||
e.OK(object, "查询成功")
|
||||
}
|
||||
|
||||
// DeleteSysLoginLog 登录日志删除
|
||||
// Delete 登录日志删除
|
||||
// @Summary 登录日志删除
|
||||
// @Description 登录日志删除
|
||||
// @Tags 登录日志
|
||||
// @Param data body dto.SysLoginLogById true "body"
|
||||
// @Param data body dto.SysLoginLogDeleteReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/sys-login-log [delete]
|
||||
// @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).
|
||||
@@ -101,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, "删除失败")
|
||||
|
||||
+14
-16
@@ -1,13 +1,11 @@
|
||||
package apis
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"go-admin/app/admin/models"
|
||||
"net/http"
|
||||
|
||||
"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"
|
||||
"go-admin/app/admin/service/dto"
|
||||
@@ -22,13 +20,12 @@ type SysMenu struct {
|
||||
// @Description 获取JSON
|
||||
// @Tags 菜单
|
||||
// @Param menuName query string false "menuName"
|
||||
// @Param menuName query string false "menuName"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/menu [get]
|
||||
// @Security Bearer
|
||||
func (e SysMenu) GetPage(c *gin.Context) {
|
||||
s := service.SysMenu{}
|
||||
req := dto.SysMenuSearch{}
|
||||
req := dto.SysMenuGetPageReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
@@ -57,7 +54,7 @@ func (e SysMenu) GetPage(c *gin.Context) {
|
||||
// @Router /api/v1/menu/{id} [get]
|
||||
// @Security Bearer
|
||||
func (e SysMenu) Get(c *gin.Context) {
|
||||
req := dto.SysMenuById{}
|
||||
req := dto.SysMenuGetReq{}
|
||||
s := new(service.SysMenu)
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
@@ -85,12 +82,12 @@ func (e SysMenu) Get(c *gin.Context) {
|
||||
// @Tags 菜单
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.SysMenuControl true "data"
|
||||
// @Param data body dto.SysMenuInsertReq true "data"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/menu [post]
|
||||
// @Security Bearer
|
||||
func (e SysMenu) Insert(c *gin.Context) {
|
||||
req := dto.SysMenuControl{}
|
||||
req := dto.SysMenuInsertReq{}
|
||||
s := new(service.SysMenu)
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
@@ -119,12 +116,12 @@ func (e SysMenu) Insert(c *gin.Context) {
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param id path int true "id"
|
||||
// @Param data body dto.SysMenuControl true "body"
|
||||
// @Param data body dto.SysMenuUpdateReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/menu/{id} [put]
|
||||
// @Security Bearer
|
||||
func (e SysMenu) Update(c *gin.Context) {
|
||||
req := dto.SysMenuControl{}
|
||||
req := dto.SysMenuUpdateReq{}
|
||||
s := new(service.SysMenu)
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
@@ -150,11 +147,12 @@ func (e SysMenu) Update(c *gin.Context) {
|
||||
// @Summary 删除菜单
|
||||
// @Description 删除数据
|
||||
// @Tags 菜单
|
||||
// @Param data body dto.SysMenuById true "body"
|
||||
// @Param data body dto.SysMenuDeleteReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/menu [delete]
|
||||
// @Security Bearer
|
||||
func (e SysMenu) Delete(c *gin.Context) {
|
||||
control := new(dto.SysMenuById)
|
||||
control := new(dto.SysMenuDeleteReq)
|
||||
s := new(service.SysMenu)
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
@@ -169,7 +167,7 @@ func (e SysMenu) Delete(c *gin.Context) {
|
||||
err = s.Remove(control).Error
|
||||
if err != nil {
|
||||
e.Logger.Errorf("RemoveSysMenu error, %s", err)
|
||||
e.Error(http.StatusInternalServerError, err, "删除失败")
|
||||
e.Error(500, err, "删除失败")
|
||||
return
|
||||
}
|
||||
e.OK(control.GetId(), "删除成功")
|
||||
@@ -197,7 +195,7 @@ func (e SysMenu) GetMenuRole(c *gin.Context) {
|
||||
result, err := s.SetMenuRole(user.GetRoleName(c))
|
||||
|
||||
if err != nil {
|
||||
e.Error(http.StatusInternalServerError, err, "查询失败")
|
||||
e.Error(500, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -255,7 +253,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).
|
||||
|
||||
@@ -2,12 +2,10 @@ package apis
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"go-admin/app/admin/models"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/service"
|
||||
"go-admin/app/admin/service/dto"
|
||||
)
|
||||
@@ -33,7 +31,7 @@ type SysOperaLog struct {
|
||||
// @Security Bearer
|
||||
func (e SysOperaLog) GetPage(c *gin.Context) {
|
||||
s := service.SysOperaLog{}
|
||||
req := new(dto.SysOperaLogSearch)
|
||||
req := new(dto.SysOperaLogGetPageReq)
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(req, binding.Form).
|
||||
@@ -50,7 +48,7 @@ func (e SysOperaLog) GetPage(c *gin.Context) {
|
||||
|
||||
err = s.GetPage(req, &list, &count)
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(500, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -67,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).
|
||||
@@ -95,9 +93,10 @@ func (e SysOperaLog) Get(c *gin.Context) {
|
||||
// @Param data body dto.SysOperaLogById true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/sys-opera-log [delete]
|
||||
// @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).
|
||||
|
||||
+24
-24
@@ -1,10 +1,9 @@
|
||||
package apis
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"net/http"
|
||||
|
||||
"fmt"
|
||||
"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"
|
||||
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
||||
@@ -31,7 +30,7 @@ type SysPost struct {
|
||||
// @Security Bearer
|
||||
func (e SysPost) GetPage(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostSearch{}
|
||||
req :=dto.SysPostPageReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
@@ -46,9 +45,9 @@ func (e SysPost) GetPage(c *gin.Context) {
|
||||
list := make([]models.SysPost, 0)
|
||||
var count int64
|
||||
|
||||
err = s.GetSysPostPage(&req, &list, &count)
|
||||
err = s.GetPage(&req, &list, &count)
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(500, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -59,13 +58,13 @@ func (e SysPost) GetPage(c *gin.Context) {
|
||||
// @Summary 获取岗位信息
|
||||
// @Description 获取JSON
|
||||
// @Tags 岗位
|
||||
// @Param postId path int true "postId"
|
||||
// @Param id path int true "编码"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/post/{postId} [get]
|
||||
// @Security Bearer
|
||||
func (e SysPost) Get(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostById{}
|
||||
req :=dto.SysPostGetReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, nil).
|
||||
@@ -78,9 +77,9 @@ func (e SysPost) Get(c *gin.Context) {
|
||||
}
|
||||
var object models.SysPost
|
||||
|
||||
err = s.GetSysPost(&req, &object)
|
||||
err = s.Get(&req, &object)
|
||||
if err != nil {
|
||||
e.Error(500, err, "查询失败")
|
||||
e.Error(500, err, fmt.Sprintf("岗位信息获取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -93,14 +92,14 @@ func (e SysPost) Get(c *gin.Context) {
|
||||
// @Tags 岗位
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.SysPostControl true "data"
|
||||
// @Param data body dto.SysPostInsertReq true "data"
|
||||
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/post [post]
|
||||
// @Security Bearer
|
||||
func (e SysPost) Insert(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostControl{}
|
||||
req :=dto.SysPostInsertReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
@@ -112,9 +111,9 @@ func (e SysPost) Insert(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
req.SetCreateBy(user.GetUserId(c))
|
||||
err = s.InsertSysPost(&req)
|
||||
err = s.Insert(&req)
|
||||
if err != nil {
|
||||
e.Error(500, err, "创建失败")
|
||||
e.Error(500, err, fmt.Sprintf("新建岗位失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK(req.GetId(), "创建成功")
|
||||
@@ -126,14 +125,14 @@ func (e SysPost) Insert(c *gin.Context) {
|
||||
// @Tags 岗位
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.SysPostControl true "body"
|
||||
// @Param data body dto.SysPostUpdateReq true "body"
|
||||
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/post/ [put]
|
||||
// @Router /api/v1/post/{id} [put]
|
||||
// @Security Bearer
|
||||
func (e SysPost) Update(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostControl{}
|
||||
req :=dto.SysPostUpdateReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON, nil).
|
||||
@@ -147,9 +146,9 @@ func (e SysPost) Update(c *gin.Context) {
|
||||
|
||||
req.SetUpdateBy(user.GetUserId(c))
|
||||
|
||||
err = s.UpdateSysPost(&req)
|
||||
err = s.Update(&req)
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, fmt.Sprintf("岗位更新失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK(req.GetId(), "更新成功")
|
||||
@@ -159,13 +158,14 @@ func (e SysPost) Update(c *gin.Context) {
|
||||
// @Summary 删除岗位
|
||||
// @Description 删除数据
|
||||
// @Tags 岗位
|
||||
// @Param id path int true "id"
|
||||
// @Param id body dto.SysPostDeleteReq true "请求参数"
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 500 {string} string "{"code": 500, "message": "删除失败"}"
|
||||
// @Router /api/v1/post [delete]
|
||||
// @Security Bearer
|
||||
func (e SysPost) Delete(c *gin.Context) {
|
||||
s := service.SysPost{}
|
||||
req := dto.SysPostById{}
|
||||
req :=dto.SysPostDeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
@@ -177,10 +177,10 @@ func (e SysPost) Delete(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
req.SetUpdateBy(user.GetUserId(c))
|
||||
err = s.RemoveSysPost(&req)
|
||||
err = s.Remove(&req)
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, fmt.Sprintf("岗位删除失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK(req.GetId(), "删除成功")
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -35,7 +35,7 @@ type SysRole struct {
|
||||
// @Security Bearer
|
||||
func (e SysRole) GetPage(c *gin.Context) {
|
||||
s := service.SysRole{}
|
||||
req := dto.SysRoleSearch{}
|
||||
req := dto.SysRoleGetPageReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
@@ -69,7 +69,7 @@ func (e SysRole) GetPage(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysRole) Get(c *gin.Context) {
|
||||
s := service.SysRole{}
|
||||
req := dto.SysRoleById{}
|
||||
req := dto.SysRoleGetReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, nil).
|
||||
@@ -104,7 +104,7 @@ func (e SysRole) Get(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysRole) Insert(c *gin.Context) {
|
||||
s := service.SysRole{}
|
||||
req := dto.SysRoleControl{}
|
||||
req := dto.SysRoleInsertReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
@@ -148,7 +148,7 @@ func (e SysRole) Insert(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysRole) Update(c *gin.Context) {
|
||||
s := service.SysRole{}
|
||||
req := dto.SysRoleControl{}
|
||||
req := dto.SysRoleUpdateReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, nil, binding.JSON).
|
||||
@@ -170,7 +170,7 @@ func (e SysRole) Update(c *gin.Context) {
|
||||
}
|
||||
_, err = global.LoadPolicy(c)
|
||||
if err != nil {
|
||||
e.Error(http.StatusInternalServerError, err, "")
|
||||
e.Error(500, err, "")
|
||||
return
|
||||
}
|
||||
e.OK(req.GetId(), "更新成功")
|
||||
@@ -186,7 +186,7 @@ func (e SysRole) Update(c *gin.Context) {
|
||||
// @Security Bearer
|
||||
func (e SysRole) Delete(c *gin.Context) {
|
||||
s := new(service.SysRole)
|
||||
req := dto.SysRoleById{}
|
||||
req := dto.SysRoleDeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.JSON).
|
||||
@@ -206,7 +206,7 @@ func (e SysRole) Delete(c *gin.Context) {
|
||||
}
|
||||
_, err = global.LoadPolicy(c)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("删除角色 %v 失败,失败信息 %s", req.Id, err.Error()))
|
||||
e.Error(500, err, fmt.Sprintf("删除角色 %v 失败,失败信息 %s", req.GetId(), err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK(req.GetId(), fmt.Sprintf("删除角色角色 %v 状态成功!", req.GetId()))
|
||||
@@ -227,7 +227,7 @@ func (e SysRole) Update2Status(c *gin.Context) {
|
||||
req := dto.UpdateStatusReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, nil, binding.JSON).
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
@@ -255,7 +255,7 @@ func (e SysRole) Update2Status(c *gin.Context) {
|
||||
// @Router /api/v1/role-status/{id} [put]
|
||||
// @Security Bearer
|
||||
func (e SysRole) Update2DataScope(c *gin.Context) {
|
||||
s := &service.SysRole{}
|
||||
s := service.SysRole{}
|
||||
req := dto.RoleDataScopeReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
@@ -275,7 +275,7 @@ func (e SysRole) Update2DataScope(c *gin.Context) {
|
||||
data.UpdateBy = user.GetUserId(c)
|
||||
err = s.UpdateDataScope(&req).Error
|
||||
if err != nil {
|
||||
e.Error(http.StatusInternalServerError, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("更新角色数据权限失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK(nil, "操作成功")
|
||||
|
||||
+30
-25
@@ -30,10 +30,10 @@ type SysUser struct {
|
||||
// @Security Bearer
|
||||
func (e SysUser) GetPage(c *gin.Context) {
|
||||
s := service.SysUser{}
|
||||
req := dto.SysUserSearch{}
|
||||
req :=dto.SysUserGetPageReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req, binding.Form).
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
@@ -63,11 +63,11 @@ func (e SysUser) GetPage(c *gin.Context) {
|
||||
// @Tags 用户
|
||||
// @Param userId path int true "用户编码"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/sysUser/{userId} [get]
|
||||
// @Router /api/v1/sys-user/{userId} [get]
|
||||
// @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).
|
||||
@@ -95,12 +95,13 @@ func (e SysUser) Get(c *gin.Context) {
|
||||
// @Tags 用户
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.SysUserControl true "用户数据"
|
||||
// @Param data body dto.SysUserInsertReq true "用户数据"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/sysUser [post]
|
||||
// @Router /api/v1/sys-user [post]
|
||||
// @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).
|
||||
@@ -129,15 +130,16 @@ func (e SysUser) Insert(c *gin.Context) {
|
||||
// @Tags 用户
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.SysUserControl true "body"
|
||||
// @Param data body dto.SysUserUpdateReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/sys-user/{userId} [put]
|
||||
// @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, binding.JSON, nil).
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
@@ -166,9 +168,10 @@ func (e SysUser) Update(c *gin.Context) {
|
||||
// @Param userId path int true "userId"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/sys-user/{userId} [delete]
|
||||
// @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).
|
||||
@@ -202,9 +205,10 @@ func (e SysUser) Delete(c *gin.Context) {
|
||||
// @Param file formData file true "file"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/user/avatar [post]
|
||||
// @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).
|
||||
@@ -233,7 +237,7 @@ func (e SysUser) InsetAvatar(c *gin.Context) {
|
||||
req.UserId = p.UserId
|
||||
req.Avatar = "/" + filPath
|
||||
|
||||
err = s.Update(&req, p)
|
||||
err = s.UpdateAvatar(&req, p)
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
return
|
||||
@@ -250,9 +254,10 @@ func (e SysUser) InsetAvatar(c *gin.Context) {
|
||||
// @Param data body dto.UpdateSysUserStatusReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/user/status [put]
|
||||
// @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).
|
||||
@@ -269,7 +274,7 @@ func (e SysUser) UpdateStatus(c *gin.Context) {
|
||||
//数据权限检查
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
err = s.UpdateSysUserStatus(&req, p)
|
||||
err = s.UpdateStatus(&req, p)
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
return
|
||||
@@ -286,9 +291,10 @@ func (e SysUser) UpdateStatus(c *gin.Context) {
|
||||
// @Param data body dto.ResetSysUserPwdReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/user/pwd/reset [put]
|
||||
// @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).
|
||||
@@ -305,7 +311,7 @@ func (e SysUser) ResetPwd(c *gin.Context) {
|
||||
//数据权限检查
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
err = s.ResetSysUserPwd(&req, p)
|
||||
err = s.ResetPwd(&req, p)
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
return
|
||||
@@ -321,11 +327,11 @@ func (e SysUser) ResetPwd(c *gin.Context) {
|
||||
// @Product application/json
|
||||
// @Param data body dto.PassWord true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/user/pwd [post]
|
||||
// @Router /api/v1/user/pwd/set [put]
|
||||
// @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).
|
||||
@@ -340,7 +346,7 @@ func (e SysUser) UpdatePwd(c *gin.Context) {
|
||||
// 数据权限检查
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
err = s.UpdateSysUserPwd(user.GetUserId(c), req.OldPassword, req.NewPassword, p)
|
||||
err = s.UpdatePwd(user.GetUserId(c), req.OldPassword, req.NewPassword, p)
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(http.StatusForbidden, err, "密码修改失败")
|
||||
@@ -358,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).
|
||||
@@ -374,7 +380,7 @@ func (e SysUser) GetProfile(c *gin.Context) {
|
||||
sysUser := models.SysUser{}
|
||||
roles := make([]models.SysRole, 0)
|
||||
posts := make([]models.SysPost, 0)
|
||||
err = s.GetSysUserProfile(&req, &sysUser, &roles, &posts)
|
||||
err = s.GetProfile(&req, &sysUser, &roles, &posts)
|
||||
if err != nil {
|
||||
e.Logger.Errorf("get user profile error, %s", err.Error())
|
||||
e.Error(500, err, "获取用户信息失败")
|
||||
@@ -395,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).
|
||||
@@ -415,8 +421,6 @@ func (e SysUser) GetInfo(c *gin.Context) {
|
||||
permissions[0] = "*:*:*"
|
||||
var buttons = make([]string, 1)
|
||||
buttons[0] = "*:*:*"
|
||||
//RoleMenu := models.RoleMenu{}
|
||||
//RoleMenu.RoleId = user.GetRoleId(c)
|
||||
|
||||
var mp = make(map[string]interface{})
|
||||
mp["roles"] = roles
|
||||
@@ -444,5 +448,6 @@ func (e SysUser) GetInfo(c *gin.Context) {
|
||||
mp["userId"] = sysUser.UserId
|
||||
mp["deptId"] = sysUser.DeptId
|
||||
mp["name"] = sysUser.NickName
|
||||
mp["code"] = 200
|
||||
e.OK(mp, "")
|
||||
}
|
||||
@@ -57,24 +57,32 @@ func SaveOperaLog(message storage.Messager) (err error) {
|
||||
if db == nil {
|
||||
err = errors.New("db not exist")
|
||||
log.Errorf("host[%s]'s %s", message.GetPrefix(), err.Error())
|
||||
return err
|
||||
// Log writing to the database ignores error
|
||||
return nil
|
||||
}
|
||||
var rb []byte
|
||||
rb, err = json.Marshal(message.GetValues())
|
||||
if err != nil {
|
||||
log.Errorf("json Marshal error, %s", err.Error())
|
||||
return err
|
||||
// Log writing to the database ignores error
|
||||
return nil
|
||||
}
|
||||
var l SysOperaLog
|
||||
err = json.Unmarshal(rb, &l)
|
||||
if err != nil {
|
||||
log.Errorf("json Unmarshal error, %s", err.Error())
|
||||
return err
|
||||
// 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())
|
||||
return err
|
||||
// Log writing to the database ignores error
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func registerSysConfigRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMidd
|
||||
|
||||
r2 := v1.Group("/app-config")
|
||||
{
|
||||
r2.GET("", api.GetSysConfigBySysApp)
|
||||
r2.GET("", api.Get2SysApp)
|
||||
}
|
||||
|
||||
r3 := v1.Group("/set-config").Use(authMiddleware.MiddlewareFunc())
|
||||
|
||||
@@ -32,6 +32,6 @@ func registerDictRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddlewar
|
||||
}
|
||||
opSelect := v1.Group("/dict-data").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
||||
{
|
||||
opSelect.GET("/option-select", dataApi.GetSysDictDataAll)
|
||||
opSelect.GET("/option-select", dataApi.GetAll)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/go-admin-team/go-admin-core/sdk/config"
|
||||
"go-admin/app/admin/apis"
|
||||
"mime"
|
||||
|
||||
@@ -21,7 +22,9 @@ func InitSysRouter(r *gin.Engine, authMiddleware *jwt.GinJWTMiddleware) *gin.Rou
|
||||
// 静态文件
|
||||
sysStaticFileRouter(g)
|
||||
// swagger;注意:生产环境可以注释掉
|
||||
sysSwaggerRouter(g)
|
||||
if config.ApplicationConfig.Mode != "prod" {
|
||||
sysSwaggerRouter(g)
|
||||
}
|
||||
// 需要认证
|
||||
sysCheckRoleRouterInit(g, authMiddleware)
|
||||
return g
|
||||
@@ -33,7 +36,9 @@ func sysBaseRouter(r *gin.RouterGroup) {
|
||||
go ws.WebsocketManager.SendService()
|
||||
go ws.WebsocketManager.SendAllService()
|
||||
|
||||
r.GET("/", apis.HelloWorld)
|
||||
if config.ApplicationConfig.Mode != "prod" {
|
||||
r.GET("/", apis.GoAdmin)
|
||||
}
|
||||
r.GET("/info", handler.Ping)
|
||||
}
|
||||
|
||||
@@ -43,7 +48,9 @@ func sysStaticFileRouter(r *gin.RouterGroup) {
|
||||
return
|
||||
}
|
||||
r.Static("/static", "./static")
|
||||
r.Static("/form-generator", "./static/form-generator")
|
||||
if config.ApplicationConfig.Mode != "prod" {
|
||||
r.Static("/form-generator", "./static/form-generator")
|
||||
}
|
||||
}
|
||||
|
||||
func sysSwaggerRouter(r *gin.RouterGroup) {
|
||||
@@ -51,16 +58,19 @@ func sysSwaggerRouter(r *gin.RouterGroup) {
|
||||
}
|
||||
|
||||
func sysCheckRoleRouterInit(r *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
r.Group("").Use(authMiddleware.MiddlewareFunc()).GET("/ws/:id/:channel", ws.WebsocketManager.WsClient)
|
||||
r.Group("").Use(authMiddleware.MiddlewareFunc()).GET("/wslogout/:id/:channel", ws.WebsocketManager.UnWsClient)
|
||||
v1 := r.Group("/api/v1")
|
||||
wss:=r.Group("").Use(authMiddleware.MiddlewareFunc())
|
||||
{
|
||||
wss.GET("/ws/:id/:channel", ws.WebsocketManager.WsClient)
|
||||
wss.GET("/wslogout/:id/:channel", ws.WebsocketManager.UnWsClient)
|
||||
}
|
||||
|
||||
v1.POST("/login", authMiddleware.LoginHandler)
|
||||
// Refresh time can be longer than token timeout
|
||||
v1.GET("/refresh_token", authMiddleware.RefreshHandler)
|
||||
//registerPageRouter(v1, authMiddleware)
|
||||
v1 := r.Group("/api/v1")
|
||||
{
|
||||
v1.POST("/login", authMiddleware.LoginHandler)
|
||||
// Refresh time can be longer than token timeout
|
||||
v1.GET("/refresh_token", authMiddleware.RefreshHandler)
|
||||
}
|
||||
registerBaseRouter(v1, authMiddleware)
|
||||
//registerDictRouter(v1, authMiddleware)
|
||||
}
|
||||
|
||||
func registerBaseRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
|
||||
@@ -28,7 +28,7 @@ func registerSysUserRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
|
||||
{
|
||||
user.GET("/profile", api.GetProfile)
|
||||
user.POST("/avatar", api.InsetAvatar)
|
||||
user.PUT("/pwd", api.UpdatePwd)
|
||||
user.PUT("/pwd/set", api.UpdatePwd)
|
||||
user.PUT("/pwd/reset", api.ResetPwd)
|
||||
user.PUT("/status", api.UpdateStatus)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ import (
|
||||
common "go-admin/common/models"
|
||||
)
|
||||
|
||||
type SysApiSearch struct {
|
||||
// SysApiGetPageReq 功能列表请求参数
|
||||
type SysApiGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
Title string `form:"title" search:"type:contains;column:title;table:sys_api" comment:"标题"`
|
||||
Path string `form:"path" search:"type:contains;column:path;table:sys_api" comment:"地址"`
|
||||
@@ -21,11 +22,35 @@ type SysApiOrder struct {
|
||||
CreatedAtOrder string `search:"type:order;column:created_at;table:sys_api" form:"createdAtOrder"`
|
||||
}
|
||||
|
||||
func (m *SysApiSearch) GetNeedSearch() interface{} {
|
||||
func (m *SysApiGetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
type SysApiControl struct {
|
||||
// SysApiInsertReq 功能创建请求参数
|
||||
type SysApiInsertReq struct {
|
||||
Id int `json:"-" comment:"编码"` // 编码
|
||||
Handle string `json:"handle" comment:"handle"`
|
||||
Title string `json:"title" comment:"标题"`
|
||||
Path string `json:"path" comment:"地址"`
|
||||
Type string `json:"type" comment:""`
|
||||
Action string `json:"action" comment:"类型"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysApiInsertReq) Generate(model *models.SysApi) {
|
||||
model.Handle = s.Handle
|
||||
model.Title = s.Title
|
||||
model.Path = s.Path
|
||||
model.Type = s.Type
|
||||
model.Action = s.Action
|
||||
}
|
||||
|
||||
func (s *SysApiInsertReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
// SysApiUpdateReq 功能更新请求参数
|
||||
type SysApiUpdateReq struct {
|
||||
Id int `uri:"id" comment:"编码"` // 编码
|
||||
Handle string `json:"handle" comment:"handle"`
|
||||
Title string `json:"title" comment:"标题"`
|
||||
@@ -35,7 +60,7 @@ type SysApiControl struct {
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysApiControl) Generate(model *models.SysApi) {
|
||||
func (s *SysApiUpdateReq) Generate(model *models.SysApi) {
|
||||
if s.Id != 0 {
|
||||
model.Id = s.Id
|
||||
}
|
||||
@@ -46,28 +71,26 @@ func (s *SysApiControl) Generate(model *models.SysApi) {
|
||||
model.Action = s.Action
|
||||
}
|
||||
|
||||
func (s *SysApiControl) GetId() interface{} {
|
||||
func (s *SysApiUpdateReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type SysApiById struct {
|
||||
dto.ObjectById
|
||||
common.ControlBy
|
||||
// SysApiGetReq 功能获取请求参数
|
||||
type SysApiGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *SysApiById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
func (s *SysApiGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysApiById) Generate() dto.Control {
|
||||
o := *s
|
||||
return &o
|
||||
|
||||
// SysApiDeleteReq 功能删除请求参数
|
||||
type SysApiDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
}
|
||||
|
||||
func (s *SysApiById) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.SysApi{}, nil
|
||||
func (s *SysApiDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
common "go-admin/common/models"
|
||||
)
|
||||
|
||||
// SysConfigSearch 列表或者搜索使用结构体
|
||||
type SysConfigSearch struct {
|
||||
// SysConfigGetPageReq 列表或者搜索使用结构体
|
||||
type SysConfigGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
ConfigName string `form:"configName" search:"type:contains;column:config_name;table:sys_config"`
|
||||
ConfigKey string `form:"configKey" search:"type:contains;column:config_key;table:sys_config"`
|
||||
@@ -24,7 +24,15 @@ type SysConfigOrder struct {
|
||||
CreatedAtOrder string `search:"type:order;column:created_at;table:sys_config" form:"createdAtOrder"`
|
||||
}
|
||||
|
||||
func (m *SysConfigSearch) GetNeedSearch() interface{} {
|
||||
func (m *SysConfigGetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
type SysConfigGetToSysAppReq struct {
|
||||
IsFrontend int `form:"isFrontend" search:"type:exact;column:is_frontend;table:sys_config"`
|
||||
}
|
||||
|
||||
func (m *SysConfigGetToSysAppReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
@@ -86,22 +94,19 @@ type GetSysConfigByKEYForServiceResp struct {
|
||||
ConfigValue string `json:"configValue" comment:""`
|
||||
}
|
||||
|
||||
// SysConfigById 获取单个或者删除的结构体
|
||||
type SysConfigById struct {
|
||||
Id int `uri:"id"`
|
||||
type SysConfigGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *SysConfigGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type SysConfigDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysConfigById) Generate() *SysConfigById {
|
||||
cp := *s
|
||||
return &cp
|
||||
}
|
||||
|
||||
func (s *SysConfigById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
func (s *SysConfigDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
|
||||
@@ -3,13 +3,10 @@ package dto
|
||||
import (
|
||||
"go-admin/app/admin/models"
|
||||
common "go-admin/common/models"
|
||||
|
||||
"go-admin/common/dto"
|
||||
)
|
||||
|
||||
// SysDeptSearch 列表或者搜索使用结构体
|
||||
type SysDeptSearch struct {
|
||||
dto.Pagination `search:"-"`
|
||||
// SysDeptGetPageReq 列表或者搜索使用结构体
|
||||
type SysDeptGetPageReq struct {
|
||||
DeptId int `form:"deptId" search:"type:exact;column:dept_id;table:sys_dept" comment:"id"` //id
|
||||
ParentId int `form:"parentId" search:"type:exact;column:parent_id;table:sys_dept" comment:"上级部门"` //上级部门
|
||||
DeptPath string `form:"deptPath" search:"type:exact;column:dept_path;table:sys_dept" comment:""` //路径
|
||||
@@ -21,26 +18,24 @@ type SysDeptSearch struct {
|
||||
Status string `form:"status" search:"type:exact;column:status;table:sys_dept" comment:"状态"` //状态
|
||||
}
|
||||
|
||||
func (m *SysDeptSearch) GetNeedSearch() interface{} {
|
||||
func (m *SysDeptGetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
// SysDeptControl 增、改使用的结构体
|
||||
type SysDeptControl struct {
|
||||
DeptId int `uri:"id" comment:"编码"` // 编码
|
||||
ParentId int `json:"parentId" comment:"上级部门"` //上级部门
|
||||
DeptPath string `json:"deptPath" comment:""` //路径
|
||||
DeptName string `json:"deptName" comment:"部门名称"` //部门名称
|
||||
Sort int `json:"sort" comment:"排序"` //排序
|
||||
Leader string `json:"leader" comment:"负责人"` //负责人
|
||||
Phone string `json:"phone" comment:"手机"` //手机
|
||||
Email string `json:"email" comment:"邮箱"` //邮箱
|
||||
Status int `json:"status" comment:"状态"` //状态
|
||||
type SysDeptInsertReq struct {
|
||||
DeptId int `uri:"id" comment:"编码"` // 编码
|
||||
ParentId int `json:"parentId" comment:"上级部门" vd:"?"` //上级部门
|
||||
DeptPath string `json:"deptPath" comment:""` //路径
|
||||
DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"` //部门名称
|
||||
Sort int `json:"sort" comment:"排序" vd:"?"` //排序
|
||||
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"` //状态
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
// Generate 结构体数据转化 从 SysDeptControl 至 SysDept 对应的模型
|
||||
func (s *SysDeptControl) Generate(model *models.SysDept) {
|
||||
func (s *SysDeptInsertReq) Generate(model *models.SysDept) {
|
||||
if s.DeptId != 0 {
|
||||
model.DeptId = s.DeptId
|
||||
}
|
||||
@@ -55,31 +50,57 @@ func (s *SysDeptControl) Generate(model *models.SysDept) {
|
||||
}
|
||||
|
||||
// GetId 获取数据对应的ID
|
||||
func (s *SysDeptControl) GetId() interface{} {
|
||||
func (s *SysDeptInsertReq) GetId() interface{} {
|
||||
return s.DeptId
|
||||
}
|
||||
|
||||
// SysDeptById 获取单个或者删除的结构体
|
||||
type SysDeptById struct {
|
||||
Id int `uri:"id"`
|
||||
Ids []int `json:"ids"`
|
||||
type SysDeptUpdateReq struct {
|
||||
DeptId int `uri:"id" comment:"编码"` // 编码
|
||||
ParentId int `json:"parentId" comment:"上级部门" vd:"?"` //上级部门
|
||||
DeptPath string `json:"deptPath" comment:""` //路径
|
||||
DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"` //部门名称
|
||||
Sort int `json:"sort" comment:"排序" vd:"?"` //排序
|
||||
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"` //状态
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysDeptById) Generate() *SysDeptById {
|
||||
cp := *s
|
||||
return &cp
|
||||
}
|
||||
|
||||
func (s *SysDeptById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
// Generate 结构体数据转化 从 SysDeptControl 至 SysDept 对应的模型
|
||||
func (s *SysDeptUpdateReq) Generate(model *models.SysDept) {
|
||||
if s.DeptId != 0 {
|
||||
model.DeptId = s.DeptId
|
||||
}
|
||||
model.DeptName = s.DeptName
|
||||
model.ParentId = s.ParentId
|
||||
model.DeptPath = s.DeptPath
|
||||
model.Sort = s.Sort
|
||||
model.Leader = s.Leader
|
||||
model.Phone = s.Phone
|
||||
model.Email = s.Email
|
||||
model.Status = s.Status
|
||||
}
|
||||
|
||||
// GetId 获取数据对应的ID
|
||||
func (s *SysDeptUpdateReq) GetId() interface{} {
|
||||
return s.DeptId
|
||||
}
|
||||
|
||||
type SysDeptGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *SysDeptGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysDeptById) GenerateM() (*models.SysDept, error) {
|
||||
return &models.SysDept{}, nil
|
||||
type SysDeptDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
}
|
||||
|
||||
func (s *SysDeptDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
|
||||
type DeptLabel struct {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
common "go-admin/common/models"
|
||||
)
|
||||
|
||||
type SysDictDataSearch struct {
|
||||
type SysDictDataGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
Id int `form:"id" search:"type:exact;column:dict_code;table:sys_dict_data" comment:""`
|
||||
DictLabel string `form:"dictLabel" search:"type:contains;column:dict_label;table:sys_dict_data" comment:""`
|
||||
@@ -15,12 +15,17 @@ type SysDictDataSearch struct {
|
||||
Status string `form:"status" search:"type:exact;column:status;table:sys_dict_data" comment:""`
|
||||
}
|
||||
|
||||
func (m *SysDictDataSearch) GetNeedSearch() interface{} {
|
||||
func (m *SysDictDataGetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
type SysDictDataControl struct {
|
||||
Id int `uri:"dictCode" comment:""`
|
||||
type SysDictDataGetAllResp struct {
|
||||
DictLabel string `json:"label"`
|
||||
DictValue string `json:"value"`
|
||||
}
|
||||
|
||||
type SysDictDataInsertReq struct {
|
||||
Id int `json:"-" comment:""`
|
||||
DictSort int `json:"dictSort" comment:""`
|
||||
DictLabel string `json:"dictLabel" comment:""`
|
||||
DictValue string `json:"dictValue" comment:""`
|
||||
@@ -28,14 +33,13 @@ type SysDictDataControl struct {
|
||||
CssClass string `json:"cssClass" comment:""`
|
||||
ListClass string `json:"listClass" comment:""`
|
||||
IsDefault string `json:"isDefault" comment:""`
|
||||
Status int `json:"status" comment:""`
|
||||
Status int `json:"status" comment:""`
|
||||
Default string `json:"default" comment:""`
|
||||
Remark string `json:"remark" comment:""`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysDictDataControl) Generate(model *models.SysDictData) {
|
||||
|
||||
func (s *SysDictDataInsertReq) Generate(model *models.SysDictData) {
|
||||
model.DictCode = s.Id
|
||||
model.DictSort = s.DictSort
|
||||
model.DictLabel = s.DictLabel
|
||||
@@ -49,24 +53,56 @@ func (s *SysDictDataControl) Generate(model *models.SysDictData) {
|
||||
model.Remark = s.Remark
|
||||
}
|
||||
|
||||
func (s *SysDictDataControl) GetId() interface{} {
|
||||
func (s *SysDictDataInsertReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type SysDictDataById struct {
|
||||
Id int `uri:"dictCode"`
|
||||
Ids []int `json:"ids"`
|
||||
type SysDictDataUpdateReq struct {
|
||||
Id int `uri:"dictCode" comment:""`
|
||||
DictSort int `json:"dictSort" comment:""`
|
||||
DictLabel string `json:"dictLabel" comment:""`
|
||||
DictValue string `json:"dictValue" comment:""`
|
||||
DictType string `json:"dictType" comment:""`
|
||||
CssClass string `json:"cssClass" comment:""`
|
||||
ListClass string `json:"listClass" comment:""`
|
||||
IsDefault string `json:"isDefault" comment:""`
|
||||
Status int `json:"status" comment:""`
|
||||
Default string `json:"default" comment:""`
|
||||
Remark string `json:"remark" comment:""`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysDictDataUpdateReq) Generate(model *models.SysDictData) {
|
||||
model.DictCode = s.Id
|
||||
model.DictSort = s.DictSort
|
||||
model.DictLabel = s.DictLabel
|
||||
model.DictValue = s.DictValue
|
||||
model.DictType = s.DictType
|
||||
model.CssClass = s.CssClass
|
||||
model.ListClass = s.ListClass
|
||||
model.IsDefault = s.IsDefault
|
||||
model.Status = s.Status
|
||||
model.Default = s.Default
|
||||
model.Remark = s.Remark
|
||||
}
|
||||
|
||||
func (s *SysDictDataUpdateReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type SysDictDataGetReq struct {
|
||||
Id int `uri:"dictCode"`
|
||||
}
|
||||
|
||||
func (s *SysDictDataGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type SysDictDataDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
common.ControlBy `json:"-"`
|
||||
}
|
||||
|
||||
func (s *SysDictDataById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysDictDataById) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.SysDictData{}, nil
|
||||
func (s *SysDictDataDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
common "go-admin/common/models"
|
||||
)
|
||||
|
||||
type SysDictTypeSearch struct {
|
||||
type SysDictTypeGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
DictId []int `form:"dictId" search:"type:in;column:dict_id;table:sys_dict_type"`
|
||||
DictName string `form:"dictName" search:"type:icontains;column:dict_name;table:sys_dict_type"`
|
||||
@@ -19,11 +19,11 @@ type SysDictTypeOrder struct {
|
||||
DictIdOrder string `search:"type:order;column:dict_id;table:sys_dict_type" form:"dictIdOrder"`
|
||||
}
|
||||
|
||||
func (m *SysDictTypeSearch) GetNeedSearch() interface{} {
|
||||
func (m *SysDictTypeGetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
type SysDictTypeControl struct {
|
||||
type SysDictTypeInsertReq struct {
|
||||
Id int `uri:"id"`
|
||||
DictName string `json:"dictName"`
|
||||
DictType string `json:"dictType"`
|
||||
@@ -32,7 +32,7 @@ type SysDictTypeControl struct {
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysDictTypeControl) Generate(model *models.SysDictType) {
|
||||
func (s *SysDictTypeInsertReq) Generate(model *models.SysDictType) {
|
||||
if s.Id != 0 {
|
||||
model.ID = s.Id
|
||||
}
|
||||
@@ -43,28 +43,47 @@ func (s *SysDictTypeControl) Generate(model *models.SysDictType) {
|
||||
|
||||
}
|
||||
|
||||
func (s *SysDictTypeControl) GetId() interface{} {
|
||||
func (s *SysDictTypeInsertReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type SysDictTypeById struct {
|
||||
dto.ObjectById
|
||||
type SysDictTypeUpdateReq struct {
|
||||
Id int `uri:"id"`
|
||||
DictName string `json:"dictName"`
|
||||
DictType string `json:"dictType"`
|
||||
Status int `json:"status"`
|
||||
Remark string `json:"remark"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysDictTypeById) Generate() dto.Control {
|
||||
cp := *s
|
||||
return &cp
|
||||
func (s *SysDictTypeUpdateReq) Generate(model *models.SysDictType) {
|
||||
if s.Id != 0 {
|
||||
model.ID = s.Id
|
||||
}
|
||||
model.DictName = s.DictName
|
||||
model.DictType = s.DictType
|
||||
model.Status = s.Status
|
||||
model.Remark = s.Remark
|
||||
|
||||
}
|
||||
|
||||
func (s *SysDictTypeById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
func (s *SysDictTypeUpdateReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysDictTypeById) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.SysDictType{}, nil
|
||||
type SysDictTypeGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *SysDictTypeGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type SysDictTypeDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysDictTypeDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"go-admin/app/admin/models"
|
||||
"time"
|
||||
|
||||
"go-admin/common/dto"
|
||||
common "go-admin/common/models"
|
||||
)
|
||||
|
||||
type SysLoginLogSearch struct {
|
||||
type SysLoginLogGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
Username string `form:"username" search:"type:exact;column:username;table:sys_login_log" comment:"用户名"`
|
||||
Status string `form:"status" search:"type:exact;column:status;table:sys_login_log" comment:"状态"`
|
||||
@@ -23,7 +21,7 @@ type SysLoginLogOrder struct {
|
||||
CreatedAtOrder string `search:"type:order;column:created_at;table:sys_login_log" form:"createdAtOrder"`
|
||||
}
|
||||
|
||||
func (m *SysLoginLogSearch) GetNeedSearch() interface{} {
|
||||
func (m *SysLoginLogGetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
@@ -41,41 +39,19 @@ type SysLoginLogControl struct {
|
||||
Msg string `json:"msg" comment:"信息"`
|
||||
}
|
||||
|
||||
func (s *SysLoginLogControl) Generate() (*models.SysLoginLog, error) {
|
||||
return &models.SysLoginLog{
|
||||
Model: common.Model{Id: s.ID},
|
||||
Username: s.Username,
|
||||
Status: s.Status,
|
||||
Ipaddr: s.Ipaddr,
|
||||
LoginLocation: s.LoginLocation,
|
||||
Browser: s.Browser,
|
||||
Os: s.Os,
|
||||
Platform: s.Platform,
|
||||
LoginTime: s.LoginTime,
|
||||
Remark: s.Remark,
|
||||
Msg: s.Msg,
|
||||
}, nil
|
||||
type SysLoginLogGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *SysLoginLogControl) GetId() interface{} {
|
||||
return s.ID
|
||||
}
|
||||
|
||||
type SysLoginLogById struct {
|
||||
Id int `uri:"id"`
|
||||
Ids []int `json:"ids"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
@@ -7,19 +7,18 @@ import (
|
||||
"go-admin/common/dto"
|
||||
)
|
||||
|
||||
// SysMenuSearch 列表或者搜索使用结构体
|
||||
type SysMenuSearch struct {
|
||||
// SysMenuGetPageReq 列表或者搜索使用结构体
|
||||
type SysMenuGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
Title string `form:"title" search:"type:contains;column:title;table:sys_menu" comment:"菜单名称"` // 菜单名称
|
||||
Visible int `form:"visible" search:"type:exact;column:visible;table:sys_menu" comment:"显示状态"` // 显示状态
|
||||
}
|
||||
|
||||
func (m *SysMenuSearch) GetNeedSearch() interface{} {
|
||||
func (m *SysMenuGetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
// SysMenuControl 增、改使用的结构体
|
||||
type SysMenuControl struct {
|
||||
type SysMenuInsertReq struct {
|
||||
MenuId int `uri:"id" comment:"编码"` // 编码
|
||||
MenuName string `form:"menuName" comment:"菜单name"` //菜单name
|
||||
Title string `form:"title" comment:"显示名称"` //显示名称
|
||||
@@ -41,16 +40,7 @@ type SysMenuControl struct {
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysMenuControl) SetCreateBy(id int) {
|
||||
s.CreateBy = id
|
||||
}
|
||||
|
||||
func (s *SysMenuControl) SetUpdateBy(id int) {
|
||||
s.UpdateBy = id
|
||||
}
|
||||
|
||||
// Generate 结构体数据转化 从 Control 至 model 对应的模型
|
||||
func (s *SysMenuControl) Generate(model *models.SysMenu) {
|
||||
func (s *SysMenuInsertReq) Generate(model *models.SysMenu) {
|
||||
if s.MenuId != 0 {
|
||||
model.MenuId = s.MenuId
|
||||
}
|
||||
@@ -78,33 +68,79 @@ func (s *SysMenuControl) Generate(model *models.SysMenu) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetId 获取数据对应的ID
|
||||
func (s *SysMenuControl) GetId() interface{} {
|
||||
func (s *SysMenuInsertReq) GetId() interface{} {
|
||||
return s.MenuId
|
||||
}
|
||||
|
||||
// SysMenuById 获取单个或者删除的结构体
|
||||
type SysMenuById struct {
|
||||
Id int `uri:"id"`
|
||||
type SysMenuUpdateReq struct {
|
||||
MenuId int `uri:"id" comment:"编码"` // 编码
|
||||
MenuName string `form:"menuName" comment:"菜单name"` //菜单name
|
||||
Title string `form:"title" comment:"显示名称"` //显示名称
|
||||
Icon string `form:"icon" comment:"图标"` //图标
|
||||
Path string `form:"path" comment:"路径"` //路径
|
||||
Paths string `form:"paths" comment:"id路径"` //id路径
|
||||
MenuType string `form:"menuType" comment:"菜单类型"` //菜单类型
|
||||
SysApi []models.SysApi `form:"sysApi"`
|
||||
Apis []int `form:"apis"`
|
||||
Action string `form:"action" comment:"请求方式"` //请求方式
|
||||
Permission string `form:"permission" comment:"权限编码"` //权限编码
|
||||
ParentId int `form:"parentId" comment:"上级菜单"` //上级菜单
|
||||
NoCache bool `form:"noCache" comment:"是否缓存"` //是否缓存
|
||||
Breadcrumb string `form:"breadcrumb" comment:"是否面包屑"` //是否面包屑
|
||||
Component string `form:"component" comment:"组件"` //组件
|
||||
Sort int `form:"sort" comment:"排序"` //排序
|
||||
Visible string `form:"visible" comment:"是否显示"` //是否显示
|
||||
IsFrame string `form:"isFrame" comment:"是否frame"` //是否frame
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysMenuUpdateReq) Generate(model *models.SysMenu) {
|
||||
if s.MenuId != 0 {
|
||||
model.MenuId = s.MenuId
|
||||
}
|
||||
model.MenuName = s.MenuName
|
||||
model.Title = s.Title
|
||||
model.Icon = s.Icon
|
||||
model.Path = s.Path
|
||||
model.Paths = s.Paths
|
||||
model.MenuType = s.MenuType
|
||||
model.Action = s.Action
|
||||
model.SysApi = s.SysApi
|
||||
model.Permission = s.Permission
|
||||
model.ParentId = s.ParentId
|
||||
model.NoCache = s.NoCache
|
||||
model.Breadcrumb = s.Breadcrumb
|
||||
model.Component = s.Component
|
||||
model.Sort = s.Sort
|
||||
model.Visible = s.Visible
|
||||
model.IsFrame = s.IsFrame
|
||||
if s.CreateBy != 0 {
|
||||
model.CreateBy = s.CreateBy
|
||||
}
|
||||
if s.UpdateBy != 0 {
|
||||
model.UpdateBy = s.UpdateBy
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SysMenuUpdateReq) GetId() interface{} {
|
||||
return s.MenuId
|
||||
}
|
||||
|
||||
type SysMenuGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *SysMenuGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type SysMenuDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysMenuById) Generate() *SysMenuById {
|
||||
cp := *s
|
||||
return &cp
|
||||
}
|
||||
|
||||
func (s *SysMenuById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysMenuById) GenerateM() (*models.SysMenu, error) {
|
||||
return &models.SysMenu{}, nil
|
||||
func (s *SysMenuDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
|
||||
type MenuLabel struct {
|
||||
@@ -120,4 +156,4 @@ type MenuRole struct {
|
||||
|
||||
type SelectRole struct {
|
||||
RoleId int `uri:"roleId"`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
common "go-admin/common/models"
|
||||
)
|
||||
|
||||
type SysOperaLogSearch struct {
|
||||
type SysOperaLogGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
Title string `form:"title" search:"type:contains;column:title;table:sys_opera_log" comment:"操作模块"`
|
||||
Method string `form:"method" search:"type:contains;column:method;table:sys_opera_log" comment:"函数"`
|
||||
@@ -25,7 +25,7 @@ type SysOperaLogOrder struct {
|
||||
CreatedAtOrder string `search:"type:order;column:created_at;table:sys_opera_log" form:"createdAtOrder"`
|
||||
}
|
||||
|
||||
func (m *SysOperaLogSearch) GetNeedSearch() interface{} {
|
||||
func (m *SysOperaLogGetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"go-admin/common/dto"
|
||||
)
|
||||
|
||||
// SysPostSearch 列表或者搜索使用结构体
|
||||
type SysPostSearch struct {
|
||||
// SysPostPageReq 列表或者搜索使用结构体
|
||||
type SysPostPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
PostId int `form:"postId" search:"type:exact;column:post_id;table:sys_post" comment:"id"` // id
|
||||
PostName string `form:"postName" search:"type:contains;column:post_name;table:sys_post" comment:"名称"` // 名称
|
||||
@@ -18,12 +18,12 @@ type SysPostSearch struct {
|
||||
Remark string `form:"remark" search:"type:exact;column:remark;table:sys_post" comment:"备注"` // 备注
|
||||
}
|
||||
|
||||
func (m *SysPostSearch) GetNeedSearch() interface{} {
|
||||
func (m *SysPostPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
// SysPostControl 增、改使用的结构体
|
||||
type SysPostControl struct {
|
||||
// SysPostInsertReq 增使用的结构体
|
||||
type SysPostInsertReq struct {
|
||||
PostId int `uri:"id" comment:"id"`
|
||||
PostName string `form:"postName" comment:"名称"`
|
||||
PostCode string `form:"postCode" comment:"编码"`
|
||||
@@ -33,11 +33,7 @@ type SysPostControl struct {
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
// Generate 结构体数据转化 从 SysConfigControl 至 system.SysConfig 对应的模型
|
||||
func (s *SysPostControl) Generate(model *models.SysPost) {
|
||||
if s.PostId != 0 {
|
||||
model.PostId = s.PostId
|
||||
}
|
||||
func (s *SysPostInsertReq) Generate(model *models.SysPost) {
|
||||
model.PostName = s.PostName
|
||||
model.PostCode = s.PostCode
|
||||
model.Sort = s.Sort
|
||||
@@ -52,18 +48,28 @@ func (s *SysPostControl) Generate(model *models.SysPost) {
|
||||
}
|
||||
|
||||
// GetId 获取数据对应的ID
|
||||
func (s *SysPostControl) GetId() interface{} {
|
||||
func (s *SysPostInsertReq) GetId() interface{} {
|
||||
return s.PostId
|
||||
}
|
||||
|
||||
// SysPostById 获取单个或者删除的结构体
|
||||
type SysPostById struct {
|
||||
Id int `uri:"id"`
|
||||
Ids []int `json:"ids"`
|
||||
// SysPostUpdateReq 改使用的结构体
|
||||
type SysPostUpdateReq struct {
|
||||
PostId int `uri:"id" comment:"id"`
|
||||
PostName string `form:"postName" comment:"名称"`
|
||||
PostCode string `form:"postCode" comment:"编码"`
|
||||
Sort int `form:"sort" comment:"排序"`
|
||||
Status int `form:"status" comment:"状态"`
|
||||
Remark string `form:"remark" comment:"备注"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysPostById) Generate(model *models.SysPost) {
|
||||
func (s *SysPostUpdateReq) Generate(model *models.SysPost) {
|
||||
model.PostId = s.PostId
|
||||
model.PostName = s.PostName
|
||||
model.PostCode = s.PostCode
|
||||
model.Sort = s.Sort
|
||||
model.Status = s.Status
|
||||
model.Remark = s.Remark
|
||||
if s.ControlBy.UpdateBy != 0 {
|
||||
model.UpdateBy = s.UpdateBy
|
||||
}
|
||||
@@ -72,14 +78,34 @@ func (s *SysPostById) Generate(model *models.SysPost) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SysPostById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
func (s *SysPostUpdateReq) GetId() interface{} {
|
||||
return s.PostId
|
||||
}
|
||||
|
||||
// SysPostGetReq 获取单个的结构体
|
||||
type SysPostGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *SysPostGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysPostById) GenerateM() (*models.SysPost, error) {
|
||||
return &models.SysPost{}, nil
|
||||
// SysPostDeleteReq 删除的结构体
|
||||
type SysPostDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysPostDeleteReq) Generate(model *models.SysPost) {
|
||||
if s.ControlBy.UpdateBy != 0 {
|
||||
model.UpdateBy = s.UpdateBy
|
||||
}
|
||||
if s.ControlBy.CreateBy != 0 {
|
||||
model.CreateBy = s.CreateBy
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SysPostDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ import (
|
||||
"go-admin/common/dto"
|
||||
)
|
||||
|
||||
// SysRoleSearch 列表或者搜索使用结构体
|
||||
type SysRoleSearch struct {
|
||||
type SysRoleGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
|
||||
RoleId int `form:"roleId" search:"type:exact;column:role_id;table:sys_role" comment:"角色编码"` // 角色编码
|
||||
@@ -30,11 +29,11 @@ type SysRoleOrder struct {
|
||||
CreatedAtOrder string `search:"type:order;column:created_at;table:sys_role" form:"createdAtOrder"`
|
||||
}
|
||||
|
||||
func (m *SysRoleSearch) GetNeedSearch() interface{} {
|
||||
func (m *SysRoleGetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
type SysRoleControl struct {
|
||||
type SysRoleInsertReq struct {
|
||||
RoleId int `uri:"id" comment:"角色编码"` // 角色编码
|
||||
RoleName string `form:"roleName" comment:"角色名称"` // 角色名称
|
||||
Status string `form:"status" comment:"状态"` // 状态
|
||||
@@ -51,16 +50,7 @@ type SysRoleControl struct {
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysRoleControl) SetCreateBy(id int) {
|
||||
s.CreateBy = id
|
||||
}
|
||||
|
||||
func (s *SysRoleControl) SetUpdateBy(id int) {
|
||||
s.UpdateBy = id
|
||||
}
|
||||
|
||||
// Generate 结构体数据转化
|
||||
func (s *SysRoleControl) Generate(model *models.SysRole) {
|
||||
func (s *SysRoleInsertReq) Generate(model *models.SysRole) {
|
||||
if s.RoleId != 0 {
|
||||
model.RoleId = s.RoleId
|
||||
}
|
||||
@@ -74,11 +64,46 @@ func (s *SysRoleControl) Generate(model *models.SysRole) {
|
||||
model.DataScope = s.DataScope
|
||||
model.SysMenu = &s.SysMenu
|
||||
model.SysDept = s.SysDept
|
||||
|
||||
}
|
||||
|
||||
// GetId 获取数据对应的ID
|
||||
func (s *SysRoleControl) GetId() interface{} {
|
||||
func (s *SysRoleInsertReq) GetId() interface{} {
|
||||
return s.RoleId
|
||||
}
|
||||
|
||||
type SysRoleUpdateReq struct {
|
||||
RoleId int `uri:"id" comment:"角色编码"` // 角色编码
|
||||
RoleName string `form:"roleName" comment:"角色名称"` // 角色名称
|
||||
Status string `form:"status" comment:"状态"` // 状态
|
||||
RoleKey string `form:"roleKey" comment:"角色代码"` // 角色代码
|
||||
RoleSort int `form:"roleSort" comment:"角色排序"` // 角色排序
|
||||
Flag string `form:"flag" comment:"标记"` // 标记
|
||||
Remark string `form:"remark" comment:"备注"` // 备注
|
||||
Admin bool `form:"admin" comment:"是否管理员"`
|
||||
DataScope string `form:"dataScope"`
|
||||
SysMenu []models.SysMenu `form:"sysMenu"`
|
||||
MenuIds []int `form:"menuIds"`
|
||||
SysDept []models.SysDept `form:"sysDept"`
|
||||
DeptIds []int `form:"deptIds"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysRoleUpdateReq) Generate(model *models.SysRole) {
|
||||
if s.RoleId != 0 {
|
||||
model.RoleId = s.RoleId
|
||||
}
|
||||
model.RoleName = s.RoleName
|
||||
model.Status = s.Status
|
||||
model.RoleKey = s.RoleKey
|
||||
model.RoleSort = s.RoleSort
|
||||
model.Flag = s.Flag
|
||||
model.Remark = s.Remark
|
||||
model.Admin = s.Admin
|
||||
model.DataScope = s.DataScope
|
||||
model.SysMenu = &s.SysMenu
|
||||
model.SysDept = s.SysDept
|
||||
}
|
||||
|
||||
func (s *SysRoleUpdateReq) GetId() interface{} {
|
||||
return s.RoleId
|
||||
}
|
||||
|
||||
@@ -103,26 +128,20 @@ type SysRoleByName struct {
|
||||
RoleName string `form:"role"` // 角色编码
|
||||
}
|
||||
|
||||
// SysRoleById 获取单个或者删除的结构体
|
||||
type SysRoleById struct {
|
||||
dto.ObjectById
|
||||
type SysRoleGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *SysRoleById) Generate() *SysRoleById {
|
||||
cp := *s
|
||||
return &cp
|
||||
}
|
||||
|
||||
func (s *SysRoleById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
func (s *SysRoleGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysRoleById) GenerateM() (*models.SysRole, error) {
|
||||
return &models.SysRole{}, nil
|
||||
type SysRoleDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
}
|
||||
|
||||
func (s *SysRoleDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
|
||||
// RoleDataScopeReq 角色数据权限修改
|
||||
@@ -142,4 +161,4 @@ func (s *RoleDataScopeReq) Generate(model *models.SysRole) {
|
||||
|
||||
type DeptIdList struct {
|
||||
DeptId int `json:"DeptId"`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
common "go-admin/common/models"
|
||||
)
|
||||
|
||||
type SysUserSearch struct {
|
||||
type SysUserGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
UserId int `form:"userId" search:"type:exact;column:user_id;table:sys_user" comment:"用户ID"`
|
||||
Username string `form:"username" search:"type:contains;column:username;table:sys_user" comment:"用户名"`
|
||||
@@ -33,7 +33,7 @@ type DeptJoin struct {
|
||||
DeptId string `search:"type:contains;column:dept_path;table:sys_dept" form:"deptId"`
|
||||
}
|
||||
|
||||
func (m *SysUserSearch) GetNeedSearch() interface{} {
|
||||
func (m *SysUserGetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
@@ -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:"len($)>0"` // 用户ID
|
||||
Avatar string `json:"avatar" comment:"头像" vd:"len($)>0"`
|
||||
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:"$>0"` // 用户ID
|
||||
Status string `json:"status" comment:"状态" vd:"len($)>0"`
|
||||
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:"len($)>0"`
|
||||
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:"len($)>0"`
|
||||
Phone string `json:"phone" comment:"手机号" vd:"len($)>0"`
|
||||
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:"len($)>0,email"`
|
||||
DeptId int `json:"deptId" comment:"部门" vd:"len($)>0"`
|
||||
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:"len($)>0" 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:"len($)>0"`
|
||||
NickName string `json:"nickName" comment:"昵称" vd:"len($)>0"`
|
||||
Phone string `json:"phone" comment:"手机号" vd:"len($)>0"`
|
||||
RoleId int `json:"roleId" comment:"角色ID"`
|
||||
Avatar string `json:"avatar" comment:"头像"`
|
||||
Sex string `json:"sex" comment:"性别"`
|
||||
Email string `json:"email" comment:"邮箱" vd:"len($)>0,email"`
|
||||
DeptId int `json:"deptId" comment:"部门" vd:"$>0"`
|
||||
PostId int `json:"postId" comment:"岗位"`
|
||||
Remark string `json:"remark" comment:"备注"`
|
||||
Status string `json:"status" comment:"状态" 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:"len($)>0"`
|
||||
OldPassword string `json:"oldPassword" vd:"len($)>0"`
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ type SysApi struct {
|
||||
}
|
||||
|
||||
// GetPage 获取SysApi列表
|
||||
func (e *SysApi) GetPage(c *dto.SysApiSearch, p *actions.DataPermission, list *[]models.SysApi, count *int64) error {
|
||||
func (e *SysApi) GetPage(c *dto.SysApiGetPageReq, p *actions.DataPermission, list *[]models.SysApi, count *int64) error {
|
||||
var err error
|
||||
var data models.SysApi
|
||||
|
||||
@@ -39,7 +39,7 @@ func (e *SysApi) GetPage(c *dto.SysApiSearch, p *actions.DataPermission, list *[
|
||||
}
|
||||
|
||||
// Get 获取SysApi对象with id
|
||||
func (e *SysApi) Get(d *dto.SysApiById, p *actions.DataPermission, model *models.SysApi) *SysApi {
|
||||
func (e *SysApi) Get(d *dto.SysApiGetReq, p *actions.DataPermission, model *models.SysApi) *SysApi {
|
||||
var data models.SysApi
|
||||
err := e.Orm.Model(&data).
|
||||
Scopes(
|
||||
@@ -61,7 +61,7 @@ func (e *SysApi) Get(d *dto.SysApiById, p *actions.DataPermission, model *models
|
||||
}
|
||||
|
||||
// Update 修改SysApi对象
|
||||
func (e *SysApi) Update(c *dto.SysApiControl, p *actions.DataPermission) error {
|
||||
func (e *SysApi) Update(c *dto.SysApiUpdateReq, p *actions.DataPermission) error {
|
||||
var model = models.SysApi{}
|
||||
db := e.Orm.Debug().First(&model, c.GetId())
|
||||
if db.RowsAffected == 0 {
|
||||
@@ -78,7 +78,7 @@ func (e *SysApi) Update(c *dto.SysApiControl, p *actions.DataPermission) error {
|
||||
}
|
||||
|
||||
// Remove 删除SysApi
|
||||
func (e *SysApi) Remove(d *dto.SysApiById, p *actions.DataPermission) error {
|
||||
func (e *SysApi) Remove(d *dto.SysApiDeleteReq, p *actions.DataPermission) error {
|
||||
var data models.SysApi
|
||||
|
||||
db := e.Orm.Model(&data).
|
||||
|
||||
@@ -16,7 +16,7 @@ type SysConfig struct {
|
||||
}
|
||||
|
||||
// GetPage 获取SysConfig列表
|
||||
func (e *SysConfig) GetPage(c *dto.SysConfigSearch, list *[]models.SysConfig, count *int64) error {
|
||||
func (e *SysConfig) GetPage(c *dto.SysConfigGetPageReq, list *[]models.SysConfig, count *int64) error {
|
||||
err := e.Orm.
|
||||
Scopes(
|
||||
cDto.MakeCondition(c.GetNeedSearch()),
|
||||
@@ -32,7 +32,7 @@ func (e *SysConfig) GetPage(c *dto.SysConfigSearch, list *[]models.SysConfig, co
|
||||
}
|
||||
|
||||
// Get 获取SysConfig对象
|
||||
func (e *SysConfig) Get(d *dto.SysConfigById, model *models.SysConfig) error {
|
||||
func (e *SysConfig) Get(d *dto.SysConfigGetReq, model *models.SysConfig) error {
|
||||
err := e.Orm.First(model, d.GetId()).Error
|
||||
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
err = errors.New("查看对象不存在或无权查看")
|
||||
@@ -137,7 +137,7 @@ func (e *SysConfig) UpdateForSet(c *[]dto.GetSetSysConfigReq) error {
|
||||
}
|
||||
|
||||
// Remove 删除SysConfig
|
||||
func (e *SysConfig) Remove(d *dto.SysConfigById) error {
|
||||
func (e *SysConfig) Remove(d *dto.SysConfigDeleteReq) error {
|
||||
var err error
|
||||
var data models.SysConfig
|
||||
|
||||
@@ -167,7 +167,7 @@ func (e *SysConfig) GetWithKey(c *dto.SysConfigByKeyReq, resp *dto.GetSysConfigB
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *SysConfig) GetWithKeyList(c *dto.SysConfigSearch, list *[]models.SysConfig) error {
|
||||
func (e *SysConfig) GetWithKeyList(c *dto.SysConfigGetToSysAppReq, list *[]models.SysConfig) error {
|
||||
var err error
|
||||
err = e.Orm.
|
||||
Scopes(
|
||||
|
||||
@@ -20,24 +20,24 @@ type SysDept struct {
|
||||
}
|
||||
|
||||
// GetPage 获取SysDept列表
|
||||
func (e *SysDept) GetPage(c *dto.SysDeptSearch, list *[]models.SysDept) error {
|
||||
var err error
|
||||
var data models.SysDept
|
||||
|
||||
err = e.Orm.Model(&data).
|
||||
Scopes(
|
||||
cDto.MakeCondition(c.GetNeedSearch()),
|
||||
).
|
||||
Find(list).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("db error:%s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
//func (e *SysDept) GetPage(c *dto.SysDeptGetPageReq, list *[]models.SysDept) error {
|
||||
// var err error
|
||||
// var data models.SysDept
|
||||
//
|
||||
// err = e.Orm.Model(&data).
|
||||
// Scopes(
|
||||
// cDto.MakeCondition(c.GetNeedSearch()),
|
||||
// ).
|
||||
// Find(list).Error
|
||||
// if err != nil {
|
||||
// e.Log.Errorf("db error:%s", err)
|
||||
// return err
|
||||
// }
|
||||
// return nil
|
||||
//}
|
||||
|
||||
// Get 获取SysDept对象
|
||||
func (e *SysDept) Get(d *dto.SysDeptById, model *models.SysDept) error {
|
||||
func (e *SysDept) Get(d *dto.SysDeptGetReq, model *models.SysDept) error {
|
||||
var err error
|
||||
var data models.SysDept
|
||||
|
||||
@@ -57,7 +57,7 @@ func (e *SysDept) Get(d *dto.SysDeptById, model *models.SysDept) error {
|
||||
}
|
||||
|
||||
// Insert 创建SysDept对象
|
||||
func (e *SysDept) Insert(c *dto.SysDeptControl) error {
|
||||
func (e *SysDept) Insert(c *dto.SysDeptInsertReq) error {
|
||||
var err error
|
||||
var data models.SysDept
|
||||
c.Generate(&data)
|
||||
@@ -92,7 +92,7 @@ func (e *SysDept) Insert(c *dto.SysDeptControl) error {
|
||||
}
|
||||
|
||||
// Update 修改SysDept对象
|
||||
func (e *SysDept) Update(c *dto.SysDeptControl) error {
|
||||
func (e *SysDept) Update(c *dto.SysDeptUpdateReq) error {
|
||||
var err error
|
||||
var model = models.SysDept{}
|
||||
tx := e.Orm.Debug().Begin()
|
||||
@@ -127,7 +127,7 @@ func (e *SysDept) Update(c *dto.SysDeptControl) error {
|
||||
}
|
||||
|
||||
// Remove 删除SysDept
|
||||
func (e *SysDept) Remove(d *dto.SysDeptById) error {
|
||||
func (e *SysDept) Remove(d *dto.SysDeptDeleteReq) error {
|
||||
var err error
|
||||
var data models.SysDept
|
||||
|
||||
@@ -145,7 +145,7 @@ func (e *SysDept) Remove(d *dto.SysDeptById) error {
|
||||
}
|
||||
|
||||
// GetSysDeptList 获取组织数据
|
||||
func (e *SysDept) getList(c *dto.SysDeptSearch, list *[]models.SysDept) error {
|
||||
func (e *SysDept) getList(c *dto.SysDeptGetPageReq, list *[]models.SysDept) error {
|
||||
var err error
|
||||
var data models.SysDept
|
||||
|
||||
@@ -162,7 +162,7 @@ func (e *SysDept) getList(c *dto.SysDeptSearch, list *[]models.SysDept) error {
|
||||
}
|
||||
|
||||
// SetDeptTree 设置组织数据
|
||||
func (e *SysDept) SetDeptTree(c *dto.SysDeptSearch) (m []dto.DeptLabel, err error) {
|
||||
func (e *SysDept) SetDeptTree(c *dto.SysDeptGetPageReq) (m []dto.DeptLabel, err error) {
|
||||
var list []models.SysDept
|
||||
err = e.getList(c, &list)
|
||||
|
||||
@@ -198,7 +198,7 @@ func deptTreeCall(deptList *[]models.SysDept, dept dto.DeptLabel) dto.DeptLabel
|
||||
}
|
||||
|
||||
// SetDeptPage 设置dept页面数据
|
||||
func (e *SysDept) SetDeptPage(c *dto.SysDeptSearch) (m []models.SysDept, err error) {
|
||||
func (e *SysDept) SetDeptPage(c *dto.SysDeptGetPageReq) (m []models.SysDept, err error) {
|
||||
var list []models.SysDept
|
||||
err = e.getList(c, &list)
|
||||
for i := 0; i < len(list); i++ {
|
||||
|
||||
@@ -16,7 +16,7 @@ type SysDictData struct {
|
||||
}
|
||||
|
||||
// GetPage 获取列表
|
||||
func (e *SysDictData) GetPage(c *dto.SysDictDataSearch, list *[]models.SysDictData, count *int64) error {
|
||||
func (e *SysDictData) GetPage(c *dto.SysDictDataGetPageReq, list *[]models.SysDictData, count *int64) error {
|
||||
var err error
|
||||
var data models.SysDictData
|
||||
|
||||
@@ -35,7 +35,7 @@ func (e *SysDictData) GetPage(c *dto.SysDictDataSearch, list *[]models.SysDictDa
|
||||
}
|
||||
|
||||
// Get 获取对象
|
||||
func (e *SysDictData) Get(d *dto.SysDictDataById, model *models.SysDictData) error {
|
||||
func (e *SysDictData) Get(d *dto.SysDictDataGetReq, model *models.SysDictData) error {
|
||||
var err error
|
||||
var data models.SysDictData
|
||||
|
||||
@@ -55,7 +55,7 @@ func (e *SysDictData) Get(d *dto.SysDictDataById, model *models.SysDictData) err
|
||||
}
|
||||
|
||||
// Insert 创建对象
|
||||
func (e *SysDictData) Insert(c *dto.SysDictDataControl) error {
|
||||
func (e *SysDictData) Insert(c *dto.SysDictDataInsertReq) error {
|
||||
var err error
|
||||
var data = new(models.SysDictData)
|
||||
c.Generate(data)
|
||||
@@ -68,7 +68,7 @@ func (e *SysDictData) Insert(c *dto.SysDictDataControl) error {
|
||||
}
|
||||
|
||||
// Update 修改对象
|
||||
func (e *SysDictData) Update(c *dto.SysDictDataControl) error {
|
||||
func (e *SysDictData) Update(c *dto.SysDictDataUpdateReq) error {
|
||||
var err error
|
||||
var model = models.SysDictData{}
|
||||
e.Orm.First(&model, c.GetId())
|
||||
@@ -86,7 +86,7 @@ func (e *SysDictData) Update(c *dto.SysDictDataControl) error {
|
||||
}
|
||||
|
||||
// Remove 删除
|
||||
func (e *SysDictData) Remove(c *dto.SysDictDataById) error {
|
||||
func (e *SysDictData) Remove(c *dto.SysDictDataDeleteReq) error {
|
||||
var err error
|
||||
var data models.SysDictData
|
||||
|
||||
@@ -104,7 +104,7 @@ func (e *SysDictData) Remove(c *dto.SysDictDataById) error {
|
||||
}
|
||||
|
||||
// GetAll 获取所有
|
||||
func (e *SysDictData) GetAll(c *dto.SysDictDataSearch, list *[]models.SysDictData) error {
|
||||
func (e *SysDictData) GetAll(c *dto.SysDictDataGetPageReq, list *[]models.SysDictData) error {
|
||||
var err error
|
||||
var data models.SysDictData
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ type SysDictType struct {
|
||||
}
|
||||
|
||||
// GetPage 获取列表
|
||||
func (e *SysDictType) GetPage(c *dto.SysDictTypeSearch, list *[]models.SysDictType, count *int64) error {
|
||||
func (e *SysDictType) GetPage(c *dto.SysDictTypeGetPageReq, list *[]models.SysDictType, count *int64) error {
|
||||
var err error
|
||||
var data models.SysDictType
|
||||
|
||||
@@ -35,7 +35,7 @@ func (e *SysDictType) GetPage(c *dto.SysDictTypeSearch, list *[]models.SysDictTy
|
||||
}
|
||||
|
||||
// Get 获取对象
|
||||
func (e *SysDictType) Get(d *dto.SysDictTypeById, model *models.SysDictType) error {
|
||||
func (e *SysDictType) Get(d *dto.SysDictTypeGetReq, model *models.SysDictType) error {
|
||||
var err error
|
||||
|
||||
db := e.Orm.First(model, d.GetId())
|
||||
@@ -53,7 +53,7 @@ func (e *SysDictType) Get(d *dto.SysDictTypeById, model *models.SysDictType) err
|
||||
}
|
||||
|
||||
// Insert 创建对象
|
||||
func (e *SysDictType) Insert(c *dto.SysDictTypeControl) error {
|
||||
func (e *SysDictType) Insert(c *dto.SysDictTypeInsertReq) error {
|
||||
var err error
|
||||
var data models.SysDictType
|
||||
c.Generate(&data)
|
||||
@@ -71,7 +71,7 @@ func (e *SysDictType) Insert(c *dto.SysDictTypeControl) error {
|
||||
}
|
||||
|
||||
// Update 修改对象
|
||||
func (e *SysDictType) Update(c *dto.SysDictTypeControl) error {
|
||||
func (e *SysDictType) Update(c *dto.SysDictTypeUpdateReq) error {
|
||||
var err error
|
||||
var model = models.SysDictType{}
|
||||
e.Orm.First(&model, c.GetId())
|
||||
@@ -89,7 +89,7 @@ func (e *SysDictType) Update(c *dto.SysDictTypeControl) error {
|
||||
}
|
||||
|
||||
// Remove 删除
|
||||
func (e *SysDictType) Remove(d *dto.SysDictTypeById) error {
|
||||
func (e *SysDictType) Remove(d *dto.SysDictTypeDeleteReq) error {
|
||||
var err error
|
||||
var data models.SysDictType
|
||||
|
||||
@@ -107,7 +107,7 @@ func (e *SysDictType) Remove(d *dto.SysDictTypeById) error {
|
||||
}
|
||||
|
||||
// GetAll 获取所有
|
||||
func (e *SysDictType) GetAll(c *dto.SysDictTypeSearch, list *[]models.SysDictType) error {
|
||||
func (e *SysDictType) GetAll(c *dto.SysDictTypeGetPageReq, list *[]models.SysDictType) error {
|
||||
var err error
|
||||
var data models.SysDictType
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ type SysLoginLog struct {
|
||||
service.Service
|
||||
}
|
||||
|
||||
// GetSysLoginLogPage 获取SysLoginLog列表
|
||||
func (e *SysLoginLog) GetPage(c *dto.SysLoginLogSearch, list *[]models.SysLoginLog, count *int64) error {
|
||||
// GetPage 获取SysLoginLog列表
|
||||
func (e *SysLoginLog) GetPage(c *dto.SysLoginLogGetPageReq, list *[]models.SysLoginLog, count *int64) error {
|
||||
var err error
|
||||
var data models.SysLoginLog
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
||||
"gorm.io/gorm"
|
||||
|
||||
@@ -19,7 +18,7 @@ type SysMenu struct {
|
||||
}
|
||||
|
||||
// GetPage 获取SysMenu列表
|
||||
func (e *SysMenu) GetPage(c *dto.SysMenuSearch, menus *[]models.SysMenu) *SysMenu {
|
||||
func (e *SysMenu) GetPage(c *dto.SysMenuGetPageReq, menus *[]models.SysMenu) *SysMenu {
|
||||
var menu = make([]models.SysMenu, 0)
|
||||
err := e.getPage(c, &menu).Error
|
||||
if err != nil {
|
||||
@@ -37,7 +36,7 @@ func (e *SysMenu) GetPage(c *dto.SysMenuSearch, menus *[]models.SysMenu) *SysMen
|
||||
}
|
||||
|
||||
// getPage 菜单分页列表
|
||||
func (e *SysMenu) getPage(c *dto.SysMenuSearch, list *[]models.SysMenu) *SysMenu {
|
||||
func (e *SysMenu) getPage(c *dto.SysMenuGetPageReq, list *[]models.SysMenu) *SysMenu {
|
||||
var err error
|
||||
var data models.SysMenu
|
||||
|
||||
@@ -56,7 +55,7 @@ func (e *SysMenu) getPage(c *dto.SysMenuSearch, list *[]models.SysMenu) *SysMenu
|
||||
}
|
||||
|
||||
// Get 获取SysMenu对象
|
||||
func (e *SysMenu) Get(d *dto.SysMenuById, model *models.SysMenu) *SysMenu {
|
||||
func (e *SysMenu) Get(d *dto.SysMenuGetReq, model *models.SysMenu) *SysMenu {
|
||||
var err error
|
||||
var data models.SysMenu
|
||||
|
||||
@@ -83,7 +82,7 @@ func (e *SysMenu) Get(d *dto.SysMenuById, model *models.SysMenu) *SysMenu {
|
||||
}
|
||||
|
||||
// Insert 创建SysMenu对象
|
||||
func (e *SysMenu) Insert(c *dto.SysMenuControl) *SysMenu {
|
||||
func (e *SysMenu) Insert(c *dto.SysMenuInsertReq) *SysMenu {
|
||||
var err error
|
||||
var data models.SysMenu
|
||||
c.Generate(&data)
|
||||
@@ -115,7 +114,7 @@ func (e *SysMenu) initPaths(menu *models.SysMenu) error {
|
||||
}
|
||||
|
||||
// Update 修改SysMenu对象
|
||||
func (e *SysMenu) Update(c *dto.SysMenuControl) *SysMenu {
|
||||
func (e *SysMenu) Update(c *dto.SysMenuUpdateReq) *SysMenu {
|
||||
var err error
|
||||
tx := e.Orm.Debug().Begin()
|
||||
defer func() {
|
||||
@@ -151,7 +150,7 @@ func (e *SysMenu) Update(c *dto.SysMenuControl) *SysMenu {
|
||||
}
|
||||
|
||||
// Remove 删除SysMenu
|
||||
func (e *SysMenu) Remove(d *dto.SysMenuById) *SysMenu {
|
||||
func (e *SysMenu) Remove(d *dto.SysMenuDeleteReq) *SysMenu {
|
||||
var err error
|
||||
var data models.SysMenu
|
||||
|
||||
@@ -169,7 +168,7 @@ func (e *SysMenu) Remove(d *dto.SysMenuById) *SysMenu {
|
||||
}
|
||||
|
||||
// GetList 获取菜单数据
|
||||
func (e *SysMenu) GetList(c *dto.SysMenuSearch, list *[]models.SysMenu) error {
|
||||
func (e *SysMenu) GetList(c *dto.SysMenuGetPageReq, list *[]models.SysMenu) error {
|
||||
var err error
|
||||
var data models.SysMenu
|
||||
|
||||
@@ -188,7 +187,7 @@ func (e *SysMenu) GetList(c *dto.SysMenuSearch, list *[]models.SysMenu) error {
|
||||
// SetLabel 修改角色中 设置菜单基础数据
|
||||
func (e *SysMenu) SetLabel() (m []dto.MenuLabel, err error) {
|
||||
var list []models.SysMenu
|
||||
err = e.GetList(&dto.SysMenuSearch{}, &list)
|
||||
err = e.GetList(&dto.SysMenuGetPageReq{}, &list)
|
||||
|
||||
m = make([]dto.MenuLabel, 0)
|
||||
for i := 0; i < len(list); i++ {
|
||||
@@ -333,11 +332,25 @@ func (e *SysMenu) getByRoleName(roleName string) ([]models.SysMenu, error) {
|
||||
} else {
|
||||
role.RoleKey = roleName
|
||||
err = e.Orm.Debug().Model(&role).Where("role_key = ? ", roleName).Preload("SysMenu", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Where(" menu_type in ('M','C')").Order("sort")
|
||||
return db.Where(" menu_type in ('C')").Order("sort")
|
||||
}).Find(&role).Error
|
||||
if role.SysMenu != nil {
|
||||
MenuList = *role.SysMenu
|
||||
}
|
||||
mIds := make([]int, 0)
|
||||
for _, menu := range MenuList {
|
||||
if menu.ParentId != 0 {
|
||||
mIds = append(mIds, menu.ParentId)
|
||||
}
|
||||
}
|
||||
var data []models.SysMenu
|
||||
err = e.Orm.Where(" menu_type in ('M') and menu_id in ?", mIds).Order("sort").Find(&data).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, datum := range data {
|
||||
MenuList = append(MenuList, datum)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -16,7 +16,7 @@ type SysOperaLog struct {
|
||||
}
|
||||
|
||||
// GetPage 获取SysOperaLog列表
|
||||
func (e *SysOperaLog) GetPage(c *dto.SysOperaLogSearch, list *[]models.SysOperaLog, count *int64) error {
|
||||
func (e *SysOperaLog) GetPage(c *dto.SysOperaLogGetPageReq, list *[]models.SysOperaLog, count *int64) error {
|
||||
var err error
|
||||
var data models.SysOperaLog
|
||||
|
||||
@@ -35,7 +35,7 @@ func (e *SysOperaLog) GetPage(c *dto.SysOperaLogSearch, list *[]models.SysOperaL
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ type SysPost struct {
|
||||
service.Service
|
||||
}
|
||||
|
||||
// GetSysPostPage 获取SysPost列表
|
||||
func (e *SysPost) GetSysPostPage(c *dto.SysPostSearch, list *[]models.SysPost, count *int64) error {
|
||||
// GetPage 获取SysPost列表
|
||||
func (e *SysPost) GetPage(c *dto.SysPostPageReq, list *[]models.SysPost, count *int64) error {
|
||||
var err error
|
||||
var data models.SysPost
|
||||
|
||||
@@ -28,14 +28,14 @@ func (e *SysPost) GetSysPostPage(c *dto.SysPostSearch, list *[]models.SysPost, c
|
||||
Find(list).Limit(-1).Offset(-1).
|
||||
Count(count).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("db error:%s", err)
|
||||
e.Log.Errorf("db error:%s \r", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSysPost 获取SysPost对象
|
||||
func (e *SysPost) GetSysPost(d *dto.SysPostById, model *models.SysPost) error {
|
||||
// Get 获取SysPost对象
|
||||
func (e *SysPost) Get(d *dto.SysPostGetReq, model *models.SysPost) error {
|
||||
var err error
|
||||
var data models.SysPost
|
||||
|
||||
@@ -54,8 +54,8 @@ func (e *SysPost) GetSysPost(d *dto.SysPostById, model *models.SysPost) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// InsertSysPost 创建SysPost对象
|
||||
func (e *SysPost) InsertSysPost(c *dto.SysPostControl) error {
|
||||
// Insert 创建SysPost对象
|
||||
func (e *SysPost) Insert(c *dto.SysPostInsertReq) error {
|
||||
var err error
|
||||
var data models.SysPost
|
||||
c.Generate(&data)
|
||||
@@ -67,8 +67,8 @@ func (e *SysPost) InsertSysPost(c *dto.SysPostControl) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateSysPost 修改SysPost对象
|
||||
func (e *SysPost) UpdateSysPost(c *dto.SysPostControl) error {
|
||||
// Update 修改SysPost对象
|
||||
func (e *SysPost) Update(c *dto.SysPostUpdateReq) error {
|
||||
var err error
|
||||
var model = models.SysPost{}
|
||||
e.Orm.First(&model, c.GetId())
|
||||
@@ -86,8 +86,8 @@ func (e *SysPost) UpdateSysPost(c *dto.SysPostControl) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemoveSysPost 删除SysPost
|
||||
func (e *SysPost) RemoveSysPost(d *dto.SysPostById) error {
|
||||
// Remove 删除SysPost
|
||||
func (e *SysPost) Remove(d *dto.SysPostDeleteReq) error {
|
||||
var err error
|
||||
var data models.SysPost
|
||||
|
||||
@@ -102,4 +102,4 @@ func (e *SysPost) RemoveSysPost(d *dto.SysPostById) error {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ type SysRole struct {
|
||||
}
|
||||
|
||||
// GetPage 获取SysRole列表
|
||||
func (e *SysRole) GetPage(c *dto.SysRoleSearch, list *[]models.SysRole, count *int64) error {
|
||||
func (e *SysRole) GetPage(c *dto.SysRoleGetPageReq, list *[]models.SysRole, count *int64) error {
|
||||
var err error
|
||||
var data models.SysRole
|
||||
|
||||
@@ -38,7 +38,7 @@ func (e *SysRole) GetPage(c *dto.SysRoleSearch, list *[]models.SysRole, count *i
|
||||
}
|
||||
|
||||
// Get 获取SysRole对象
|
||||
func (e *SysRole) Get(d *dto.SysRoleById, model *models.SysRole) error {
|
||||
func (e *SysRole) Get(d *dto.SysRoleGetReq, model *models.SysRole) error {
|
||||
var err error
|
||||
db := e.Orm.First(model, d.GetId())
|
||||
err = db.Error
|
||||
@@ -60,7 +60,7 @@ func (e *SysRole) Get(d *dto.SysRoleById, model *models.SysRole) error {
|
||||
}
|
||||
|
||||
// Insert 创建SysRole对象
|
||||
func (e *SysRole) Insert(c *dto.SysRoleControl, cb *casbin.SyncedEnforcer) error {
|
||||
func (e *SysRole) Insert(c *dto.SysRoleInsertReq, cb *casbin.SyncedEnforcer) error {
|
||||
var err error
|
||||
var data models.SysRole
|
||||
var dataMenu []models.SysMenu
|
||||
@@ -106,7 +106,7 @@ func (e *SysRole) Insert(c *dto.SysRoleControl, cb *casbin.SyncedEnforcer) error
|
||||
}
|
||||
|
||||
// Update 修改SysRole对象
|
||||
func (e *SysRole) Update(c *dto.SysRoleControl, cb *casbin.SyncedEnforcer) error {
|
||||
func (e *SysRole) Update(c *dto.SysRoleUpdateReq, cb *casbin.SyncedEnforcer) error {
|
||||
var err error
|
||||
tx := e.Orm.Debug().Begin()
|
||||
defer func() {
|
||||
@@ -153,7 +153,7 @@ func (e *SysRole) Update(c *dto.SysRoleControl, cb *casbin.SyncedEnforcer) error
|
||||
}
|
||||
|
||||
// Remove 删除SysRole
|
||||
func (e *SysRole) Remove(c *dto.SysRoleById) error {
|
||||
func (e *SysRole) Remove(c *dto.SysRoleDeleteReq) error {
|
||||
var err error
|
||||
tx := e.Orm.Begin()
|
||||
defer func() {
|
||||
|
||||
@@ -19,7 +19,7 @@ type SysUser struct {
|
||||
}
|
||||
|
||||
// GetPage 获取SysUser列表
|
||||
func (e *SysUser) GetPage(c *dto.SysUserSearch, p *actions.DataPermission, list *[]models.SysUser, count *int64) error {
|
||||
func (e *SysUser) GetPage(c *dto.SysUserGetPageReq, p *actions.DataPermission, list *[]models.SysUser, count *int64) error {
|
||||
var err error
|
||||
var data models.SysUser
|
||||
|
||||
@@ -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,36 @@ 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)
|
||||
update := e.Orm.Model(&model).Where("user_id = ?", &model.UserId).Omit("password", "salt").Updates(&model)
|
||||
if err = update.Error; err != nil {
|
||||
e.Log.Errorf("db error: %s", err)
|
||||
return err
|
||||
}
|
||||
if update.RowsAffected == 0 {
|
||||
err = errors.New("update userinfo error")
|
||||
log.Warnf("db update error")
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateAvatar 更新用户头像
|
||||
func (e *SysUser) UpdateAvatar(c *dto.UpdateSysUserAvatarReq, p *actions.DataPermission) error {
|
||||
var err error
|
||||
var model models.SysUser
|
||||
db := e.Orm.Scopes(
|
||||
@@ -107,8 +136,8 @@ func (e *SysUser) Update(c *dto.SysUserControl, p *actions.DataPermission) error
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateSysUserStatus 更新用户状态
|
||||
func (e *SysUser) UpdateSysUserStatus(c *dto.UpdateSysUserStatusReq, p *actions.DataPermission) error {
|
||||
// UpdateStatus 更新用户状态
|
||||
func (e *SysUser) UpdateStatus(c *dto.UpdateSysUserStatusReq, p *actions.DataPermission) error {
|
||||
var err error
|
||||
var model models.SysUser
|
||||
db := e.Orm.Scopes(
|
||||
@@ -131,8 +160,8 @@ func (e *SysUser) UpdateSysUserStatus(c *dto.UpdateSysUserStatusReq, p *actions.
|
||||
return nil
|
||||
}
|
||||
|
||||
// ResetSysUserPwd 重置用户密码
|
||||
func (e *SysUser) ResetSysUserPwd(c *dto.ResetSysUserPwdReq, p *actions.DataPermission) error {
|
||||
// ResetPwd 重置用户密码
|
||||
func (e *SysUser) ResetPwd(c *dto.ResetSysUserPwdReq, p *actions.DataPermission) error {
|
||||
var err error
|
||||
var model models.SysUser
|
||||
db := e.Orm.Scopes(
|
||||
@@ -173,8 +202,8 @@ func (e *SysUser) Remove(c *dto.SysUserById, p *actions.DataPermission) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateSysUserPwd 修改SysUser对象密码
|
||||
func (e *SysUser) UpdateSysUserPwd(id int, oldPassword, newPassword string, p *actions.DataPermission) error {
|
||||
// UpdatePwd 修改SysUser对象密码
|
||||
func (e *SysUser) UpdatePwd(id int, oldPassword, newPassword string, p *actions.DataPermission) error {
|
||||
var err error
|
||||
|
||||
if newPassword == "" {
|
||||
@@ -219,7 +248,7 @@ func (e *SysUser) UpdateSysUserPwd(id int, oldPassword, newPassword string, p *a
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *SysUser) GetSysUserProfile(c *dto.SysUserById, user *models.SysUser, roles *[]models.SysRole, posts *[]models.SysPost) error {
|
||||
func (e *SysUser) GetProfile(c *dto.SysUserById, user *models.SysUser, roles *[]models.SysRole, posts *[]models.SysPost) error {
|
||||
err := e.Orm.Preload("Dept").First(user, c.GetId()).Error
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -33,7 +33,7 @@ func (e SysJob) RemoveJobForService(c *gin.Context) {
|
||||
err = s.RemoveJob(&v)
|
||||
if err != nil {
|
||||
e.Logger.Errorf("RemoveJob error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "")
|
||||
e.Error(500, err, "")
|
||||
return
|
||||
}
|
||||
e.OK(nil, s.Msg)
|
||||
@@ -62,7 +62,7 @@ func (e SysJob) StartJobForService(c *gin.Context) {
|
||||
err = s.StartJob(&v)
|
||||
if err != nil {
|
||||
log.Errorf("GetCrontabKey error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "")
|
||||
e.Error(500, err, "")
|
||||
return
|
||||
}
|
||||
e.OK(nil, s.Msg)
|
||||
|
||||
@@ -40,6 +40,7 @@ type File struct {
|
||||
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/public/uploadFile [post]
|
||||
// @Security Bearer
|
||||
func (e File) UploadFile(c *gin.Context) {
|
||||
e.MakeContext(c)
|
||||
tag, _ := c.GetPostForm("type")
|
||||
|
||||
@@ -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,15 +27,31 @@ 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
|
||||
// @Tags 系统信息
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/server-monitor [get]
|
||||
// @Security Bearer
|
||||
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
|
||||
@@ -41,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
|
||||
@@ -66,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,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
||||
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
||||
|
||||
"go-admin/app/admin/models/tools"
|
||||
"go-admin/app/other/models/tools"
|
||||
)
|
||||
|
||||
// GetDBColumnList 分页列表数据
|
||||
// @Summary 分页列表数据 / page list data
|
||||
// @Description 数据库表列分页列表 / database table column page list
|
||||
// @Tags 工具 / Tools
|
||||
// @Tags 工具 / 生成工具
|
||||
// @Param tableName query string false "tableName / 数据表名称"
|
||||
// @Param pageSize query int false "pageSize / 页条数"
|
||||
// @Param pageIndex query int false "pageIndex / 页码"
|
||||
@@ -38,7 +36,7 @@ func (e *Gen) GetDBColumnList(c *gin.Context) {
|
||||
db, err := pkg.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Error(500, err, "数据库连接获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,20 +2,18 @@ package tools
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/config"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
||||
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
||||
|
||||
"go-admin/app/admin/models/tools"
|
||||
"go-admin/app/other/models/tools"
|
||||
)
|
||||
|
||||
// GetDBTableList 分页列表数据
|
||||
// @Summary 分页列表数据 / page list data
|
||||
// @Description 数据库表分页列表 / database table page list
|
||||
// @Tags 工具 / Tools
|
||||
// @Tags 工具 / 生成工具
|
||||
// @Param tableName query string false "tableName / 数据表名称"
|
||||
// @Param pageSize query int false "pageSize / 页条数"
|
||||
// @Param pageIndex query int false "pageIndex / 页码"
|
||||
@@ -47,7 +45,7 @@ func (e *Gen) GetDBTableList(c *gin.Context) {
|
||||
db, err := pkg.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Error(500, err, "数据库连接获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ package tools
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go-admin/app/admin/service"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/go-admin-team/go-admin-core/sdk/config"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
||||
|
||||
"go-admin/app/admin/models/tools"
|
||||
"go-admin/app/other/models/tools"
|
||||
)
|
||||
|
||||
type Gen struct {
|
||||
@@ -29,61 +29,61 @@ func (e Gen) Preview(c *gin.Context) {
|
||||
id, err := pkg.StringToInt(c.Param("tableId"))
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("tableId接收失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
table.TableId = id
|
||||
t1, err := template.ParseFiles("template/v4/model.go.template")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("model模版读取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t2, err := template.ParseFiles("template/v4/no_actions/apis.go.template")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("api模版读取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t3, err := template.ParseFiles("template/v4/js.go.template")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("js模版读取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t4, err := template.ParseFiles("template/v4/vue.go.template")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("vue模版读取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t5, err := template.ParseFiles("template/v4/no_actions/router_check_role.go.template")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("路由模版读取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t6, err := template.ParseFiles("template/v4/dto.go.template")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("dto模版读取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t7, err := template.ParseFiles("template/v4/no_actions/service.go.template")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("service模版读取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
db, err := pkg.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Error(500, err, fmt.Sprintf("数据库链接获取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
tab, _ := table.Get(db)
|
||||
tab, _ := table.Get(db,false)
|
||||
var b1 bytes.Buffer
|
||||
err = t1.Execute(&b1, tab)
|
||||
var b2 bytes.Buffer
|
||||
@@ -117,25 +117,21 @@ func (e Gen) GenCode(c *gin.Context) {
|
||||
id, err := pkg.StringToInt(c.Param("tableId"))
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("tableId参数接收失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
db, err := pkg.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Error(500, err, fmt.Sprintf("数据库链接获取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
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!")
|
||||
}
|
||||
@@ -147,19 +143,19 @@ func (e Gen) GenApiToFile(c *gin.Context) {
|
||||
id, err := pkg.StringToInt(c.Param("tableId"))
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("tableId参数获取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
db, err := pkg.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Error(500, err, fmt.Sprintf("数据库链接获取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
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"
|
||||
@@ -179,43 +176,43 @@ func (e Gen) NOActionsGen(c *gin.Context, tab tools.SysTables) {
|
||||
t1, err := template.ParseFiles(basePath + "model.go.template")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("model模版读取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t2, err := template.ParseFiles(basePath + "no_actions/apis.go.template")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("api模版读取失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t3, err := template.ParseFiles(routerFile)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("路由模版失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t4, err := template.ParseFiles(basePath + "js.go.template")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("js模版解析失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t5, err := template.ParseFiles(basePath + "vue.go.template")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("vue模版解析失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t6, err := template.ParseFiles(basePath + "dto.go.template")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("dto模版解析失败失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
t7, err := template.ParseFiles(basePath + "no_actions/service.go.template")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("service模版失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
}
|
||||
|
||||
@@ -265,7 +267,7 @@ func (e Gen) genApiToFile(c *gin.Context, tab tools.SysTables) {
|
||||
t1, err := template.ParseFiles(basePath + "api_migrate.template")
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, "")
|
||||
e.Error(500, err, fmt.Sprintf("数据迁移模版解析失败!错误详情:%s", err.Error()))
|
||||
return
|
||||
}
|
||||
i := strconv.FormatInt(time.Now().UnixNano()/1e6, 10)
|
||||
@@ -279,80 +281,8 @@ 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, "")
|
||||
return
|
||||
}
|
||||
t3, err := template.ParseFiles(routerFile)
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, "")
|
||||
return
|
||||
}
|
||||
t4, err := template.ParseFiles(basePath + "js.go.template")
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, "")
|
||||
return
|
||||
}
|
||||
t5, err := template.ParseFiles(basePath + "vue.go.template")
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, "")
|
||||
return
|
||||
}
|
||||
t6, err := template.ParseFiles(basePath + "dto.go.template")
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, "")
|
||||
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{}
|
||||
s := service.SysMenu{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
MakeService(&s.Service).
|
||||
@@ -365,16 +295,20 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
|
||||
table := tools.SysTables{}
|
||||
id, err := pkg.StringToInt(c.Param("tableId"))
|
||||
pkg.HasError(err, "", -1)
|
||||
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
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 := dto.SysMenuInsertReq{}
|
||||
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
|
||||
@@ -386,17 +320,17 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
Mmenu.CreateBy = 1
|
||||
s.Insert(&Mmenu)
|
||||
|
||||
Cmenu := dto.SysMenuControl{}
|
||||
Cmenu := dto.SysMenuInsertReq{}
|
||||
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"
|
||||
@@ -404,14 +338,14 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
Cmenu.UpdateBy = 1
|
||||
s.Insert(&Cmenu)
|
||||
|
||||
MList := dto.SysMenuControl{}
|
||||
MList := dto.SysMenuInsertReq{}
|
||||
MList.MenuName = ""
|
||||
MList.Title = "分页获取" + tab.TableComment
|
||||
MList.Icon = ""
|
||||
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
|
||||
@@ -421,14 +355,14 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
MList.UpdateBy = 1
|
||||
s.Insert(&MList)
|
||||
|
||||
MCreate := dto.SysMenuControl{}
|
||||
MCreate := dto.SysMenuInsertReq{}
|
||||
MCreate.MenuName = ""
|
||||
MCreate.Title = "创建" + tab.TableComment
|
||||
MCreate.Icon = ""
|
||||
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
|
||||
@@ -438,14 +372,14 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
MCreate.UpdateBy = 1
|
||||
s.Insert(&MCreate)
|
||||
|
||||
MUpdate := dto.SysMenuControl{}
|
||||
MUpdate := dto.SysMenuInsertReq{}
|
||||
MUpdate.MenuName = ""
|
||||
MUpdate.Title = "修改" + tab.TableComment
|
||||
MUpdate.Icon = ""
|
||||
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
|
||||
@@ -455,14 +389,14 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
MUpdate.UpdateBy = 1
|
||||
s.Insert(&MUpdate)
|
||||
|
||||
MDelete := dto.SysMenuControl{}
|
||||
MDelete := dto.SysMenuInsertReq{}
|
||||
MDelete.MenuName = ""
|
||||
MDelete.Title = "删除" + tab.TableComment
|
||||
MDelete.Icon = ""
|
||||
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
|
||||
@@ -472,6 +406,5 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
|
||||
MDelete.UpdateBy = 1
|
||||
s.Insert(&MDelete)
|
||||
|
||||
|
||||
e.OK("", "数据生成成功!")
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -10,23 +9,23 @@ import (
|
||||
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/admin/models/tools"
|
||||
"go-admin/app/other/models/tools"
|
||||
)
|
||||
|
||||
type SysTable struct {
|
||||
api.Api
|
||||
}
|
||||
|
||||
// GetSysTableList 分页列表数据
|
||||
// GetPage 分页列表数据
|
||||
// @Summary 分页列表数据
|
||||
// @Description 生成表分页列表
|
||||
// @Tags 工具 - 生成表
|
||||
// @Tags 工具 / 生成工具
|
||||
// @Param tableName query string false "tableName / 数据表名称"
|
||||
// @Param pageSize query int false "pageSize / 页条数"
|
||||
// @Param pageIndex query int false "pageIndex / 页码"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/sys/tables/page [get]
|
||||
func (e SysTable) GetSysTableList(c *gin.Context) {
|
||||
func (e SysTable) GetPage(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
var data tools.SysTables
|
||||
@@ -45,7 +44,7 @@ func (e SysTable) GetSysTableList(c *gin.Context) {
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Error(500, err, "数据库连接获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -60,26 +59,27 @@ func (e SysTable) GetSysTableList(c *gin.Context) {
|
||||
e.PageOK(result, count, pageIndex, pageSize, "查询成功")
|
||||
}
|
||||
|
||||
// Get
|
||||
// @Summary 获取配置
|
||||
// @Description 获取JSON
|
||||
// @Tags 工具 - 生成表
|
||||
// @Tags 工具 / 生成工具
|
||||
// @Param configKey path int true "configKey"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/sys/tables/info/{tableId} [get]
|
||||
// @Security Bearer
|
||||
func (e SysTable) GetSysTables(c *gin.Context) {
|
||||
func (e SysTable) Get(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Error(500, err, "数据库连接获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
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, "")
|
||||
@@ -98,7 +98,7 @@ func (e SysTable) GetSysTablesInfo(c *gin.Context) {
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Error(500, err, "数据库连接获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -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, "抱歉未找到相关信息")
|
||||
@@ -127,7 +127,7 @@ func (e SysTable) GetSysTablesTree(c *gin.Context) {
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Error(500, err, "数据库连接获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -142,9 +142,10 @@ func (e SysTable) GetSysTablesTree(c *gin.Context) {
|
||||
e.OK(result, "")
|
||||
}
|
||||
|
||||
// Insert
|
||||
// @Summary 添加表结构
|
||||
// @Description 添加表结构
|
||||
// @Tags 工具 - 生成表
|
||||
// @Tags 工具 / 生成工具
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param tables query string false "tableName / 数据表名称"
|
||||
@@ -152,13 +153,13 @@ func (e SysTable) GetSysTablesTree(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/sys/tables/info [post]
|
||||
// @Security Bearer
|
||||
func (e SysTable) InsertSysTable(c *gin.Context) {
|
||||
func (e SysTable) Insert(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Error(500, err, "数据库连接获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -201,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
|
||||
@@ -218,11 +227,11 @@ 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"
|
||||
data.IsActions = 1
|
||||
data.IsActions = 2
|
||||
data.IsDataScope = 1
|
||||
data.IsAuth = 1
|
||||
|
||||
@@ -287,9 +296,10 @@ func genTableInit(tx *gorm.DB, tablesList []string, i int, c *gin.Context) (tool
|
||||
return data, err
|
||||
}
|
||||
|
||||
// Update
|
||||
// @Summary 修改表结构
|
||||
// @Description 修改表结构
|
||||
// @Tags 工具 - 生成表
|
||||
// @Tags 工具 / 生成工具
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body tools.SysTables true "body"
|
||||
@@ -297,7 +307,7 @@ func genTableInit(tx *gorm.DB, tablesList []string, i int, c *gin.Context) (tool
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/sys/tables/info [put]
|
||||
// @Security Bearer
|
||||
func (e SysTable) UpdateSysTable(c *gin.Context) {
|
||||
func (e SysTable) Update(c *gin.Context) {
|
||||
var data tools.SysTables
|
||||
err := c.Bind(&data)
|
||||
pkg.HasError(err, "数据解析失败", 500)
|
||||
@@ -307,7 +317,7 @@ func (e SysTable) UpdateSysTable(c *gin.Context) {
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Error(500, err, "数据库连接获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -321,20 +331,21 @@ func (e SysTable) UpdateSysTable(c *gin.Context) {
|
||||
e.OK(result, "修改成功")
|
||||
}
|
||||
|
||||
// Delete
|
||||
// @Summary 删除表结构
|
||||
// @Description 删除表结构
|
||||
// @Tags 工具 - 生成表
|
||||
// @Tags 工具 / 生成工具
|
||||
// @Param tableId path int true "tableId"
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
||||
// @Router /api/v1/sys/tables/info/{tableId} [delete]
|
||||
func (e SysTable) DeleteSysTables(c *gin.Context) {
|
||||
func (e SysTable) Delete(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Errorf("get db connection error, %s", err.Error())
|
||||
e.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Error(500, err, "数据库连接获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,19 @@ package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
|
||||
"go-admin/app/other/apis"
|
||||
)
|
||||
|
||||
func init() {
|
||||
routerNoCheckRole = append(routerNoCheckRole, registerFileRouter)
|
||||
routerCheckRole = append(routerCheckRole, registerFileRouter)
|
||||
}
|
||||
|
||||
// 需认证的路由代码
|
||||
func registerFileRouter(v1 *gin.RouterGroup) {
|
||||
func registerFileRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
var api = apis.File{}
|
||||
v1.POST("/public/uploadFile", api.UploadFile)
|
||||
r := v1.Group("").Use(authMiddleware.MiddlewareFunc())
|
||||
{
|
||||
r.POST("/public/uploadFile", api.UploadFile)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
|
||||
"go-admin/app/admin/apis"
|
||||
"go-admin/app/admin/apis/tools"
|
||||
"go-admin/app/other/apis/tools"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -15,7 +15,7 @@ func sysNoCheckRoleRouter(v1 *gin.RouterGroup ,authMiddleware *jwt.GinJWTMiddlew
|
||||
r1 := v1.Group("")
|
||||
{
|
||||
sys := apis.System{}
|
||||
r1.GET("/getCaptcha", sys.GenerateCaptchaHandler)
|
||||
r1.GET("/captcha", sys.GenerateCaptchaHandler)
|
||||
}
|
||||
|
||||
r := v1.Group("").Use(authMiddleware.MiddlewareFunc())
|
||||
@@ -43,13 +43,13 @@ func registerSysTableRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl
|
||||
tables := v1.Group("/sys/tables")
|
||||
{
|
||||
sysTable := tools.SysTable{}
|
||||
tables.Group("").Use(authMiddleware.MiddlewareFunc()).GET("/page", sysTable.GetSysTableList)
|
||||
tables.Group("").Use(authMiddleware.MiddlewareFunc()).GET("/page", sysTable.GetPage)
|
||||
tablesInfo := tables.Group("/info").Use(authMiddleware.MiddlewareFunc())
|
||||
{
|
||||
tablesInfo.POST("", sysTable.InsertSysTable)
|
||||
tablesInfo.PUT("", sysTable.UpdateSysTable)
|
||||
tablesInfo.DELETE("/:tableId", sysTable.DeleteSysTables)
|
||||
tablesInfo.GET("/:tableId", sysTable.GetSysTables)
|
||||
tablesInfo.POST("", sysTable.Insert)
|
||||
tablesInfo.PUT("", sysTable.Update)
|
||||
tablesInfo.DELETE("/:tableId", sysTable.Delete)
|
||||
tablesInfo.GET("/:tableId", sysTable.Get)
|
||||
tablesInfo.GET("", sysTable.GetSysTablesInfo)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
||||
"go-admin/cmd/app"
|
||||
"go-admin/common/global"
|
||||
"os"
|
||||
|
||||
@@ -45,6 +46,7 @@ func init() {
|
||||
rootCmd.AddCommand(migrate.StartCmd)
|
||||
rootCmd.AddCommand(version.StartCmd)
|
||||
rootCmd.AddCommand(config.StartCmd)
|
||||
rootCmd.AddCommand(app.StartCmd)
|
||||
}
|
||||
|
||||
//Execute : apply commands
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -33,14 +33,14 @@ func CreateAction(control dto.Control) gin.HandlerFunc {
|
||||
var object models.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
response.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
response.Error(c, 500, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
object.SetCreateBy(user.GetUserId(c))
|
||||
err = db.WithContext(c).Create(object).Error
|
||||
if err != nil {
|
||||
log.Errorf("Create error: %s", err)
|
||||
response.Error(c, http.StatusInternalServerError, err, "创建失败")
|
||||
response.Error(c, 500, err, "创建失败")
|
||||
return
|
||||
}
|
||||
response.OK(c, object.GetId(), "创建成功")
|
||||
|
||||
@@ -34,7 +34,7 @@ func DeleteAction(control dto.Control) gin.HandlerFunc {
|
||||
var object models.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
response.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
response.Error(c, 500, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func DeleteAction(control dto.Control) gin.HandlerFunc {
|
||||
).Where(req.GetId()).Delete(object)
|
||||
if db.Error != nil {
|
||||
log.Errorf("MsgID[%s] Delete error: %s", msgID, err)
|
||||
response.Error(c, http.StatusInternalServerError, err, "删除失败")
|
||||
response.Error(c, 500, err, "删除失败")
|
||||
return
|
||||
}
|
||||
if db.RowsAffected == 0 {
|
||||
|
||||
@@ -49,7 +49,7 @@ func IndexAction(m models.ActiveRecord, d dto.Index, f func() interface{}) gin.H
|
||||
Count(&count).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
log.Errorf("MsgID[%s] Index error: %s", msgID, err)
|
||||
response.Error(c, http.StatusInternalServerError, err, "查询失败")
|
||||
response.Error(c, 500, err, "查询失败")
|
||||
return
|
||||
}
|
||||
response.PageOK(c, list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||
|
||||
@@ -2,7 +2,6 @@ package actions
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/go-admin-team/go-admin-core/logger"
|
||||
@@ -34,7 +33,7 @@ func PermissionAction() gin.HandlerFunc {
|
||||
p, err = newDataPermission(db, userId)
|
||||
if err != nil {
|
||||
log.Errorf("MsgID[%s] PermissionAction error: %s", msgID, err)
|
||||
response.Error(c, http.StatusInternalServerError, err, "权限范围鉴定错误")
|
||||
response.Error(c, 500, err, "权限范围鉴定错误")
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func UpdateAction(control dto.Control) gin.HandlerFunc {
|
||||
var object models.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
response.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
response.Error(c, 500, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
object.SetUpdateBy(user.GetUserId(c))
|
||||
@@ -46,7 +46,7 @@ func UpdateAction(control dto.Control) gin.HandlerFunc {
|
||||
).Where(req.GetId()).Updates(object)
|
||||
if db.Error != nil {
|
||||
log.Errorf("MsgID[%s] Update error: %s", msgID, err)
|
||||
response.Error(c, http.StatusInternalServerError, err, "更新失败")
|
||||
response.Error(c, 500, err, "更新失败")
|
||||
return
|
||||
}
|
||||
if db.RowsAffected == 0 {
|
||||
|
||||
@@ -34,7 +34,7 @@ func ViewAction(control dto.Control, f func() interface{}) gin.HandlerFunc {
|
||||
var object models.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
response.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
response.Error(c, 500, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func ViewAction(control dto.Control, f func() interface{}) gin.HandlerFunc {
|
||||
}
|
||||
if err != nil {
|
||||
log.Errorf("MsgID[%s] View error: %s", msgID, err)
|
||||
response.Error(c, http.StatusInternalServerError, err, "查看失败")
|
||||
response.Error(c, 500, err, "查看失败")
|
||||
return
|
||||
}
|
||||
response.OK(c, rsp, "查询成功")
|
||||
|
||||
+3
-4
@@ -3,7 +3,6 @@ package apis
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
@@ -85,7 +84,7 @@ func (e *Api) Bind(d interface{}, bindings ...binding.Binding) *Api {
|
||||
func (e Api) GetOrm() (*gorm.DB, error) {
|
||||
db, err := pkg.GetOrm(e.Context)
|
||||
if err != nil {
|
||||
e.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Error(500, err, "数据库连接获取失败")
|
||||
return nil, err
|
||||
}
|
||||
return db, nil
|
||||
@@ -96,13 +95,13 @@ func (e *Api) MakeOrm() *Api {
|
||||
var err error
|
||||
if e.Logger == nil {
|
||||
err = errors.New("at MakeOrm logger is nil")
|
||||
//e.Logger.Error(http.StatusInternalServerError, err, "at MakeOrm logger is nil")
|
||||
//e.Logger.Error(500, err, "at MakeOrm logger is nil")
|
||||
e.AddError(err)
|
||||
return e
|
||||
}
|
||||
db, err := pkg.GetOrm(e.Context)
|
||||
if err != nil {
|
||||
e.Logger.Error(http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
e.Logger.Error(500, err, "数据库连接获取失败")
|
||||
e.AddError(err)
|
||||
}
|
||||
e.Orm = db
|
||||
|
||||
@@ -51,3 +51,56 @@ func (s *ObjectById) GetId() interface{} {
|
||||
}
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type ObjectGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *ObjectGetReq) Bind(ctx *gin.Context) error {
|
||||
var err error
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err = ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Warnf("ShouldBindUri error: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
if err = vd.Validate(s); err != nil {
|
||||
log.Errorf("Validate error: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *ObjectGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type ObjectDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
}
|
||||
|
||||
func (s *ObjectDeleteReq) Bind(ctx *gin.Context) error {
|
||||
var err error
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err = ctx.ShouldBind(&s)
|
||||
if err != nil {
|
||||
log.Warnf("ShouldBind error: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
if len(s.Ids) > 0 {
|
||||
return nil
|
||||
}
|
||||
if s.Ids == nil {
|
||||
s.Ids = make([]int, 0)
|
||||
}
|
||||
|
||||
if err = vd.Validate(s); err != nil {
|
||||
log.Errorf("Validate error: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *ObjectDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package global
|
||||
|
||||
const (
|
||||
// Version go-admin version info
|
||||
Version = "2.0.0-beta.6"
|
||||
Version = "2.0.1"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
+2
-4
@@ -1,16 +1,15 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetClientIP(c *gin.Context) string {
|
||||
ClientIP := c.ClientIP()
|
||||
fmt.Println("ClientIP:", ClientIP)
|
||||
//fmt.Println("ClientIP:", ClientIP)
|
||||
RemoteIP, _ := c.RemoteIP()
|
||||
fmt.Println("RemoteIP:", RemoteIP)
|
||||
//fmt.Println("RemoteIP:", RemoteIP)
|
||||
ip := c.Request.Header.Get("X-Forwarded-For")
|
||||
if strings.Contains(ip, "127.0.0.1") || ip == "" {
|
||||
ip = c.Request.Header.Get("X-real-ip")
|
||||
@@ -24,6 +23,5 @@ func GetClientIP(c *gin.Context) string {
|
||||
if ClientIP != "127.0.0.1" {
|
||||
ip = ClientIP
|
||||
}
|
||||
fmt.Println("ip:", ip)
|
||||
return ip
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ func IdentityHandler(c *gin.Context) interface{} {
|
||||
// @Description Reply will be of the form {"token": "TOKEN"}.
|
||||
// @Description dev mode:It should be noted that all fields cannot be empty, and a value of 0 can be passed in addition to the account password
|
||||
// @Description 注意:开发模式:需要注意全部字段不能为空,账号密码外可以传入0值
|
||||
// @Tags 登陆
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param account body Login true "account"
|
||||
@@ -67,7 +68,7 @@ func Authenticator(c *gin.Context) (interface{}, error) {
|
||||
db, err := pkg.GetOrm(c)
|
||||
if err != nil {
|
||||
log.Errorf("get db error, %s", err.Error())
|
||||
response.Error(c, http.StatusInternalServerError, err, "数据库连接获取失败")
|
||||
response.Error(c, 500, err, "数据库连接获取失败")
|
||||
return nil, jwt.ErrFailedAuthentication
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const (
|
||||
_ uint8 = iota
|
||||
json
|
||||
xml
|
||||
yaml
|
||||
form
|
||||
query
|
||||
)
|
||||
|
||||
var constructor = &bindConstructor{}
|
||||
|
||||
type bindConstructor struct {
|
||||
cache map[string][]uint8
|
||||
mux sync.Mutex
|
||||
}
|
||||
|
||||
func (e *bindConstructor) GetBindingForGin(d interface{}) []binding.Binding {
|
||||
bs := e.getBinding(reflect.TypeOf(d).String())
|
||||
if bs == nil {
|
||||
//重新构建
|
||||
bs = e.resolve(d)
|
||||
}
|
||||
gbs := make([]binding.Binding, len(bs))
|
||||
for i, b := range bs {
|
||||
switch b {
|
||||
case json:
|
||||
gbs[i] = binding.JSON
|
||||
case xml:
|
||||
gbs[i] = binding.XML
|
||||
case yaml:
|
||||
gbs[i] = binding.YAML
|
||||
case form:
|
||||
gbs[i] = binding.Form
|
||||
case query:
|
||||
gbs[i] = binding.Query
|
||||
default:
|
||||
gbs[i] = nil
|
||||
}
|
||||
}
|
||||
return gbs
|
||||
}
|
||||
|
||||
func (e *bindConstructor) resolve(d interface{}) []uint8 {
|
||||
bs := make([]uint8, 0)
|
||||
qType := reflect.TypeOf(d).Elem()
|
||||
var tag reflect.StructTag
|
||||
var ok bool
|
||||
fmt.Println(qType.Kind())
|
||||
for i := 0; i < qType.NumField(); i++ {
|
||||
tag = qType.Field(i).Tag
|
||||
if _, ok = tag.Lookup("json"); ok {
|
||||
bs = append(bs, json)
|
||||
}
|
||||
if _, ok = tag.Lookup("xml"); ok {
|
||||
bs = append(bs, xml)
|
||||
}
|
||||
if _, ok = tag.Lookup("yaml"); ok {
|
||||
bs = append(bs, yaml)
|
||||
}
|
||||
if _, ok = tag.Lookup("form"); ok {
|
||||
bs = append(bs, form)
|
||||
}
|
||||
if _, ok = tag.Lookup("query"); ok {
|
||||
bs = append(bs, query)
|
||||
}
|
||||
if _, ok = tag.Lookup("uri"); ok {
|
||||
bs = append(bs, 0)
|
||||
}
|
||||
if t, ok := tag.Lookup("binding"); ok && strings.Index(t, "dive") > -1 {
|
||||
qValue := reflect.ValueOf(d)
|
||||
bs = append(bs, e.resolve(qValue.Field(i))...)
|
||||
continue
|
||||
}
|
||||
if t, ok := tag.Lookup("validate"); ok && strings.Index(t, "dive") > -1 {
|
||||
qValue := reflect.ValueOf(d)
|
||||
bs = append(bs, e.resolve(qValue.Field(i))...)
|
||||
}
|
||||
}
|
||||
return bs
|
||||
}
|
||||
|
||||
func (e *bindConstructor) getBinding(name string) []uint8 {
|
||||
e.mux.Lock()
|
||||
defer e.mux.Unlock()
|
||||
return e.cache[name]
|
||||
}
|
||||
|
||||
func (e *bindConstructor) setBinding(name string, bs []uint8) {
|
||||
e.mux.Lock()
|
||||
defer e.mux.Unlock()
|
||||
if e.cache == nil {
|
||||
e.cache = make(map[string][]uint8)
|
||||
}
|
||||
e.cache[name] = bs
|
||||
}
|
||||
+7
-11
@@ -192,10 +192,6 @@ INSERT INTO `sys_dict_type` VALUES (10, '通知状态', 'sys_notice_status', '2'
|
||||
INSERT INTO `sys_dict_type` VALUES (11, '内容状态', 'sys_content_status', '2', '', 1, 1, '2021-05-13 19:56:40.813', '2021-05-13 19:56:40.813', NULL);
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO `sys_file_dir` VALUES (1, '根目录', 0, 0, '', 1, 1, '2021-05-13 19:56:39.773', '2021-05-13 19:56:39.773', NULL);
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO `sys_job` VALUES (1, '接口测试', 'DEFAULT', 1, '0/5 * * * * ', 'http://localhost:8000', '', 1, 1, 1, 0, '2021-05-13 19:56:37.914', '2021-06-14 20:59:55.417', NULL, 1, 1);
|
||||
INSERT INTO `sys_job` VALUES (2, '函数测试', 'DEFAULT', 2, '0/5 * * * * ', 'ExamplesOne', '参数', 1, 1, 1, 0, '2021-05-13 19:56:37.914', '2021-05-31 23:55:37.221', NULL, 1, 1);
|
||||
@@ -203,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);
|
||||
@@ -358,13 +354,13 @@ INSERT INTO `sys_menu_api_rule` VALUES (45, 142);
|
||||
INSERT INTO `sys_menu_api_rule` VALUES (43, 150);
|
||||
INSERT INTO `sys_menu_api_rule` VALUES (45, 151);
|
||||
INSERT INTO `sys_menu_api_rule` VALUES (46, 156);
|
||||
INSERT INTO `sys_post` VALUES (1, '首席执行官', 'CEO', 0, '2', '首席执行官', '2021-05-13 19:56:37.913', '2021-05-13 19:56:37.913', NULL, 1, 1);
|
||||
INSERT INTO `sys_post` VALUES (2, '首席技术执行官', 'CTO', 2, '2', '首席技术执行官', '2021-05-13 19:56:37.913', '2021-05-13 19:56:37.913', NULL, 1, 1);
|
||||
INSERT INTO `sys_post` VALUES (3, '首席运营官', 'COO', 3, '2', '测试工程师', '2021-05-13 19:56:37.913', '2021-05-13 19:56:37.913', NULL, 1, 1);
|
||||
INSERT INTO `sys_role` VALUES (1, '系统管理员', '2', 'admin', 1, '', '', 1, '', '2021-05-13 19:56:37.913', '2021-05-13 19:56:37.913', NULL, 1, 1);
|
||||
INSERT INTO `sys_user` VALUES (1, 1, '2021-05-13 19:56:37.914', '2021-05-13 19:56:40.205', NULL, 1, 'admin', '$2a$10$/Glr4g9Svr6O0kvjsRJCXu3f0W8/dsP3XZyVNi1019ratWpSPMyw.', 'zhangwj', '13818888888', 1, '', '', '1', '1@qq.com', 1, 1, '', '2');
|
||||
INSERT INTO `sys_post` VALUES (1, '首席执行官', 'CEO', 0, '2','首席执行官', 1, 1, '2021-05-13 19:56:37.913', '2021-05-13 19:56:37.913', NULL);
|
||||
INSERT INTO `sys_post` VALUES (2, '首席技术执行官', 'CTO', 2, '2','首席技术执行官', 1, 1,'2021-05-13 19:56:37.913', '2021-05-13 19:56:37.913', NULL);
|
||||
INSERT INTO `sys_post` VALUES (3, '首席运营官', 'COO', 3, '2','测试工程师', 1, 1,'2021-05-13 19:56:37.913', '2021-05-13 19:56:37.913', NULL);
|
||||
INSERT INTO `sys_role` VALUES (1, '系统管理员', '2', 'admin', 1, '', '', 1, '', 1, 1, '2021-05-13 19:56:37.913', '2021-05-13 19:56:37.913', NULL);
|
||||
INSERT INTO `sys_user` VALUES (1, 'admin', '$2a$10$/Glr4g9Svr6O0kvjsRJCXu3f0W8/dsP3XZyVNi1019ratWpSPMyw.', 'zhangwj', '13818888888', 1, '', '', '1', '1@qq.com', 1, 1, '', '2', 1, 1, '2021-05-13 19:56:37.914', '2021-05-13 19:56:40.205', NULL);
|
||||
COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
-- 数据完成 ;
|
||||
-- 数据完成 ;
|
||||
|
||||
@@ -28,7 +28,7 @@ settings:
|
||||
stdout: '' #控制台日志,启用后,不输出到文件
|
||||
# 日志等级, trace, debug, info, warn, error, fatal
|
||||
level: trace
|
||||
# 数据库日志开关 dev模式,将自动开启
|
||||
# 数据库日志开关
|
||||
enableddb: false
|
||||
jwt:
|
||||
# token 密钥,生产环境时及的修改
|
||||
|
||||
@@ -19,7 +19,7 @@ settings:
|
||||
stdout: '' #控制台日志,启用后,不输出到文件
|
||||
# 日志等级, trace, debug, info, warn, error, fatal
|
||||
level: trace
|
||||
# 数据库日志开关 dev模式,将自动开启
|
||||
# 数据库日志开关
|
||||
enableddb: false
|
||||
jwt:
|
||||
# token 密钥,生产环境时及的修改
|
||||
|
||||
+8
-6
@@ -19,7 +19,7 @@ settings:
|
||||
stdout: '' #控制台日志,启用后,不输出到文件
|
||||
# 日志等级, trace, debug, info, warn, error, fatal
|
||||
level: trace
|
||||
# 数据库日志开关 dev模式,将自动开启
|
||||
# 数据库日志开关
|
||||
enableddb: false
|
||||
jwt:
|
||||
# token 密钥,生产环境时及的修改
|
||||
@@ -48,10 +48,12 @@ settings:
|
||||
demo:
|
||||
name: data
|
||||
cache:
|
||||
redis:
|
||||
addr: 127.0.0.1:6379
|
||||
password: xxxxxx
|
||||
db: 2
|
||||
# redis:
|
||||
# addr: 127.0.0.1:6379
|
||||
# password: xxxxxx
|
||||
# db: 2
|
||||
# key存在即可
|
||||
memory: ''
|
||||
queue:
|
||||
memory:
|
||||
poolSize: 100
|
||||
@@ -68,4 +70,4 @@ settings:
|
||||
# blockingTimeout: 5
|
||||
# reclaimInterval: 1
|
||||
locker:
|
||||
redis:
|
||||
redis:
|
||||
|
||||
+262
-115
@@ -30,16 +30,11 @@ var doc = `{
|
||||
"paths": {
|
||||
"/api/v1/app-config": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取系统配置信息,主要注意这里不在验证数据权限",
|
||||
"description": "获取系统配置信息,主要注意这里不在验证权限",
|
||||
"tags": [
|
||||
"配置管理"
|
||||
],
|
||||
"summary": "获取系统前台配置信息,主要注意这里不在验证数据权限",
|
||||
"summary": "获取系统前台配置信息,主要注意这里不在验证权限",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
@@ -65,11 +60,46 @@ var doc = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/captcha": {
|
||||
"get": {
|
||||
"description": "获取验证码",
|
||||
"tags": [
|
||||
"登陆"
|
||||
],
|
||||
"summary": "获取验证码",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/response.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/db/columns/page": {
|
||||
"get": {
|
||||
"description": "数据库表列分页列表 / database table column page list",
|
||||
"tags": [
|
||||
"工具 / Tools"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "分页列表数据 / page list data",
|
||||
"parameters": [
|
||||
@@ -106,7 +136,7 @@ var doc = `{
|
||||
"get": {
|
||||
"description": "数据库表分页列表 / database table page list",
|
||||
"tags": [
|
||||
"工具 / Tools"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "分页列表数据 / page list data",
|
||||
"parameters": [
|
||||
@@ -215,6 +245,11 @@ var doc = `{
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "删除数据",
|
||||
"tags": [
|
||||
"部门"
|
||||
@@ -621,6 +656,11 @@ var doc = `{
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "删除数据",
|
||||
"tags": [
|
||||
"字典类型"
|
||||
@@ -780,6 +820,9 @@ var doc = `{
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"登陆"
|
||||
],
|
||||
"summary": "登陆",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -872,6 +915,11 @@ var doc = `{
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "删除数据",
|
||||
"tags": [
|
||||
"菜单"
|
||||
@@ -1093,7 +1141,7 @@ var doc = `{
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.SysPostControl"
|
||||
"$ref": "#/definitions/dto.SysPostInsertReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -1107,6 +1155,11 @@ var doc = `{
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "删除数据",
|
||||
"tags": [
|
||||
"岗位"
|
||||
@@ -1114,11 +1167,13 @@ var doc = `{
|
||||
"summary": "删除岗位",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "id",
|
||||
"description": "请求参数",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.SysPostDeleteReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -1137,7 +1192,7 @@ var doc = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/post/": {
|
||||
"/api/v1/post/{id}": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
@@ -1159,7 +1214,7 @@ var doc = `{
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.SysPostControl"
|
||||
"$ref": "#/definitions/dto.SysPostUpdateReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -1188,8 +1243,8 @@ var doc = `{
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "postId",
|
||||
"name": "postId",
|
||||
"description": "编码",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
@@ -1206,6 +1261,11 @@ var doc = `{
|
||||
},
|
||||
"/api/v1/public/uploadFile": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
@@ -1461,6 +1521,11 @@ var doc = `{
|
||||
},
|
||||
"/api/v1/server-monitor": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"tags": [
|
||||
"系统信息"
|
||||
@@ -2037,6 +2102,11 @@ var doc = `{
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "登录日志删除",
|
||||
"tags": [
|
||||
"登录日志"
|
||||
@@ -2165,6 +2235,11 @@ var doc = `{
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "删除数据",
|
||||
"tags": [
|
||||
"操作日志"
|
||||
@@ -2249,10 +2324,78 @@ var doc = `{
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户"
|
||||
],
|
||||
"summary": "创建用户",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "用户数据",
|
||||
"name": "data",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.SysUserControl"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/sys-user/{userId}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"tags": [
|
||||
"用户"
|
||||
],
|
||||
"summary": "获取用户",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "用户编码",
|
||||
"name": "userId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
@@ -2282,6 +2425,11 @@ var doc = `{
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "删除数据",
|
||||
"tags": [
|
||||
"用户"
|
||||
@@ -2318,7 +2466,7 @@ var doc = `{
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"工具 - 生成表"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "修改表结构",
|
||||
"parameters": [
|
||||
@@ -2352,7 +2500,7 @@ var doc = `{
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"工具 - 生成表"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "添加表结构",
|
||||
"parameters": [
|
||||
@@ -2382,7 +2530,7 @@ var doc = `{
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"tags": [
|
||||
"工具 - 生成表"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "获取配置",
|
||||
"parameters": [
|
||||
@@ -2406,7 +2554,7 @@ var doc = `{
|
||||
"delete": {
|
||||
"description": "删除表结构",
|
||||
"tags": [
|
||||
"工具 - 生成表"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "删除表结构",
|
||||
"parameters": [
|
||||
@@ -2432,7 +2580,7 @@ var doc = `{
|
||||
"get": {
|
||||
"description": "生成表分页列表",
|
||||
"tags": [
|
||||
"工具 - 生成表"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "分页列表数据",
|
||||
"parameters": [
|
||||
@@ -2465,70 +2613,13 @@ var doc = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/sysUser": {
|
||||
"/api/v1/user/avatar": {
|
||||
"post": {
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户"
|
||||
],
|
||||
"summary": "创建用户",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "用户数据",
|
||||
"name": "data",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.SysUserControl"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/sysUser/{userId}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"tags": [
|
||||
"用户"
|
||||
],
|
||||
"summary": "获取用户",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "用户编码",
|
||||
"name": "userId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/user/avatar": {
|
||||
"post": {
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
@@ -2578,8 +2669,44 @@ var doc = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/user/pwd": {
|
||||
"post": {
|
||||
"/api/v1/user/pwd/reset": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户"
|
||||
],
|
||||
"summary": "重置用户密码",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "body",
|
||||
"name": "data",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ResetSysUserPwdReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/user/pwd/set": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
@@ -2614,39 +2741,13 @@ var doc = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/user/pwd/reset": {
|
||||
"put": {
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户"
|
||||
],
|
||||
"summary": "重置用户密码",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "body",
|
||||
"name": "data",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ResetSysUserPwdReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/user/status": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
@@ -3132,7 +3233,53 @@ var doc = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.SysPostControl": {
|
||||
"dto.SysPostDeleteReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createBy": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ids": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"updateBy": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.SysPostInsertReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createBy": {
|
||||
"type": "integer"
|
||||
},
|
||||
"postCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"postId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"postName": {
|
||||
"type": "string"
|
||||
},
|
||||
"remark": {
|
||||
"type": "string"
|
||||
},
|
||||
"sort": {
|
||||
"type": "integer"
|
||||
},
|
||||
"status": {
|
||||
"type": "integer"
|
||||
},
|
||||
"updateBy": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.SysPostUpdateReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createBy": {
|
||||
|
||||
+262
-115
@@ -13,16 +13,11 @@
|
||||
"paths": {
|
||||
"/api/v1/app-config": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取系统配置信息,主要注意这里不在验证数据权限",
|
||||
"description": "获取系统配置信息,主要注意这里不在验证权限",
|
||||
"tags": [
|
||||
"配置管理"
|
||||
],
|
||||
"summary": "获取系统前台配置信息,主要注意这里不在验证数据权限",
|
||||
"summary": "获取系统前台配置信息,主要注意这里不在验证权限",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
@@ -48,11 +43,46 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/captcha": {
|
||||
"get": {
|
||||
"description": "获取验证码",
|
||||
"tags": [
|
||||
"登陆"
|
||||
],
|
||||
"summary": "获取验证码",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/response.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/db/columns/page": {
|
||||
"get": {
|
||||
"description": "数据库表列分页列表 / database table column page list",
|
||||
"tags": [
|
||||
"工具 / Tools"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "分页列表数据 / page list data",
|
||||
"parameters": [
|
||||
@@ -89,7 +119,7 @@
|
||||
"get": {
|
||||
"description": "数据库表分页列表 / database table page list",
|
||||
"tags": [
|
||||
"工具 / Tools"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "分页列表数据 / page list data",
|
||||
"parameters": [
|
||||
@@ -198,6 +228,11 @@
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "删除数据",
|
||||
"tags": [
|
||||
"部门"
|
||||
@@ -604,6 +639,11 @@
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "删除数据",
|
||||
"tags": [
|
||||
"字典类型"
|
||||
@@ -763,6 +803,9 @@
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"登陆"
|
||||
],
|
||||
"summary": "登陆",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -855,6 +898,11 @@
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "删除数据",
|
||||
"tags": [
|
||||
"菜单"
|
||||
@@ -1076,7 +1124,7 @@
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.SysPostControl"
|
||||
"$ref": "#/definitions/dto.SysPostInsertReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -1090,6 +1138,11 @@
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "删除数据",
|
||||
"tags": [
|
||||
"岗位"
|
||||
@@ -1097,11 +1150,13 @@
|
||||
"summary": "删除岗位",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "id",
|
||||
"description": "请求参数",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.SysPostDeleteReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -1120,7 +1175,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/post/": {
|
||||
"/api/v1/post/{id}": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
@@ -1142,7 +1197,7 @@
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.SysPostControl"
|
||||
"$ref": "#/definitions/dto.SysPostUpdateReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -1171,8 +1226,8 @@
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "postId",
|
||||
"name": "postId",
|
||||
"description": "编码",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
@@ -1189,6 +1244,11 @@
|
||||
},
|
||||
"/api/v1/public/uploadFile": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
@@ -1444,6 +1504,11 @@
|
||||
},
|
||||
"/api/v1/server-monitor": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"tags": [
|
||||
"系统信息"
|
||||
@@ -2020,6 +2085,11 @@
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "登录日志删除",
|
||||
"tags": [
|
||||
"登录日志"
|
||||
@@ -2148,6 +2218,11 @@
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "删除数据",
|
||||
"tags": [
|
||||
"操作日志"
|
||||
@@ -2232,10 +2307,78 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户"
|
||||
],
|
||||
"summary": "创建用户",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "用户数据",
|
||||
"name": "data",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.SysUserControl"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/sys-user/{userId}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"tags": [
|
||||
"用户"
|
||||
],
|
||||
"summary": "获取用户",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "用户编码",
|
||||
"name": "userId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
@@ -2265,6 +2408,11 @@
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "删除数据",
|
||||
"tags": [
|
||||
"用户"
|
||||
@@ -2301,7 +2449,7 @@
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"工具 - 生成表"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "修改表结构",
|
||||
"parameters": [
|
||||
@@ -2335,7 +2483,7 @@
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"工具 - 生成表"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "添加表结构",
|
||||
"parameters": [
|
||||
@@ -2365,7 +2513,7 @@
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"tags": [
|
||||
"工具 - 生成表"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "获取配置",
|
||||
"parameters": [
|
||||
@@ -2389,7 +2537,7 @@
|
||||
"delete": {
|
||||
"description": "删除表结构",
|
||||
"tags": [
|
||||
"工具 - 生成表"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "删除表结构",
|
||||
"parameters": [
|
||||
@@ -2415,7 +2563,7 @@
|
||||
"get": {
|
||||
"description": "生成表分页列表",
|
||||
"tags": [
|
||||
"工具 - 生成表"
|
||||
"工具 / 生成工具"
|
||||
],
|
||||
"summary": "分页列表数据",
|
||||
"parameters": [
|
||||
@@ -2448,70 +2596,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/sysUser": {
|
||||
"/api/v1/user/avatar": {
|
||||
"post": {
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户"
|
||||
],
|
||||
"summary": "创建用户",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "用户数据",
|
||||
"name": "data",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.SysUserControl"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/sysUser/{userId}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"tags": [
|
||||
"用户"
|
||||
],
|
||||
"summary": "获取用户",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "用户编码",
|
||||
"name": "userId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/user/avatar": {
|
||||
"post": {
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
@@ -2561,8 +2652,44 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/user/pwd": {
|
||||
"post": {
|
||||
"/api/v1/user/pwd/reset": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户"
|
||||
],
|
||||
"summary": "重置用户密码",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "body",
|
||||
"name": "data",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ResetSysUserPwdReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/user/pwd/set": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
@@ -2597,39 +2724,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/user/pwd/reset": {
|
||||
"put": {
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户"
|
||||
],
|
||||
"summary": "重置用户密码",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "body",
|
||||
"name": "data",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ResetSysUserPwdReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{\"code\": 200, \"data\": [...]}",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/user/status": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "获取JSON",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
@@ -3115,7 +3216,53 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.SysPostControl": {
|
||||
"dto.SysPostDeleteReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createBy": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ids": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"updateBy": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.SysPostInsertReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createBy": {
|
||||
"type": "integer"
|
||||
},
|
||||
"postCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"postId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"postName": {
|
||||
"type": "string"
|
||||
},
|
||||
"remark": {
|
||||
"type": "string"
|
||||
},
|
||||
"sort": {
|
||||
"type": "integer"
|
||||
},
|
||||
"status": {
|
||||
"type": "integer"
|
||||
},
|
||||
"updateBy": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.SysPostUpdateReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createBy": {
|
||||
|
||||
+158
-81
@@ -292,7 +292,37 @@ definitions:
|
||||
type: integer
|
||||
type: array
|
||||
type: object
|
||||
dto.SysPostControl:
|
||||
dto.SysPostDeleteReq:
|
||||
properties:
|
||||
createBy:
|
||||
type: integer
|
||||
ids:
|
||||
items:
|
||||
type: integer
|
||||
type: array
|
||||
updateBy:
|
||||
type: integer
|
||||
type: object
|
||||
dto.SysPostInsertReq:
|
||||
properties:
|
||||
createBy:
|
||||
type: integer
|
||||
postCode:
|
||||
type: string
|
||||
postId:
|
||||
type: integer
|
||||
postName:
|
||||
type: string
|
||||
remark:
|
||||
type: string
|
||||
sort:
|
||||
type: integer
|
||||
status:
|
||||
type: integer
|
||||
updateBy:
|
||||
type: integer
|
||||
type: object
|
||||
dto.SysPostUpdateReq:
|
||||
properties:
|
||||
createBy:
|
||||
type: integer
|
||||
@@ -822,7 +852,7 @@ info:
|
||||
paths:
|
||||
/api/v1/app-config:
|
||||
get:
|
||||
description: 获取系统配置信息,主要注意这里不在验证数据权限
|
||||
description: 获取系统配置信息,主要注意这里不在验证权限
|
||||
responses:
|
||||
"200":
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
@@ -835,11 +865,29 @@ paths:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 获取系统前台配置信息,主要注意这里不在验证数据权限
|
||||
summary: 获取系统前台配置信息,主要注意这里不在验证权限
|
||||
tags:
|
||||
- 配置管理
|
||||
/api/v1/captcha:
|
||||
get:
|
||||
description: 获取验证码
|
||||
responses:
|
||||
"200":
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.Response'
|
||||
- properties:
|
||||
data:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
msg:
|
||||
type: string
|
||||
type: object
|
||||
summary: 获取验证码
|
||||
tags:
|
||||
- 登陆
|
||||
/api/v1/db/columns/page:
|
||||
get:
|
||||
description: 数据库表列分页列表 / database table column page list
|
||||
@@ -863,7 +911,7 @@ paths:
|
||||
$ref: '#/definitions/response.Response'
|
||||
summary: 分页列表数据 / page list data
|
||||
tags:
|
||||
- 工具 / Tools
|
||||
- 工具 / 生成工具
|
||||
/api/v1/db/tables/page:
|
||||
get:
|
||||
description: 数据库表分页列表 / database table page list
|
||||
@@ -887,7 +935,7 @@ paths:
|
||||
$ref: '#/definitions/response.Response'
|
||||
summary: 分页列表数据 / page list data
|
||||
tags:
|
||||
- 工具 / Tools
|
||||
- 工具 / 生成工具
|
||||
/api/v1/dept:
|
||||
delete:
|
||||
description: 删除数据
|
||||
@@ -903,6 +951,8 @@ paths:
|
||||
description: '{"code": -1, "message": "删除失败"}'
|
||||
schema:
|
||||
type: string
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 删除部门
|
||||
tags:
|
||||
- 部门
|
||||
@@ -1147,6 +1197,8 @@ paths:
|
||||
description: '{"code": -1, "message": "删除失败"}'
|
||||
schema:
|
||||
type: string
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 删除字典类型
|
||||
tags:
|
||||
- 字典类型
|
||||
@@ -1309,6 +1361,8 @@ paths:
|
||||
schema:
|
||||
type: string
|
||||
summary: 登陆
|
||||
tags:
|
||||
- 登陆
|
||||
/api/v1/menu:
|
||||
delete:
|
||||
description: 删除数据
|
||||
@@ -1324,6 +1378,8 @@ paths:
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 删除菜单
|
||||
tags:
|
||||
- 菜单
|
||||
@@ -1451,11 +1507,12 @@ paths:
|
||||
delete:
|
||||
description: 删除数据
|
||||
parameters:
|
||||
- description: id
|
||||
in: path
|
||||
- description: 请求参数
|
||||
in: body
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
schema:
|
||||
$ref: '#/definitions/dto.SysPostDeleteReq'
|
||||
responses:
|
||||
"200":
|
||||
description: '{"code": 200, "message": "删除成功"}'
|
||||
@@ -1465,6 +1522,8 @@ paths:
|
||||
description: '{"code": 500, "message": "删除失败"}'
|
||||
schema:
|
||||
type: string
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 删除岗位
|
||||
tags:
|
||||
- 岗位
|
||||
@@ -1507,7 +1566,7 @@ paths:
|
||||
name: data
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.SysPostControl'
|
||||
$ref: '#/definitions/dto.SysPostInsertReq'
|
||||
responses:
|
||||
"200":
|
||||
description: '{"code": -1, "message": "添加失败"}'
|
||||
@@ -1518,7 +1577,7 @@ paths:
|
||||
summary: 添加岗位
|
||||
tags:
|
||||
- 岗位
|
||||
/api/v1/post/:
|
||||
/api/v1/post/{id}:
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
@@ -1529,7 +1588,7 @@ paths:
|
||||
name: data
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.SysPostControl'
|
||||
$ref: '#/definitions/dto.SysPostUpdateReq'
|
||||
responses:
|
||||
"200":
|
||||
description: '{"code": -1, "message": "添加失败"}'
|
||||
@@ -1544,9 +1603,9 @@ paths:
|
||||
get:
|
||||
description: 获取JSON
|
||||
parameters:
|
||||
- description: postId
|
||||
- description: 编码
|
||||
in: path
|
||||
name: postId
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
responses:
|
||||
@@ -1580,6 +1639,8 @@ paths:
|
||||
description: '{"code": -1, "message": "添加失败"}'
|
||||
schema:
|
||||
type: string
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 上传图片
|
||||
tags:
|
||||
- 公共接口
|
||||
@@ -1726,6 +1787,8 @@ paths:
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 系统信息
|
||||
tags:
|
||||
- 系统信息
|
||||
@@ -2037,6 +2100,8 @@ paths:
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 登录日志删除
|
||||
tags:
|
||||
- 登录日志
|
||||
@@ -2110,6 +2175,8 @@ paths:
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 删除操作日志
|
||||
tags:
|
||||
- 操作日志
|
||||
@@ -2194,6 +2261,27 @@ paths:
|
||||
summary: 列表用户信息数据
|
||||
tags:
|
||||
- 用户
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 获取JSON
|
||||
parameters:
|
||||
- description: 用户数据
|
||||
in: body
|
||||
name: data
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.SysUserControl'
|
||||
responses:
|
||||
"200":
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 创建用户
|
||||
tags:
|
||||
- 用户
|
||||
/api/v1/sys-user/{userId}:
|
||||
delete:
|
||||
description: 删除数据
|
||||
@@ -2208,9 +2296,29 @@ paths:
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 删除用户数据
|
||||
tags:
|
||||
- 用户
|
||||
get:
|
||||
description: 获取JSON
|
||||
parameters:
|
||||
- description: 用户编码
|
||||
in: path
|
||||
name: userId
|
||||
required: true
|
||||
type: integer
|
||||
responses:
|
||||
"200":
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 获取用户
|
||||
tags:
|
||||
- 用户
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
@@ -2227,6 +2335,8 @@ paths:
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 修改用户数据
|
||||
tags:
|
||||
- 用户
|
||||
@@ -2249,7 +2359,7 @@ paths:
|
||||
- Bearer: []
|
||||
summary: 添加表结构
|
||||
tags:
|
||||
- 工具 - 生成表
|
||||
- 工具 / 生成工具
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
@@ -2270,7 +2380,7 @@ paths:
|
||||
- Bearer: []
|
||||
summary: 修改表结构
|
||||
tags:
|
||||
- 工具 - 生成表
|
||||
- 工具 / 生成工具
|
||||
/api/v1/sys/tables/info/{tableId}:
|
||||
delete:
|
||||
description: 删除表结构
|
||||
@@ -2287,7 +2397,7 @@ paths:
|
||||
type: string
|
||||
summary: 删除表结构
|
||||
tags:
|
||||
- 工具 - 生成表
|
||||
- 工具 / 生成工具
|
||||
get:
|
||||
description: 获取JSON
|
||||
parameters:
|
||||
@@ -2305,7 +2415,7 @@ paths:
|
||||
- Bearer: []
|
||||
summary: 获取配置
|
||||
tags:
|
||||
- 工具 - 生成表
|
||||
- 工具 / 生成工具
|
||||
/api/v1/sys/tables/page:
|
||||
get:
|
||||
description: 生成表分页列表
|
||||
@@ -2329,46 +2439,7 @@ paths:
|
||||
$ref: '#/definitions/response.Response'
|
||||
summary: 分页列表数据
|
||||
tags:
|
||||
- 工具 - 生成表
|
||||
/api/v1/sysUser:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 获取JSON
|
||||
parameters:
|
||||
- description: 用户数据
|
||||
in: body
|
||||
name: data
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.SysUserControl'
|
||||
responses:
|
||||
"200":
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
summary: 创建用户
|
||||
tags:
|
||||
- 用户
|
||||
/api/v1/sysUser/{userId}:
|
||||
get:
|
||||
description: 获取JSON
|
||||
parameters:
|
||||
- description: 用户编码
|
||||
in: path
|
||||
name: userId
|
||||
required: true
|
||||
type: integer
|
||||
responses:
|
||||
"200":
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 获取用户
|
||||
tags:
|
||||
- 用户
|
||||
- 工具 / 生成工具
|
||||
/api/v1/user/avatar:
|
||||
post:
|
||||
consumes:
|
||||
@@ -2385,6 +2456,8 @@ paths:
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 修改头像
|
||||
tags:
|
||||
- 个人中心
|
||||
@@ -2401,8 +2474,30 @@ paths:
|
||||
summary: 获取个人中心用户
|
||||
tags:
|
||||
- 个人中心
|
||||
/api/v1/user/pwd:
|
||||
post:
|
||||
/api/v1/user/pwd/reset:
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 获取JSON
|
||||
parameters:
|
||||
- description: body
|
||||
in: body
|
||||
name: data
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.ResetSysUserPwdReq'
|
||||
responses:
|
||||
"200":
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 重置用户密码
|
||||
tags:
|
||||
- 用户
|
||||
/api/v1/user/pwd/set:
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 获取JSON
|
||||
@@ -2423,26 +2518,6 @@ paths:
|
||||
summary: 重置密码
|
||||
tags:
|
||||
- 用户
|
||||
/api/v1/user/pwd/reset:
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 获取JSON
|
||||
parameters:
|
||||
- description: body
|
||||
in: body
|
||||
name: data
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.ResetSysUserPwdReq'
|
||||
responses:
|
||||
"200":
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
summary: 重置用户密码
|
||||
tags:
|
||||
- 用户
|
||||
/api/v1/user/status:
|
||||
put:
|
||||
consumes:
|
||||
@@ -2460,6 +2535,8 @@ paths:
|
||||
description: '{"code": 200, "data": [...]}'
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: 修改用户状态
|
||||
tags:
|
||||
- 用户
|
||||
|
||||
@@ -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.20210619151458-e7f05c83652b
|
||||
github.com/go-admin-team/go-admin-core/sdk v1.3.5-rc.6.0.20210619151458-e7f05c83652b
|
||||
github.com/gin-gonic/gin v1.7.2
|
||||
github.com/go-admin-team/go-admin-core v1.3.7
|
||||
github.com/go-admin-team/go-admin-core/sdk v1.3.7
|
||||
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("/api/v1")
|
||||
|
||||
for _, f := range routerNoCheckRole {
|
||||
f(v)
|
||||
}
|
||||
}
|
||||
|
||||
// checkRoleRouter 需要认证的路由
|
||||
func checkRoleRouter(r *gin.Engine, authMiddleware *jwtauth.GinJWTMiddleware) {
|
||||
// 可根据业务需求来设置接口版本
|
||||
v := r.Group("/api/v1")
|
||||
|
||||
for _, f := range routerCheckRole {
|
||||
f(v, authMiddleware)
|
||||
}
|
||||
}
|
||||
+92
-86
@@ -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 -}}
|
||||
@@ -19,27 +29,60 @@ type {{.ClassName}}Search struct {
|
||||
{{.GoField}} {{.GoType}} `form:"{{.JsonField}}" search:"type:{{if eq .QueryType "EQ"}}exact{{ else if eq .QueryType "NE"}}iexact{{ else if eq .QueryType "LIKE"}}contains{{ else if eq .QueryType "GT"}}gt{{ else if eq .QueryType "GTE"}}gte{{ else if eq .QueryType "LT"}}lt{{ else if eq .QueryType "LTE"}}lte{{- end }};column:{{.ColumnName}};table:{{$tablename}}" comment:"{{.ColumnComment}}"`
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{.ClassName}}Order
|
||||
}
|
||||
|
||||
func (m *{{.ClassName}}Search) GetNeedSearch() interface{} {
|
||||
type {{.ClassName}}Order struct {
|
||||
{{- $tablename := .TBName -}}
|
||||
{{- range .Columns -}}
|
||||
{{.GoField}} {{.GoType}} `form:"{{.JsonField}}Order" search:"type:order;column:{{.ColumnName}};table:{{$tablename}}"`
|
||||
{{ end }}
|
||||
}
|
||||
|
||||
func (m *{{.ClassName}}GetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
func (m *{{.ClassName}}Search) Generate() dto.Index {
|
||||
o := *m
|
||||
return &o
|
||||
type {{.ClassName}}InsertReq struct {
|
||||
{{- range .Columns -}}
|
||||
{{$x := .Pk}}
|
||||
{{- if ($x) }}
|
||||
{{.GoField}} {{.GoType}} `json:"-" 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 (m *{{.ClassName}}Search) Bind(ctx *gin.Context) error {
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBind(m)
|
||||
if err != nil {
|
||||
log.Errorf("ShouldBind error: %s", err.Error())
|
||||
func (s *{{.ClassName}}InsertReq) Generate(model *models.{{.ClassName}}) {
|
||||
{{- range .Columns -}}
|
||||
{{$x := .Pk}}
|
||||
{{- if ($x) }}
|
||||
if s.{{.GoField}} == 0 {
|
||||
model.Model = common.Model{ {{.GoField}}: s.{{.GoField}} }
|
||||
}
|
||||
return err
|
||||
{{- 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 }}
|
||||
}
|
||||
|
||||
type {{.ClassName}}Control struct {
|
||||
func (s *{{.ClassName}}InsertReq) GetId() interface{} {
|
||||
return s.{{.PkGoField}}
|
||||
}
|
||||
|
||||
type {{.ClassName}}UpdateReq struct {
|
||||
{{- range .Columns -}}
|
||||
{{$x := .Pk}}
|
||||
{{- if ($x) }}
|
||||
@@ -53,86 +96,49 @@ type {{.ClassName}}Control struct {
|
||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}Control) Generate() dto.Control {
|
||||
o := *s
|
||||
return &o
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}Control) Bind(ctx *gin.Context) error {
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Errorf("ShouldBindUri error: %s", err.Error())
|
||||
return errors.New("数据绑定出错")
|
||||
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}} }
|
||||
}
|
||||
err = ctx.ShouldBind(s)
|
||||
if err != nil {
|
||||
log.Errorf("ShouldBind error: %s", err.Error())
|
||||
err = errors.New("数据绑定出错")
|
||||
}
|
||||
return err
|
||||
{{- 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}}Control) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.{{.ClassName}}{
|
||||
{{- range .Columns -}}
|
||||
{{$x := .Pk}}
|
||||
{{- if ($x) }}
|
||||
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 }}
|
||||
{{.GoField}}: s.{{.GoField}},
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}Control) GetId() interface{} {
|
||||
func (s *{{.ClassName}}UpdateReq) GetId() interface{} {
|
||||
return s.{{.PkGoField}}
|
||||
}
|
||||
|
||||
type {{.ClassName}}ById struct {
|
||||
dto.ObjectById
|
||||
// {{.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}}
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}ById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
// {{.ClassName}}DeleteReq 功能删除请求参数
|
||||
type {{.ClassName}}DeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}ById) Bind(ctx *gin.Context) error {
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Errorf("ShouldBindUri error: %s", err.Error())
|
||||
return errors.New("数据绑定出错")
|
||||
}
|
||||
err = ctx.ShouldBind(s)
|
||||
if err != nil {
|
||||
log.Errorf("ShouldBind error: %s", err.Error())
|
||||
err = errors.New("数据绑定出错")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}ById) SetUpdateBy(id int) {
|
||||
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}ById) Generate() dto.Control {
|
||||
o := *s
|
||||
return &o
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}ById) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.{{.ClassName}}{}, nil
|
||||
func (s *{{.ClassName}}DeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package apis
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
@@ -18,7 +18,7 @@ type {{.ClassName}} struct {
|
||||
api.Api
|
||||
}
|
||||
|
||||
// Get{{.ClassName}}List 获取{{.TableComment}}列表
|
||||
// GetPage 获取{{.TableComment}}列表
|
||||
// @Summary 获取{{.TableComment}}列表
|
||||
// @Description 获取{{.TableComment}}列表
|
||||
// @Tags {{.TableComment}}
|
||||
@@ -34,43 +34,34 @@ type {{.ClassName}} struct {
|
||||
// @Success 200 {object} response.Response{data=response.Page{list=[]models.{{.ClassName}}}} "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/{{.ModuleName}} [get]
|
||||
// @Security Bearer
|
||||
func (e {{.ClassName}}) Get{{.ClassName}}List(c *gin.Context) {
|
||||
e.SetContext(c)
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
func (e {{.ClassName}}) GetPage(c *gin.Context) {
|
||||
req := dto.{{.ClassName}}GetPageReq{}
|
||||
s := service.{{.ClassName}}{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
d := new(dto.{{.ClassName}}Search)
|
||||
//查询列表
|
||||
err = d.Bind(c)
|
||||
if err != nil {
|
||||
log.Warnf("request body bind error, %s", err.Error())
|
||||
e.Error( http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
//数据权限检查
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
list := make([]models.{{.ClassName}}, 0)
|
||||
var count int64
|
||||
service{{.ClassName}} := service.{{.ClassName}}{}
|
||||
service{{.ClassName}}.Log = log
|
||||
service{{.ClassName}}.Orm = db
|
||||
err = service{{.ClassName}}.Get{{.ClassName}}Page(d, p, &list, &count)
|
||||
|
||||
err = s.GetPage(&req, p, &list, &count)
|
||||
if err != nil {
|
||||
log.Errorf("Get {{.ClassName}} Page error, %s", err.Error())
|
||||
e.Error( http.StatusInternalServerError, err, "查询失败")
|
||||
return
|
||||
e.Error(500, err, fmt.Sprintf("获取{{.TableComment}} 失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
e.PageOK( list, int(count), d.GetPageIndex(), d.GetPageSize(), "查询成功")
|
||||
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
// Get{{.ClassName}} 获取{{.TableComment}}
|
||||
// Get 获取{{.TableComment}}
|
||||
// @Summary 获取{{.TableComment}}
|
||||
// @Description 获取{{.TableComment}}
|
||||
// @Tags {{.TableComment}}
|
||||
@@ -78,144 +69,101 @@ func (e {{.ClassName}}) Get{{.ClassName}}List(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) {
|
||||
e.SetContext(c)
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
func (e {{.ClassName}}) Get(c *gin.Context) {
|
||||
req := dto.{{.ClassName}}GetReq{}
|
||||
s := service.{{.ClassName}}{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
control := new(dto.{{.ClassName}}ById)
|
||||
|
||||
//查看详情
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
log.Warnf("request body bind error, %s", err.Error())
|
||||
e.Error( http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
var object models.{{.ClassName}}
|
||||
|
||||
//数据权限检查
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
service{{.ClassName}} := service.{{.ClassName}}{}
|
||||
service{{.ClassName}}.Log = log
|
||||
service{{.ClassName}}.Orm = db
|
||||
err = service{{.ClassName}}.Get{{.ClassName}}(control, p, &object)
|
||||
err = s.Get(&req, p, &object)
|
||||
if err != nil {
|
||||
log.Errorf("Get {{.ClassName}} error, %s", err.Error())
|
||||
e.Error( http.StatusInternalServerError, err, "查询失败")
|
||||
return
|
||||
e.Error(500, err, fmt.Sprintf("获取{{.TableComment}}失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
e.OK( object, "查询成功")
|
||||
}
|
||||
|
||||
// Insert{{.ClassName}} 创建{{.TableComment}}
|
||||
// Insert 创建{{.TableComment}}
|
||||
// @Summary 创建{{.TableComment}}
|
||||
// @Description 创建{{.TableComment}}
|
||||
// @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{{.ClassName}}(c *gin.Context) {
|
||||
e.SetContext(c)
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
control := new(dto.{{.ClassName}}Control)
|
||||
|
||||
//新增操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
log.Warnf("request body bind error, %s", err.Error())
|
||||
e.Error( http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.GenerateM()
|
||||
if err != nil {
|
||||
log.Errorf("generate {{.ClassName}} model error, %s", err.Error())
|
||||
e.Error( http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
func (e {{.ClassName}}) Insert(c *gin.Context) {
|
||||
req := dto.{{.ClassName}}InsertReq{}
|
||||
s := service.{{.ClassName}}{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
// 设置创建人
|
||||
object.SetCreateBy(user.GetUserId(c))
|
||||
req.SetCreateBy(user.GetUserId(c))
|
||||
|
||||
service{{.ClassName}} := service.{{.ClassName}}{}
|
||||
service{{.ClassName}}.Orm = db
|
||||
service{{.ClassName}}.Log = log
|
||||
err = service{{.ClassName}}.Insert{{.ClassName}}(object.(*models.{{.ClassName}}))
|
||||
err = s.Insert(&req)
|
||||
if err != nil {
|
||||
log.Errorf("Insert {{.ClassName}} error, %s", err.Error())
|
||||
e.Error( http.StatusInternalServerError, err, "创建失败")
|
||||
return
|
||||
e.Error(500, err, fmt.Sprintf("创建{{.TableComment}} 失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
e.OK( object.GetId(), "创建成功")
|
||||
e.OK(req.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
// Update{{.ClassName}} 修改{{.TableComment}}
|
||||
// Update 修改{{.TableComment}}
|
||||
// @Summary 修改{{.TableComment}}
|
||||
// @Description 修改{{.TableComment}}
|
||||
// @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{{.ClassName}}(c *gin.Context) {
|
||||
e.SetContext(c)
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
control := new(dto.{{.ClassName}}Control)
|
||||
|
||||
//更新操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
log.Warnf("request body bind error, %s", err.Error())
|
||||
e.Error( http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.GenerateM()
|
||||
if err != nil {
|
||||
log.Errorf("generate {{.ClassName}} model error, %s", err.Error())
|
||||
e.Error( http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
object.SetUpdateBy(user.GetUserId(c))
|
||||
|
||||
//数据权限检查
|
||||
func (e {{.ClassName}}) Update(c *gin.Context) {
|
||||
req := dto.{{.ClassName}}UpdateReq{}
|
||||
s := service.{{.ClassName}}{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
req.SetUpdateBy(user.GetUserId(c))
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
service{{.ClassName}} := service.{{.ClassName}}{}
|
||||
service{{.ClassName}}.Orm = db
|
||||
service{{.ClassName}}.Log = log
|
||||
err = service{{.ClassName}}.Update{{.ClassName}}(object.(*models.{{.ClassName}}), p)
|
||||
err = s.Update(&req, p)
|
||||
if err != nil {
|
||||
log.Errorf("Update {{.ClassName}} error, %s", err.Error())
|
||||
e.Error( http.StatusInternalServerError, err, "更新失败")
|
||||
return
|
||||
e.Error(500, err, fmt.Sprintf("修改{{.TableComment}} 失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK( object.GetId(), "更新成功")
|
||||
e.OK( req.GetId(), "修改成功")
|
||||
}
|
||||
|
||||
// Delete{{.ClassName}} 删除{{.TableComment}}
|
||||
// Delete 删除{{.TableComment}}
|
||||
// @Summary 删除{{.TableComment}}
|
||||
// @Description 删除{{.TableComment}}
|
||||
// @Tags {{.TableComment}}
|
||||
@@ -223,39 +171,27 @@ func (e {{.ClassName}}) Update{{.ClassName}}(c *gin.Context) {
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "删除成功"}"
|
||||
// @Router /api/v1/{{.ModuleName}} [delete]
|
||||
// @Security Bearer
|
||||
func (e {{.ClassName}}) Delete{{.ClassName}}(c *gin.Context) {
|
||||
e.SetContext(c)
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
func (e {{.ClassName}}) Delete(c *gin.Context) {
|
||||
s := service.{{.ClassName}}{}
|
||||
req := dto.{{.ClassName}}DeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
control := new(dto.{{.ClassName}}ById)
|
||||
|
||||
//删除操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
log.Warnf("request body bind error, %s", err.Error())
|
||||
e.Error( http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
// 设置编辑人
|
||||
control.SetUpdateBy(user.GetUserId(c))
|
||||
|
||||
// 数据权限检查
|
||||
// req.SetUpdateBy(user.GetUserId(c))
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
service{{.ClassName}} := service.{{.ClassName}}{}
|
||||
service{{.ClassName}}.Orm = db
|
||||
service{{.ClassName}}.Log = log
|
||||
err = service{{.ClassName}}.Remove{{.ClassName}}(control, p)
|
||||
err = s.Remove(&req, p)
|
||||
if err != nil {
|
||||
log.Errorf("Remove {{.ClassName}} error, %s", err.Error())
|
||||
e.Error( http.StatusInternalServerError, err, "删除失败")
|
||||
return
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,17 @@ import (
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/{{.PackageName}}/models"
|
||||
"go-admin/app/{{.PackageName}}/service/dto"
|
||||
"go-admin/common/actions"
|
||||
cDto "go-admin/common/dto"
|
||||
"go-admin/app/{{.PackageName}}/service/dto"
|
||||
)
|
||||
|
||||
type {{.ClassName}} struct {
|
||||
service.Service
|
||||
}
|
||||
|
||||
// Get{{.ClassName}}Page 获取{{.ClassName}}列表
|
||||
func (e *{{.ClassName}}) Get{{.ClassName}}Page(c *dto.{{.ClassName}}Search, p *actions.DataPermission, list *[]models.{{.ClassName}}, count *int64) error {
|
||||
// GetPage 获取{{.ClassName}}列表
|
||||
func (e *{{.ClassName}}) GetPage(c *dto.{{.ClassName}}GetPageReq, p *actions.DataPermission, list *[]models.{{.ClassName}}, count *int64) error {
|
||||
var err error
|
||||
var data models.{{.ClassName}}
|
||||
|
||||
@@ -30,14 +30,14 @@ func (e *{{.ClassName}}) Get{{.ClassName}}Page(c *dto.{{.ClassName}}Search, p *a
|
||||
Find(list).Limit(-1).Offset(-1).
|
||||
Count(count).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("Service Get{{.ClassName}}Page error:%s", err)
|
||||
e.Log.Errorf("{{.ClassName}}Service GetPage error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get{{.ClassName}} 获取{{.ClassName}}对象
|
||||
func (e *{{.ClassName}}) Get{{.ClassName}}(d *dto.{{.ClassName}}ById, p *actions.DataPermission, model *models.{{.ClassName}}) error {
|
||||
// Get 获取{{.ClassName}}对象
|
||||
func (e *{{.ClassName}}) Get(d *dto.{{.ClassName}}GetReq, p *actions.DataPermission, model *models.{{.ClassName}}) error {
|
||||
var data models.{{.ClassName}}
|
||||
|
||||
err := e.Orm.Model(&data).
|
||||
@@ -47,7 +47,7 @@ func (e *{{.ClassName}}) Get{{.ClassName}}(d *dto.{{.ClassName}}ById, p *actions
|
||||
First(model, d.GetId()).Error
|
||||
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
err = errors.New("查看对象不存在或无权查看")
|
||||
e.Log.Errorf("Service Get{{.ClassName}} error:%s", err)
|
||||
e.Log.Errorf("Service Get{{.ClassName}} error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
@@ -57,34 +57,41 @@ func (e *{{.ClassName}}) Get{{.ClassName}}(d *dto.{{.ClassName}}ById, p *actions
|
||||
return nil
|
||||
}
|
||||
|
||||
// Insert{{.ClassName}} 创建{{.ClassName}}对象
|
||||
func (e *{{.ClassName}}) Insert{{.ClassName}}(c *models.{{.ClassName}}) error {
|
||||
err := e.Orm.Create(c).Error
|
||||
// Insert 创建{{.ClassName}}对象
|
||||
func (e *{{.ClassName}}) Insert(c *dto.{{.ClassName}}InsertReq) error {
|
||||
var err error
|
||||
var data models.{{.ClassName}}
|
||||
c.Generate(&data)
|
||||
err = e.Orm.Create(&data).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("Service Insert{{.ClassName}} error:%s", err)
|
||||
e.Log.Errorf("{{.ClassName}}Service Insert error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update{{.ClassName}} 修改{{.ClassName}}对象
|
||||
func (e *{{.ClassName}}) Update{{.ClassName}}(c *models.{{.ClassName}}, p *actions.DataPermission) error {
|
||||
db := e.Orm.Model(c).
|
||||
Scopes(
|
||||
actions.Permission(c.TableName(), p),
|
||||
).Where(c.GetId()).Updates(c)
|
||||
if err := db.Error; err != nil {
|
||||
e.Log.Errorf("Service Update{{.ClassName}} error:%s", err)
|
||||
// Update 修改{{.ClassName}}对象
|
||||
func (e *{{.ClassName}}) Update(c *dto.{{.ClassName}}UpdateReq, p *actions.DataPermission) error {
|
||||
var err error
|
||||
var data = models.{{.ClassName}}{}
|
||||
e.Orm.Scopes(
|
||||
actions.Permission(data.TableName(), p),
|
||||
).First(&data, c.GetId())
|
||||
c.Generate(&data)
|
||||
|
||||
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
|
||||
if db.RowsAffected == 0 {
|
||||
return errors.New("无权更新该数据")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Remove{{.ClassName}} 删除{{.ClassName}}
|
||||
func (e *{{.ClassName}}) Remove{{.ClassName}}(d *dto.{{.ClassName}}ById, p *actions.DataPermission) error {
|
||||
// Remove 删除{{.ClassName}}
|
||||
func (e *{{.ClassName}}) Remove(d *dto.{{.ClassName}}DeleteReq, p *actions.DataPermission) error {
|
||||
var data models.{{.ClassName}}
|
||||
|
||||
db := e.Orm.Model(&data).
|
||||
@@ -92,7 +99,7 @@ func (e *{{.ClassName}}) Remove{{.ClassName}}(d *dto.{{.ClassName}}ById, p *acti
|
||||
actions.Permission(data.TableName(), p),
|
||||
).Delete(&data, d.GetId())
|
||||
if err := db.Error; err != nil {
|
||||
e.Log.Errorf("Service Remove{{.ClassName}} error:%s", err)
|
||||
e.Log.Errorf("Service Remove{{.ClassName}} error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
if db.RowsAffected == 0 {
|
||||
|
||||
+22
-29
@@ -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 -}}
|
||||
@@ -223,27 +223,23 @@
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<FileChoose ref="fileChoose" :dialog-form-visible="fileOpen" @confirm="getImgList" @close="fileClose" />
|
||||
</el-card>
|
||||
</template>
|
||||
</BasicLayout>
|
||||
</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 -}}
|
||||
|
||||
import FileChoose from '@/components/FileChoose'
|
||||
|
||||
export default {
|
||||
name: '{{.ClassName}}',
|
||||
components: {
|
||||
FileChoose
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -262,11 +258,9 @@
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
isEdit: false,
|
||||
fileOpen: false,
|
||||
fileIndex: undefined,
|
||||
// 类型数据字典
|
||||
typeOptions: [],
|
||||
{{.ModuleName}}List: [],
|
||||
{{.BusinessName}}List: [],
|
||||
{{range .Columns}}
|
||||
{{- if ne .DictType "" -}}
|
||||
{{.JsonField}}Options: [],
|
||||
@@ -296,10 +290,7 @@
|
||||
{{- range .Columns -}}
|
||||
{{- $x := .IsQuery -}}
|
||||
{{- if (eq $x "1") -}}
|
||||
{{.JsonField}}:
|
||||
[
|
||||
{required: true, message: '{{.ColumnComment}}不能为空', trigger: 'blur'}
|
||||
],
|
||||
{{.JsonField}}: [ {required: true, message: '{{.ColumnComment}}不能为空', trigger: 'blur'} ],
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
}
|
||||
@@ -309,15 +300,12 @@
|
||||
this.getList()
|
||||
{{range .Columns}}
|
||||
{{- if ne .DictType "" -}}
|
||||
|
||||
this.getDicts('{{.DictType}}').then(response => {
|
||||
this.{{.JsonField}}Options = response.data
|
||||
})
|
||||
|
||||
{{ end -}}
|
||||
{{- if ne .FkTableName "" -}}
|
||||
this.get{{.FkTableNameClass}}Items()
|
||||
|
||||
{{ end -}}
|
||||
{{- end -}}
|
||||
},
|
||||
@@ -326,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
|
||||
}
|
||||
@@ -436,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 {
|
||||
@@ -446,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 {
|
||||
@@ -467,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