feat ✨ 优化api写法
This commit is contained in:
1 parent
5957fb280c
commit
13ff9d9e63
38 files changed
+777
-672
No files matched your search
@@ -10,15 +10,16 @@ type System struct {
|
||||
apis.Api
|
||||
}
|
||||
|
||||
func (e *System) GenerateCaptchaHandler(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e System) GenerateCaptchaHandler(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
id, b64s, err := captcha.DriverDigitFunc()
|
||||
if err != nil {
|
||||
log.Errorf("DriverDigitFunc error, %s", err.Error())
|
||||
e.Error(c, 500, err, "验证码获取失败")
|
||||
e.Error(500, err, "验证码获取失败")
|
||||
return
|
||||
}
|
||||
e.Custom(c, gin.H{
|
||||
e.Custom(gin.H{
|
||||
"code": 200,
|
||||
"data": b64s,
|
||||
"id": id,
|
||||
|
||||
@@ -29,9 +29,10 @@ type SysDictData struct {
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/dict/data [get]
|
||||
// @Security Bearer
|
||||
func (e *SysDictData) GetSysDictDataList(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysDictData) GetSysDictDataList(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -43,7 +44,7 @@ func (e *SysDictData) GetSysDictDataList(c *gin.Context) {
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
log.Warnf("Bind error: %s", err.Error())
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -55,11 +56,11 @@ func (e *SysDictData) GetSysDictDataList(c *gin.Context) {
|
||||
err = s.GetPage(req, &list, &count)
|
||||
if err != nil {
|
||||
log.Errorf("GetPage error, %s", err.Error())
|
||||
e.Error(c, http.StatusInternalServerError, err, "查询失败")
|
||||
e.Error(http.StatusInternalServerError, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.PageOK(c, list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
// @Summary 通过编码获取字典数据
|
||||
@@ -69,9 +70,10 @@ func (e *SysDictData) GetSysDictDataList(c *gin.Context) {
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/dict/data/{dictCode} [get]
|
||||
// @Security Bearer
|
||||
func (e *SysDictData) GetSysDictData(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysDictData) GetSysDictData(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -82,7 +84,7 @@ func (e *SysDictData) GetSysDictData(c *gin.Context) {
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
log.Warnf("Bind error: %s", err.Error())
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object system.SysDictData
|
||||
@@ -93,11 +95,11 @@ func (e *SysDictData) GetSysDictData(c *gin.Context) {
|
||||
err = s.Get(req, &object)
|
||||
if err != nil {
|
||||
log.Warnf("Get error: %s", err.Error())
|
||||
e.Error(c, http.StatusInternalServerError, err, "查询失败")
|
||||
e.Error(http.StatusInternalServerError, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object, "查看成功")
|
||||
e.OK(object, "查看成功")
|
||||
}
|
||||
|
||||
// @Summary 添加字典数据
|
||||
@@ -110,9 +112,10 @@ func (e *SysDictData) GetSysDictData(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/dict/data [post]
|
||||
// @Security Bearer
|
||||
func (e *SysDictData) InsertSysDictData(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysDictData) InsertSysDictData(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -123,7 +126,7 @@ func (e *SysDictData) InsertSysDictData(c *gin.Context) {
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
log.Warnf("Bind error: %s", err.Error())
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, _ := req.GenerateM()
|
||||
@@ -136,11 +139,11 @@ func (e *SysDictData) InsertSysDictData(c *gin.Context) {
|
||||
err = s.Insert(object.(*system.SysDictData))
|
||||
if err != nil {
|
||||
log.Errorf("Insert error, %s", err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "创建失败")
|
||||
e.Error(http.StatusInternalServerError, err, "创建失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object.GetId(), "创建成功")
|
||||
e.OK(object.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
// @Summary 修改字典数据
|
||||
@@ -153,9 +156,10 @@ func (e *SysDictData) InsertSysDictData(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/dict/data/{dictCode} [put]
|
||||
// @Security Bearer
|
||||
func (e *SysDictData) UpdateSysDictData(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysDictData) UpdateSysDictData(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -166,7 +170,7 @@ func (e *SysDictData) UpdateSysDictData(c *gin.Context) {
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
log.Warnf("request validate error, %s", err.Error())
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, _ := req.GenerateM()
|
||||
@@ -178,10 +182,10 @@ func (e *SysDictData) UpdateSysDictData(c *gin.Context) {
|
||||
err = s.Update(object.(*system.SysDictData))
|
||||
if err != nil {
|
||||
log.Errorf("Update error, %s", err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "更新失败")
|
||||
e.Error(http.StatusInternalServerError, err, "更新失败")
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "更新成功")
|
||||
e.OK(object.GetId(), "更新成功")
|
||||
}
|
||||
|
||||
// @Summary 删除字典数据
|
||||
@@ -191,9 +195,10 @@ func (e *SysDictData) UpdateSysDictData(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
||||
// @Router /api/v1/dict/data/{dictCode} [delete]
|
||||
func (e *SysDictData) DeleteSysDictData(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysDictData) DeleteSysDictData(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -204,14 +209,14 @@ func (e *SysDictData) DeleteSysDictData(c *gin.Context) {
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
log.Warnf("Bind error: %s", err)
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object common.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
log.Errorf("GenerateM error, %s", err.Error())
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -224,15 +229,16 @@ func (e *SysDictData) DeleteSysDictData(c *gin.Context) {
|
||||
err = s.Remove(req, object.(*system.SysDictData))
|
||||
if err != nil {
|
||||
log.Errorf("Remove error, %s", err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "删除失败")
|
||||
e.Error(http.StatusInternalServerError, err, "删除失败")
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "删除成功")
|
||||
e.OK(object.GetId(), "删除成功")
|
||||
}
|
||||
|
||||
func (e *SysDictData) GetSysDictDataAll(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysDictData) GetSysDictDataAll(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -244,7 +250,7 @@ func (e *SysDictData) GetSysDictDataAll(c *gin.Context) {
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
log.Warnf("Bind error: %s", err)
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -255,9 +261,9 @@ func (e *SysDictData) GetSysDictDataAll(c *gin.Context) {
|
||||
err = s.GetAll(req, &list)
|
||||
if err != nil {
|
||||
log.Errorf("GetAll error, %s", err.Error())
|
||||
e.Error(c, http.StatusInternalServerError, err, "查询失败")
|
||||
e.Error(http.StatusInternalServerError, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, list, "查询成功")
|
||||
e.OK(list, "查询成功")
|
||||
}
|
||||
@@ -29,9 +29,10 @@ type SysDictType struct {
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/dict/type [get]
|
||||
// @Security Bearer
|
||||
func (e *SysDictType) GetSysDictTypeList(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysDictType) GetSysDictTypeList(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -42,7 +43,7 @@ func (e *SysDictType) GetSysDictTypeList(c *gin.Context) {
|
||||
//查询列表
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -53,11 +54,11 @@ func (e *SysDictType) GetSysDictTypeList(c *gin.Context) {
|
||||
s.Orm = db.Debug()
|
||||
err = s.GetPage(req, &list, &count)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "查询失败")
|
||||
e.Error(http.StatusInternalServerError, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.PageOK(c, list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
// @Summary 通过字典id获取字典类型
|
||||
@@ -67,9 +68,10 @@ func (e *SysDictType) GetSysDictTypeList(c *gin.Context) {
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/dict/type/{dictId} [get]
|
||||
// @Security Bearer
|
||||
func (e *SysDictType) GetSysDictType(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysDictType) GetSysDictType(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -79,7 +81,7 @@ func (e *SysDictType) GetSysDictType(c *gin.Context) {
|
||||
req := &dto.SysDictTypeById{}
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object system.SysDictType
|
||||
@@ -89,11 +91,11 @@ func (e *SysDictType) GetSysDictType(c *gin.Context) {
|
||||
s.Orm = db
|
||||
err = s.Get(req, &object)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object, "查看成功")
|
||||
e.OK(object, "查看成功")
|
||||
}
|
||||
|
||||
// @Summary 添加字典类型
|
||||
@@ -106,9 +108,10 @@ func (e *SysDictType) GetSysDictType(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/dict/type [post]
|
||||
// @Security Bearer
|
||||
func (e *SysDictType) InsertSysDictType(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysDictType) InsertSysDictType(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -118,7 +121,7 @@ func (e *SysDictType) InsertSysDictType(c *gin.Context) {
|
||||
req := &dto.SysDictTypeControl{}
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, _ := req.GenerateM()
|
||||
@@ -131,11 +134,11 @@ func (e *SysDictType) InsertSysDictType(c *gin.Context) {
|
||||
err = s.Insert(object.(*system.SysDictType))
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "创建失败")
|
||||
e.Error(http.StatusInternalServerError, err, "创建失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object.GetId(), "创建成功")
|
||||
e.OK(object.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
// @Summary 修改字典类型
|
||||
@@ -148,9 +151,10 @@ func (e *SysDictType) InsertSysDictType(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/dict/type/{dictId} [put]
|
||||
// @Security Bearer
|
||||
func (e *SysDictType) UpdateSysDictType(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysDictType) UpdateSysDictType(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -160,7 +164,7 @@ func (e *SysDictType) UpdateSysDictType(c *gin.Context) {
|
||||
//更新操作
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, _ := req.GenerateM()
|
||||
@@ -174,7 +178,7 @@ func (e *SysDictType) UpdateSysDictType(c *gin.Context) {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "更新成功")
|
||||
e.OK(object.GetId(), "更新成功")
|
||||
}
|
||||
|
||||
// @Summary 删除字典类型
|
||||
@@ -184,9 +188,10 @@ func (e *SysDictType) UpdateSysDictType(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
||||
// @Router /api/v1/dict/type/{dictId} [delete]
|
||||
func (e *SysDictType) DeleteSysDictType(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysDictType) DeleteSysDictType(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -197,13 +202,13 @@ func (e *SysDictType) DeleteSysDictType(c *gin.Context) {
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("Bind error: %s", err)
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object common.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -218,7 +223,7 @@ func (e *SysDictType) DeleteSysDictType(c *gin.Context) {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "删除成功")
|
||||
e.OK(object.GetId(), "删除成功")
|
||||
}
|
||||
|
||||
// @Summary 字典类型全部数据
|
||||
@@ -230,9 +235,10 @@ func (e *SysDictType) DeleteSysDictType(c *gin.Context) {
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/dict/type-option-select [get]
|
||||
// @Security Bearer
|
||||
func (e *SysDictType) GetSysDictTypeAll(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysDictType) GetSysDictTypeAll(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -243,7 +249,7 @@ func (e *SysDictType) GetSysDictTypeAll(c *gin.Context) {
|
||||
//查询列表
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -253,9 +259,9 @@ func (e *SysDictType) GetSysDictTypeAll(c *gin.Context) {
|
||||
s.Orm = db
|
||||
err = s.GetAll(req, &list)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, list, "查询成功")
|
||||
e.OK(list, "查询成功")
|
||||
}
|
||||
@@ -23,9 +23,10 @@ type SysSetting struct {
|
||||
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/setting [get]
|
||||
func (e *SysSetting) GetSetting(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysSetting) GetSetting(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -37,7 +38,7 @@ func (e *SysSetting) GetSetting(c *gin.Context) {
|
||||
var model = models.SysSetting{}
|
||||
err = sysSettingService.GetSysSetting(&model)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "查询失败")
|
||||
e.Error(http.StatusInternalServerError, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ func (e *SysSetting) GetSetting(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
e.OK(c, model, "查询成功")
|
||||
e.OK(model, "查询成功")
|
||||
}
|
||||
|
||||
// @Summary 更新或提交系统信息
|
||||
@@ -57,10 +58,11 @@ func (e *SysSetting) GetSetting(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/system/setting [post]
|
||||
func (e *SysSetting) CreateOrUpdateSetting(c *gin.Context) {
|
||||
func (e SysSetting) CreateOrUpdateSetting(c *gin.Context) {
|
||||
control := new(dto.SysSettingControl)
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -69,12 +71,12 @@ func (e *SysSetting) CreateOrUpdateSetting(c *gin.Context) {
|
||||
//更新操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -83,7 +85,7 @@ func (e *SysSetting) CreateOrUpdateSetting(c *gin.Context) {
|
||||
sysSettingService.Orm = db
|
||||
err = sysSettingService.UpdateSysSetting(object)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "更新失败")
|
||||
e.Error(http.StatusInternalServerError, err, "更新失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -92,5 +94,5 @@ func (e *SysSetting) CreateOrUpdateSetting(c *gin.Context) {
|
||||
object.Logo = fmt.Sprintf("http://%s/%s", c.Request.Host, object.Logo)
|
||||
}
|
||||
}
|
||||
e.OK(c, object, "提交成功")
|
||||
e.OK(object, "提交成功")
|
||||
}
|
||||
@@ -16,10 +16,11 @@ type SysConfig struct {
|
||||
apis.Api
|
||||
}
|
||||
|
||||
func (e *SysConfig) GetSysConfigList(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysConfig) GetSysConfigList(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
d := new(dto.SysConfigSearch)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -29,7 +30,7 @@ func (e *SysConfig) GetSysConfigList(c *gin.Context) {
|
||||
err = d.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("参数验证失败, error:%s", err)
|
||||
e.Error(c, 500, err, "参数验证失败")
|
||||
e.Error(500, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -41,17 +42,18 @@ func (e *SysConfig) GetSysConfigList(c *gin.Context) {
|
||||
err = s.GetSysConfigPage(d, &list, &count)
|
||||
if err != nil {
|
||||
log.Errorf("GetSysConfigPage 查询失败, error:%s", err)
|
||||
e.Error(c, 500, err, "查询失败")
|
||||
e.Error(500, err, "查询失败")
|
||||
return
|
||||
}
|
||||
e.PageOK(c, list, int(count), d.GetPageIndex(), d.GetPageSize(), "查询成功")
|
||||
e.PageOK(list, int(count), d.GetPageIndex(), d.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
// GetSysConfigBySysApp 获取系统配置信息,主要注意这里不在验证数据权限
|
||||
func (e *SysConfig) GetSysConfigBySysApp(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysConfig) GetSysConfigBySysApp(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
d := new(dto.SysConfigSearch)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -59,7 +61,7 @@ func (e *SysConfig) GetSysConfigBySysApp(c *gin.Context) {
|
||||
err = d.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("参数验证失败, error:%s", err)
|
||||
e.Error(c, 500, err, "参数验证失败")
|
||||
e.Error(500, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -73,7 +75,7 @@ func (e *SysConfig) GetSysConfigBySysApp(c *gin.Context) {
|
||||
err = s.GetSysConfigByKey(d, &list)
|
||||
if err != nil {
|
||||
log.Errorf("GetSysConfigPage 查询失败, error:%s", err)
|
||||
e.Error(c, 500, err, "查询失败")
|
||||
e.Error(500, err, "查询失败")
|
||||
return
|
||||
}
|
||||
mp := make(map[string]string)
|
||||
@@ -83,13 +85,14 @@ func (e *SysConfig) GetSysConfigBySysApp(c *gin.Context) {
|
||||
mp[key] = list[i].ConfigValue
|
||||
}
|
||||
}
|
||||
e.OK(c, mp, "查询成功")
|
||||
e.OK(mp, "查询成功")
|
||||
}
|
||||
|
||||
func (e *SysConfig) GetSysConfig(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysConfig) GetSysConfig(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysConfigById)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -97,9 +100,9 @@ func (e *SysConfig) GetSysConfig(c *gin.Context) {
|
||||
//查看详情
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
log.Errorf("Orm获取失败, error:%s", err)
|
||||
e.Error(c, 500, err, "Orm获取失败")
|
||||
e.Error(500, err, "Orm获取失败")
|
||||
return
|
||||
}
|
||||
var object system.SysConfig
|
||||
@@ -109,19 +112,20 @@ func (e *SysConfig) GetSysConfig(c *gin.Context) {
|
||||
serviceSysLoginLog.Orm = db
|
||||
err = serviceSysLoginLog.GetSysConfig(control, &object)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
log.Errorf("Orm获取失败, error:%s", err)
|
||||
e.Error(c, 500, err, "Orm获取失败")
|
||||
e.Error(500, err, "Orm获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object, "查看成功")
|
||||
e.OK(object, "查看成功")
|
||||
}
|
||||
|
||||
func (e *SysConfig) InsertSysConfig(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysConfig) InsertSysConfig(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysConfigControl)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -130,16 +134,16 @@ func (e *SysConfig) InsertSysConfig(c *gin.Context) {
|
||||
//新增操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
log.Errorf("Orm获取失败, error:%s", err)
|
||||
e.Error(c, 500, err, "Orm获取失败")
|
||||
e.Error(500, err, "Orm获取失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
log.Errorf("Orm获取失败, error:%s", err)
|
||||
e.Error(c, 500, err, "Orm获取失败")
|
||||
e.Error(500, err, "Orm获取失败")
|
||||
return
|
||||
}
|
||||
// 设置创建人
|
||||
@@ -151,19 +155,20 @@ func (e *SysConfig) InsertSysConfig(c *gin.Context) {
|
||||
err = serviceSysLoginLog.InsertSysConfig(object)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "创建失败")
|
||||
e.Error(http.StatusInternalServerError, err, "创建失败")
|
||||
log.Errorf("Orm获取失败, error:%s", err)
|
||||
e.Error(c, 500, err, "Orm获取失败")
|
||||
e.Error(500, err, "Orm获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object.GetId(), "创建成功")
|
||||
e.OK(object.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
func (e *SysConfig) UpdateSysConfig(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysConfig) UpdateSysConfig(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysConfigControl)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -173,16 +178,16 @@ func (e *SysConfig) UpdateSysConfig(c *gin.Context) {
|
||||
err = control.Bind(c)
|
||||
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
log.Errorf("Orm获取失败, error:%s", err)
|
||||
e.Error(c, 500, err, "Orm获取失败")
|
||||
e.Error(500, err, "Orm获取失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
log.Errorf("Orm获取失败, error:%s", err)
|
||||
e.Error(c, 500, err, "Orm获取失败")
|
||||
e.Error(500, err, "Orm获取失败")
|
||||
return
|
||||
}
|
||||
object.SetUpdateBy(user.GetUserId(c))
|
||||
@@ -192,18 +197,19 @@ func (e *SysConfig) UpdateSysConfig(c *gin.Context) {
|
||||
serviceSysLoginLog.Log = log
|
||||
err = serviceSysLoginLog.UpdateSysConfig(object)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "更新失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "更新失败")
|
||||
log.Errorf("Orm获取失败, error:%s", err)
|
||||
e.Error(c, 500, err, "Orm获取失败")
|
||||
e.Error(500, err, "Orm获取失败")
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "更新成功")
|
||||
e.OK(object.GetId(), "更新成功")
|
||||
}
|
||||
|
||||
func (e *SysConfig) DeleteSysConfig(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysConfig) DeleteSysConfig(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysConfigById)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -213,16 +219,16 @@ func (e *SysConfig) DeleteSysConfig(c *gin.Context) {
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("Bind error: %s", err)
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
log.Errorf("Orm获取失败, error:%s", err)
|
||||
e.Error(c, 500, err, "Orm获取失败")
|
||||
e.Error(500, err, "Orm获取失败")
|
||||
return
|
||||
}
|
||||
object, err := control.GenerateM()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
log.Errorf("Orm获取失败, error:%s", err)
|
||||
e.Error(c, 500, err, "Orm获取失败")
|
||||
e.Error(500, err, "Orm获取失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -234,18 +240,19 @@ func (e *SysConfig) DeleteSysConfig(c *gin.Context) {
|
||||
serviceSysLoginLog.Log = log
|
||||
err = serviceSysLoginLog.RemoveSysConfig(control, object)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "删除失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "删除失败")
|
||||
log.Errorf("Orm获取失败, error:%s", err)
|
||||
e.Error(c, 500, err, "Orm获取失败")
|
||||
e.Error(500, err, "Orm获取失败")
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "删除成功")
|
||||
e.OK(object.GetId(), "删除成功")
|
||||
}
|
||||
|
||||
// GetSysConfigByKEYForService 根据Key获取SysConfig的Service
|
||||
func (e *SysConfig) GetSysConfigByKEYForService(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysConfig) GetSysConfigByKEYForService(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -254,7 +261,7 @@ func (e *SysConfig) GetSysConfigByKEYForService(c *gin.Context) {
|
||||
err = v.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("参数验证错误, error:%s", err)
|
||||
e.Error(c, 422, err, "参数验证失败")
|
||||
e.Error(422, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
s := service.SysConfig{}
|
||||
@@ -263,8 +270,8 @@ func (e *SysConfig) GetSysConfigByKEYForService(c *gin.Context) {
|
||||
err = s.GetSysConfigByKEY(&v)
|
||||
if err != nil {
|
||||
log.Errorf("通过Key获取配置失败, error:%s", err)
|
||||
e.Error(c, 500, err, "")
|
||||
e.Error(500, err, "")
|
||||
return
|
||||
}
|
||||
e.OK(c, v, s.Msg)
|
||||
e.OK(v, s.Msg)
|
||||
}
|
||||
@@ -27,10 +27,11 @@ type SysDept struct {
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/dept [get]
|
||||
// @Security Bearer
|
||||
func (e *SysDept) GetSysDeptList(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysDept) GetSysDeptList(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
d := new(dto.SysDeptSearch)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -39,7 +40,7 @@ func (e *SysDept) GetSysDeptList(c *gin.Context) {
|
||||
//查询列表
|
||||
err = d.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -49,11 +50,11 @@ func (e *SysDept) GetSysDeptList(c *gin.Context) {
|
||||
serviceStudent.Orm = db
|
||||
list, err = serviceStudent.SetDeptPage(d)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, list, "查询成功")
|
||||
e.OK(list, "查询成功")
|
||||
}
|
||||
|
||||
// @Summary 部门列表数据
|
||||
@@ -64,10 +65,11 @@ func (e *SysDept) GetSysDeptList(c *gin.Context) {
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/dept/{deptId} [get]
|
||||
// @Security Bearer
|
||||
func (e *SysDept) GetSysDept(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysDept) GetSysDept(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysDeptById)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -76,7 +78,7 @@ func (e *SysDept) GetSysDept(c *gin.Context) {
|
||||
//查看详情
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object system.SysDept
|
||||
@@ -86,11 +88,11 @@ func (e *SysDept) GetSysDept(c *gin.Context) {
|
||||
serviceSysOperlog.Orm = db
|
||||
err = serviceSysOperlog.GetSysDept(control, &object)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object, "查看成功")
|
||||
e.OK(object, "查看成功")
|
||||
}
|
||||
|
||||
// @Summary 添加部门
|
||||
@@ -103,10 +105,11 @@ func (e *SysDept) GetSysDept(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/dept [post]
|
||||
// @Security Bearer
|
||||
func (e *SysDept) InsertSysDept(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysDept) InsertSysDept(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysDeptControl)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -115,12 +118,12 @@ func (e *SysDept) InsertSysDept(c *gin.Context) {
|
||||
//新增操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
// 设置创建人
|
||||
@@ -132,11 +135,11 @@ func (e *SysDept) InsertSysDept(c *gin.Context) {
|
||||
err = serviceSysDept.InsertSysDept(object)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "创建失败")
|
||||
e.Error(http.StatusInternalServerError, err, "创建失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object.GetId(), "创建成功")
|
||||
e.OK(object.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
// @Summary 修改部门
|
||||
@@ -150,10 +153,11 @@ func (e *SysDept) InsertSysDept(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/dept/{deptId} [put]
|
||||
// @Security Bearer
|
||||
func (e *SysDept) UpdateSysDept(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysDept) UpdateSysDept(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysDeptControl)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -162,12 +166,12 @@ func (e *SysDept) UpdateSysDept(c *gin.Context) {
|
||||
//更新操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
object.SetUpdateBy(user.GetUserId(c))
|
||||
@@ -180,7 +184,7 @@ func (e *SysDept) UpdateSysDept(c *gin.Context) {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "更新成功")
|
||||
e.OK(object.GetId(), "更新成功")
|
||||
}
|
||||
|
||||
// @Summary 删除部门
|
||||
@@ -190,10 +194,11 @@ func (e *SysDept) UpdateSysDept(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
||||
// @Router /api/v1/dept [delete]
|
||||
func (e *SysDept) DeleteSysDept(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysDept) DeleteSysDept(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysDeptById)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -203,7 +208,7 @@ func (e *SysDept) DeleteSysDept(c *gin.Context) {
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("Bind error: %s", err)
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -213,17 +218,18 @@ func (e *SysDept) DeleteSysDept(c *gin.Context) {
|
||||
err = serviceSysDept.RemoveSysDept(control)
|
||||
if err != nil {
|
||||
log.Errorf("RemoveSysDept error, %s", err.Error())
|
||||
e.Error(c, http.StatusInternalServerError, err, "删除失败")
|
||||
e.Error(http.StatusInternalServerError, err, "删除失败")
|
||||
return
|
||||
}
|
||||
e.OK(c, control.GetId(), "删除成功")
|
||||
e.OK(control.GetId(), "删除成功")
|
||||
}
|
||||
|
||||
// GetDeptTree 用户管理 左侧部门树
|
||||
func (e *SysDept) GetDeptTree(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysDept) GetDeptTree(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
d := new(dto.SysDeptSearch)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -232,7 +238,7 @@ func (e *SysDept) GetDeptTree(c *gin.Context) {
|
||||
//查询列表
|
||||
err = d.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -242,7 +248,7 @@ func (e *SysDept) GetDeptTree(c *gin.Context) {
|
||||
serviceStudent.Orm = db
|
||||
list, err = serviceStudent.SetDeptTree(d)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -252,12 +258,13 @@ func (e *SysDept) GetDeptTree(c *gin.Context) {
|
||||
//Dept.DeptId, _ = tools.StringToInt(c.Request.FormValue("deptId"))
|
||||
//result, err := Dept.SetDept(false)
|
||||
//tools.HasError(err, "抱歉未找到相关信息", -1)
|
||||
e.OK(c, list, "")
|
||||
e.OK(list, "")
|
||||
}
|
||||
|
||||
func (e *SysDept) GetDeptTreeRoleSelect(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysDept) GetDeptTreeRoleSelect(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -270,17 +277,17 @@ func (e *SysDept) GetDeptTreeRoleSelect(c *gin.Context) {
|
||||
result, err := s.SetDeptLabel()
|
||||
if err != nil {
|
||||
log.Errorf("SetDeptLabel error, %s", err.Error())
|
||||
e.Error(c, http.StatusInternalServerError, err, "")
|
||||
e.Error(http.StatusInternalServerError, err, "")
|
||||
}
|
||||
menuIds := make([]int, 0)
|
||||
if id != 0 {
|
||||
menuIds, err = s.GetRoleDeptId(id)
|
||||
if err != nil {
|
||||
log.Errorf("抱歉未找到相关信息, %s", err.Error())
|
||||
e.Error(c, http.StatusInternalServerError, err, "")
|
||||
e.Error(http.StatusInternalServerError, err, "")
|
||||
}
|
||||
}
|
||||
e.OK(c, gin.H{
|
||||
e.OK(gin.H{
|
||||
"depts": result,
|
||||
"checkedKeys": menuIds,
|
||||
}, "")
|
||||
|
||||
@@ -16,10 +16,11 @@ type SysLoginLog struct {
|
||||
apis.Api
|
||||
}
|
||||
|
||||
func (e *SysLoginLog) GetSysLoginLogList(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysLoginLog) GetSysLoginLogList(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
d := new(dto.SysLoginLogSearch)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -28,7 +29,7 @@ func (e *SysLoginLog) GetSysLoginLogList(c *gin.Context) {
|
||||
//查询列表
|
||||
err = d.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -39,17 +40,18 @@ func (e *SysLoginLog) GetSysLoginLogList(c *gin.Context) {
|
||||
serviceStudent.Orm = db
|
||||
err = serviceStudent.GetSysLoginLogPage(d, &list, &count)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.PageOK(c, list, int(count), d.GetPageIndex(), d.GetPageSize(), "查询成功")
|
||||
e.PageOK(list, int(count), d.GetPageIndex(), d.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
func (e *SysLoginLog) GetSysLoginLog(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysLoginLog) GetSysLoginLog(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysLoginLogById)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -58,7 +60,7 @@ func (e *SysLoginLog) GetSysLoginLog(c *gin.Context) {
|
||||
//查看详情
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object system.SysLoginLog
|
||||
@@ -68,17 +70,18 @@ func (e *SysLoginLog) GetSysLoginLog(c *gin.Context) {
|
||||
serviceSysLoginLog.Orm = db
|
||||
err = serviceSysLoginLog.GetSysLoginLog(control, &object)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object, "查看成功")
|
||||
e.OK(object, "查看成功")
|
||||
}
|
||||
|
||||
func (e *SysLoginLog) InsertSysLoginLog(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysLoginLog) InsertSysLoginLog(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysLoginLogControl)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -87,12 +90,12 @@ func (e *SysLoginLog) InsertSysLoginLog(c *gin.Context) {
|
||||
//新增操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
// 设置创建人
|
||||
@@ -104,17 +107,18 @@ func (e *SysLoginLog) InsertSysLoginLog(c *gin.Context) {
|
||||
err = serviceSysLoginLog.InsertSysLoginLog(object)
|
||||
if err != nil {
|
||||
log.Errorf("InsertSysLoginLog error, %s", err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "创建失败")
|
||||
e.Error(http.StatusInternalServerError, err, "创建失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object.GetId(), "创建成功")
|
||||
e.OK(object.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
func (e *SysLoginLog) UpdateSysLoginLog(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysLoginLog) UpdateSysLoginLog(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysLoginLogControl)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -123,12 +127,12 @@ func (e *SysLoginLog) UpdateSysLoginLog(c *gin.Context) {
|
||||
//更新操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
object.SetUpdateBy(user.GetUserId(c))
|
||||
@@ -139,16 +143,17 @@ func (e *SysLoginLog) UpdateSysLoginLog(c *gin.Context) {
|
||||
err = serviceSysLoginLog.UpdateSysLoginLog(object)
|
||||
if err != nil {
|
||||
log.Errorf("UpdateSysLoginLog error, %s", err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "更新失败")
|
||||
e.Error(http.StatusInternalServerError, err, "更新失败")
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "更新成功")
|
||||
e.OK(object.GetId(), "更新成功")
|
||||
}
|
||||
|
||||
func (e *SysLoginLog) DeleteSysLoginLog(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysLoginLog) DeleteSysLoginLog(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysLoginLogById)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -158,12 +163,12 @@ func (e *SysLoginLog) DeleteSysLoginLog(c *gin.Context) {
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("Bind error: %s", err)
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.GenerateM()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -176,8 +181,8 @@ func (e *SysLoginLog) DeleteSysLoginLog(c *gin.Context) {
|
||||
err = serviceSysLoginLog.RemoveSysLoginLog(control, object)
|
||||
if err != nil {
|
||||
log.Errorf("RemoveSysLoginLog error, %s", err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "删除失败")
|
||||
e.Error(http.StatusInternalServerError, err, "删除失败")
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "删除成功")
|
||||
e.OK(object.GetId(), "删除成功")
|
||||
}
|
||||
@@ -24,10 +24,11 @@ type SysMenu struct {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "抱歉未找到相关信息"}"
|
||||
// @Router /api/v1/menulist [get]
|
||||
// @Security Bearer
|
||||
func (e *SysMenu) GetSysMenuList(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysMenu) GetSysMenuList(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
d := new(dto.SysMenuSearch)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -36,7 +37,7 @@ func (e *SysMenu) GetSysMenuList(c *gin.Context) {
|
||||
//查询列表
|
||||
err = d.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -46,11 +47,11 @@ func (e *SysMenu) GetSysMenuList(c *gin.Context) {
|
||||
serviceSysMenu.Orm = db
|
||||
list, err = serviceSysMenu.GetSysMenuPage(d)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, list, "查询成功")
|
||||
e.OK(list, "查询成功")
|
||||
}
|
||||
|
||||
// @Summary Menu详情数据
|
||||
@@ -61,12 +62,13 @@ func (e *SysMenu) GetSysMenuList(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "抱歉未找到相关信息"}"
|
||||
// @Router /api/v1/menu/{id} [get]
|
||||
// @Security Bearer
|
||||
func (e *SysMenu) GetSysMenu(c *gin.Context) {
|
||||
func (e SysMenu) GetSysMenu(c *gin.Context) {
|
||||
control := new(dto.SysMenuById)
|
||||
|
||||
log := e.GetLogger(c)
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -75,7 +77,7 @@ func (e *SysMenu) GetSysMenu(c *gin.Context) {
|
||||
//查看详情
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object system.SysMenu
|
||||
@@ -85,11 +87,11 @@ func (e *SysMenu) GetSysMenu(c *gin.Context) {
|
||||
serviceSysMenu.Orm = db
|
||||
err = serviceSysMenu.GetSysMenu(control, &object)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object, "查看成功")
|
||||
e.OK(object, "查看成功")
|
||||
}
|
||||
|
||||
// @Summary 创建菜单
|
||||
@@ -107,12 +109,13 @@ func (e *SysMenu) GetSysMenu(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/menu [post]
|
||||
// @Security Bearer
|
||||
func (e *SysMenu) InsertSysMenu(c *gin.Context) {
|
||||
func (e SysMenu) InsertSysMenu(c *gin.Context) {
|
||||
control := new(dto.SysMenuControl)
|
||||
|
||||
log := e.GetLogger(c)
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -121,12 +124,12 @@ func (e *SysMenu) InsertSysMenu(c *gin.Context) {
|
||||
//新增操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
// 设置创建人
|
||||
@@ -138,11 +141,11 @@ func (e *SysMenu) InsertSysMenu(c *gin.Context) {
|
||||
err = serviceSysMenu.InsertSysMenu(object)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "创建失败")
|
||||
e.Error(http.StatusInternalServerError, err, "创建失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object.GetId(), "创建成功")
|
||||
e.OK(object.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
// @Summary 修改菜单
|
||||
@@ -156,12 +159,13 @@ func (e *SysMenu) InsertSysMenu(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "修改失败"}"
|
||||
// @Router /api/v1/menu/{id} [put]
|
||||
// @Security Bearer
|
||||
func (e *SysMenu) UpdateSysMenu(c *gin.Context) {
|
||||
func (e SysMenu) UpdateSysMenu(c *gin.Context) {
|
||||
control := new(dto.SysMenuControl)
|
||||
|
||||
log := e.GetLogger(c)
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -170,12 +174,12 @@ func (e *SysMenu) UpdateSysMenu(c *gin.Context) {
|
||||
//更新操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
object.SetUpdateBy(user.GetUserId(c))
|
||||
@@ -188,7 +192,7 @@ func (e *SysMenu) UpdateSysMenu(c *gin.Context) {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "更新成功")
|
||||
e.OK(object.GetId(), "更新成功")
|
||||
}
|
||||
|
||||
// @Summary 删除菜单
|
||||
@@ -198,12 +202,13 @@ func (e *SysMenu) UpdateSysMenu(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
||||
// @Router /api/v1/menu/ [delete]
|
||||
func (e *SysMenu) DeleteSysMenu(c *gin.Context) {
|
||||
func (e SysMenu) DeleteSysMenu(c *gin.Context) {
|
||||
control := new(dto.SysMenuById)
|
||||
|
||||
log := e.GetLogger(c)
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -213,7 +218,7 @@ func (e *SysMenu) DeleteSysMenu(c *gin.Context) {
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("Bind error: %s", err)
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -223,10 +228,10 @@ func (e *SysMenu) DeleteSysMenu(c *gin.Context) {
|
||||
err = serviceSysMenu.RemoveSysMenu(control)
|
||||
if err != nil {
|
||||
log.Errorf("RemoveSysMenu error, %s", err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "删除失败")
|
||||
e.Error(http.StatusInternalServerError, err, "删除失败")
|
||||
return
|
||||
}
|
||||
e.OK(c, control.GetId(), "删除成功")
|
||||
e.OK(control.GetId(), "删除成功")
|
||||
}
|
||||
|
||||
// @Summary 根据角色名称获取菜单列表数据(左菜单使用)
|
||||
@@ -237,9 +242,10 @@ func (e *SysMenu) DeleteSysMenu(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "抱歉未找到相关信息"}"
|
||||
// @Router /api/v1/menurole [get]
|
||||
// @Security Bearer
|
||||
func (e *SysMenu) GetMenuRole(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysMenu) GetMenuRole(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -251,11 +257,11 @@ func (e *SysMenu) GetMenuRole(c *gin.Context) {
|
||||
result, err := serviceSysMenu.SetMenuRole(user.GetRoleName(c))
|
||||
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "查询失败")
|
||||
e.Error(http.StatusInternalServerError, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, result, "")
|
||||
e.OK(result, "")
|
||||
}
|
||||
|
||||
// @Summary 获取角色对应的菜单id数组
|
||||
@@ -266,9 +272,10 @@ func (e *SysMenu) GetMenuRole(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "抱歉未找到相关信息"}"
|
||||
// @Router /api/v1/menuids/{id} [get]
|
||||
// @Security Bearer
|
||||
func (e *SysMenu) GetMenuIDS(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysMenu) GetMenuIDS(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -279,14 +286,14 @@ func (e *SysMenu) GetMenuIDS(c *gin.Context) {
|
||||
result, err := data.GetIDS(db)
|
||||
if err != nil {
|
||||
log.Errorf("GetIDS error, %s", err.Error())
|
||||
e.Error(c, http.StatusInternalServerError, err, "获取失败")
|
||||
e.Error(http.StatusInternalServerError, err, "获取失败")
|
||||
return
|
||||
}
|
||||
e.OK(c, result, "")
|
||||
e.OK(result, "")
|
||||
}
|
||||
|
||||
//// GetMenuTreeRoleselect 角色修改中的菜单列表
|
||||
//func (e *SysMenu) GetMenuTreeRoleselect(c *gin.Context) {
|
||||
//func (e SysMenu) GetMenuTreeRoleselect(c *gin.Context) {
|
||||
// var Menu models.Menu
|
||||
// var SysRole models.SysRole
|
||||
//
|
||||
@@ -321,9 +328,10 @@ func (e *SysMenu) GetMenuIDS(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/menuTreeselect [get]
|
||||
// @Security Bearer
|
||||
func (e *SysMenu) GetMenuTreeSelect(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
db, err := e.GetOrm(c)
|
||||
func (e SysMenu) GetMenuTreeSelect(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -333,7 +341,7 @@ func (e *SysMenu) GetMenuTreeSelect(c *gin.Context) {
|
||||
|
||||
err = c.BindUri(d)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -342,7 +350,7 @@ func (e *SysMenu) GetMenuTreeSelect(c *gin.Context) {
|
||||
serviceSysMenu.Orm = db
|
||||
result, err := serviceSysMenu.SetSysMenuLabel()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
s := service.SysRole{}
|
||||
@@ -351,10 +359,10 @@ func (e *SysMenu) GetMenuTreeSelect(c *gin.Context) {
|
||||
menuIds, err := s.GetRoleMenuId(db, d.RoleId)
|
||||
if err != nil {
|
||||
log.Errorf("GetIDS error, %s", err.Error())
|
||||
e.Error(c, http.StatusInternalServerError, err, "")
|
||||
e.Error(http.StatusInternalServerError, err, "")
|
||||
return
|
||||
}
|
||||
e.OK(c, gin.H{
|
||||
e.OK(gin.H{
|
||||
"menus": result,
|
||||
"checkedKeys": menuIds,
|
||||
}, "获取成功")
|
||||
|
||||
@@ -16,10 +16,11 @@ type SysOperaLog struct {
|
||||
apis.Api
|
||||
}
|
||||
|
||||
func (e *SysOperaLog) GetSysOperaLogList(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysOperaLog) GetSysOperaLogList(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
d := new(dto.SysOperaLogSearch)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -28,7 +29,7 @@ func (e *SysOperaLog) GetSysOperaLogList(c *gin.Context) {
|
||||
//查询列表
|
||||
err = d.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -39,17 +40,18 @@ func (e *SysOperaLog) GetSysOperaLogList(c *gin.Context) {
|
||||
serviceStudent.Orm = db
|
||||
err = serviceStudent.GetSysOperaLogPage(d, &list, &count)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.PageOK(c, list, int(count), d.GetPageIndex(), d.GetPageSize(), "查询成功")
|
||||
e.PageOK(list, int(count), d.GetPageIndex(), d.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
func (e *SysOperaLog) GetSysOperaLog(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysOperaLog) GetSysOperaLog(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysOperaLogById)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -58,7 +60,7 @@ func (e *SysOperaLog) GetSysOperaLog(c *gin.Context) {
|
||||
//查看详情
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object system.SysOperaLog
|
||||
@@ -68,17 +70,18 @@ func (e *SysOperaLog) GetSysOperaLog(c *gin.Context) {
|
||||
serviceSysOperlog.Orm = db
|
||||
err = serviceSysOperlog.GetSysOperaLog(control, &object)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object, "查看成功")
|
||||
e.OK(object, "查看成功")
|
||||
}
|
||||
|
||||
func (e *SysOperaLog) InsertSysOperaLog(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysOperaLog) InsertSysOperaLog(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysOperaLogControl)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -87,12 +90,12 @@ func (e *SysOperaLog) InsertSysOperaLog(c *gin.Context) {
|
||||
//新增操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
// 设置创建人
|
||||
@@ -104,17 +107,18 @@ func (e *SysOperaLog) InsertSysOperaLog(c *gin.Context) {
|
||||
err = serviceSysOperaLog.InsertSysOperaLog(object)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "创建失败")
|
||||
e.Error(http.StatusInternalServerError, err, "创建失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object.GetId(), "创建成功")
|
||||
e.OK(object.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
func (e *SysOperaLog) UpdateSysOperaLog(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysOperaLog) UpdateSysOperaLog(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysOperaLogControl)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -123,12 +127,12 @@ func (e *SysOperaLog) UpdateSysOperaLog(c *gin.Context) {
|
||||
//更新操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
object.SetUpdateBy(user.GetUserId(c))
|
||||
@@ -141,13 +145,14 @@ func (e *SysOperaLog) UpdateSysOperaLog(c *gin.Context) {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "更新成功")
|
||||
e.OK(object.GetId(), "更新成功")
|
||||
}
|
||||
|
||||
func (e *SysOperaLog) DeleteSysOperaLog(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysOperaLog) DeleteSysOperaLog(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysOperaLogById)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -157,7 +162,7 @@ func (e *SysOperaLog) DeleteSysOperaLog(c *gin.Context) {
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("Bind error: %s", err)
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -169,5 +174,5 @@ func (e *SysOperaLog) DeleteSysOperaLog(c *gin.Context) {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
e.OK(c, control.GetId(), "删除成功")
|
||||
e.OK(control.GetId(), "删除成功")
|
||||
}
|
||||
@@ -27,10 +27,11 @@ type SysPost struct {
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/post [get]
|
||||
// @Security Bearer
|
||||
func (e *SysPost) GetSysPostList(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysPost) GetSysPostList(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
d := new(dto.SysPostSearch)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -39,7 +40,7 @@ func (e *SysPost) GetSysPostList(c *gin.Context) {
|
||||
//查询列表
|
||||
err = d.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -50,11 +51,11 @@ func (e *SysPost) GetSysPostList(c *gin.Context) {
|
||||
serviceStudent.Orm = db
|
||||
err = serviceStudent.GetSysPostPage(d, &list, &count)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.PageOK(c, list, int(count), d.GetPageIndex(), d.GetPageSize(), "查询成功")
|
||||
e.PageOK(list, int(count), d.GetPageIndex(), d.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
// @Summary 获取岗位信息
|
||||
@@ -64,10 +65,11 @@ func (e *SysPost) GetSysPostList(c *gin.Context) {
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/post/{postId} [get]
|
||||
// @Security Bearer
|
||||
func (e *SysPost) GetSysPost(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysPost) GetSysPost(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysPostById)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -76,7 +78,7 @@ func (e *SysPost) GetSysPost(c *gin.Context) {
|
||||
//查看详情
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object system.SysPost
|
||||
@@ -86,11 +88,11 @@ func (e *SysPost) GetSysPost(c *gin.Context) {
|
||||
serviceSysOperlog.Orm = db
|
||||
err = serviceSysOperlog.GetSysPost(control, &object)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object, "查看成功")
|
||||
e.OK(object, "查看成功")
|
||||
}
|
||||
|
||||
// @Summary 添加岗位
|
||||
@@ -103,10 +105,11 @@ func (e *SysPost) GetSysPost(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/post [post]
|
||||
// @Security Bearer
|
||||
func (e *SysPost) InsertSysPost(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysPost) InsertSysPost(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysPostControl)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -115,12 +118,12 @@ func (e *SysPost) InsertSysPost(c *gin.Context) {
|
||||
//新增操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
// 设置创建人
|
||||
@@ -132,11 +135,11 @@ func (e *SysPost) InsertSysPost(c *gin.Context) {
|
||||
err = serviceSysPost.InsertSysPost(object)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "创建失败")
|
||||
e.Error(http.StatusInternalServerError, err, "创建失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object.GetId(), "创建成功")
|
||||
e.OK(object.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
// @Summary 修改岗位
|
||||
@@ -149,10 +152,11 @@ func (e *SysPost) InsertSysPost(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/post/ [put]
|
||||
// @Security Bearer
|
||||
func (e *SysPost) UpdateSysPost(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysPost) UpdateSysPost(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysPostControl)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -161,12 +165,12 @@ func (e *SysPost) UpdateSysPost(c *gin.Context) {
|
||||
//更新操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
object.SetUpdateBy(user.GetUserId(c))
|
||||
@@ -179,7 +183,7 @@ func (e *SysPost) UpdateSysPost(c *gin.Context) {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "更新成功")
|
||||
e.OK(object.GetId(), "更新成功")
|
||||
}
|
||||
|
||||
// @Summary 删除岗位
|
||||
@@ -189,10 +193,11 @@ func (e *SysPost) UpdateSysPost(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 500 {string} string "{"code": 500, "message": "删除失败"}"
|
||||
// @Router /api/v1/post/{postId} [delete]
|
||||
func (e *SysPost) DeleteSysPost(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysPost) DeleteSysPost(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysPostById)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -202,7 +207,7 @@ func (e *SysPost) DeleteSysPost(c *gin.Context) {
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("Bind error: %s", err)
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -214,5 +219,5 @@ func (e *SysPost) DeleteSysPost(c *gin.Context) {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
e.OK(c, control.GetId(), "删除成功")
|
||||
e.OK(control.GetId(), "删除成功")
|
||||
}
|
||||
@@ -29,10 +29,11 @@ type SysRole struct {
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/role [get]
|
||||
// @Security Bearer
|
||||
func (e *SysRole) GetSysRoleList(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysRole) GetSysRoleList(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
d := new(dto.SysRoleSearch)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -41,7 +42,7 @@ func (e *SysRole) GetSysRoleList(c *gin.Context) {
|
||||
//查询列表
|
||||
err = d.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -52,11 +53,11 @@ func (e *SysRole) GetSysRoleList(c *gin.Context) {
|
||||
s.Orm = db
|
||||
err = s.GetSysRolePage(d, &list, &count)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.PageOK(c, list, int(count), d.GetPageIndex(), d.GetPageSize(), "查询成功")
|
||||
e.PageOK(list, int(count), d.GetPageIndex(), d.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
// @Summary 获取Role数据
|
||||
@@ -67,10 +68,11 @@ func (e *SysRole) GetSysRoleList(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "抱歉未找到相关信息"}"
|
||||
// @Router /api/v1/role/{id} [get]
|
||||
// @Security Bearer
|
||||
func (e *SysRole) GetSysRole(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysRole) GetSysRole(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysRoleById)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -79,7 +81,7 @@ func (e *SysRole) GetSysRole(c *gin.Context) {
|
||||
//查看详情
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object system.SysRole
|
||||
@@ -89,11 +91,11 @@ func (e *SysRole) GetSysRole(c *gin.Context) {
|
||||
s.Orm = db
|
||||
err = s.GetSysRole(control, &object)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(c, object, "查看成功")
|
||||
e.OK(object, "查看成功")
|
||||
}
|
||||
|
||||
// @Summary 创建角色
|
||||
@@ -106,10 +108,11 @@ func (e *SysRole) GetSysRole(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /api/v1/role [post]
|
||||
// @Security Bearer
|
||||
func (e *SysRole) InsertSysRole(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysRole) InsertSysRole(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysRoleControl)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -118,12 +121,12 @@ func (e *SysRole) InsertSysRole(c *gin.Context) {
|
||||
//新增操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
// 设置创建人
|
||||
@@ -138,15 +141,15 @@ func (e *SysRole) InsertSysRole(c *gin.Context) {
|
||||
err = s.InsertSysRole(object)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "创建失败")
|
||||
e.Error(http.StatusInternalServerError, err, "创建失败")
|
||||
return
|
||||
}
|
||||
_, err = global.LoadPolicy(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "")
|
||||
e.Error(http.StatusInternalServerError, err, "")
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "创建成功")
|
||||
e.OK(object.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
// @Summary 修改用户角色
|
||||
@@ -159,10 +162,11 @@ func (e *SysRole) InsertSysRole(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "修改失败"}"
|
||||
// @Router /api/v1/role/{id} [put]
|
||||
// @Security Bearer
|
||||
func (e *SysRole) UpdateSysRole(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysRole) UpdateSysRole(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysRoleControl)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -171,12 +175,12 @@ func (e *SysRole) UpdateSysRole(c *gin.Context) {
|
||||
//更新操作
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
object, err := control.Generate()
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
e.Error(http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
object.UpdateBy = user.GetUserId(c)
|
||||
@@ -191,10 +195,10 @@ func (e *SysRole) UpdateSysRole(c *gin.Context) {
|
||||
}
|
||||
_, err = global.LoadPolicy(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "")
|
||||
e.Error(http.StatusInternalServerError, err, "")
|
||||
return
|
||||
}
|
||||
e.OK(c, object.GetId(), "更新成功")
|
||||
e.OK(object.GetId(), "更新成功")
|
||||
}
|
||||
|
||||
// @Summary 删除用户角色
|
||||
@@ -205,10 +209,11 @@ func (e *SysRole) UpdateSysRole(c *gin.Context) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
||||
// @Router /api/v1/role [delete]
|
||||
// @Security Bearer
|
||||
func (e *SysRole) DeleteSysRole(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysRole) DeleteSysRole(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.SysRoleById)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -218,7 +223,7 @@ func (e *SysRole) DeleteSysRole(c *gin.Context) {
|
||||
err = control.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("Bind error: %s", err)
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -228,21 +233,22 @@ func (e *SysRole) DeleteSysRole(c *gin.Context) {
|
||||
err = s.RemoveSysRole(control)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
e.Error(c, http.StatusInternalServerError, err, "")
|
||||
e.Error(http.StatusInternalServerError, err, "")
|
||||
return
|
||||
}
|
||||
_, err = global.LoadPolicy(c)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "")
|
||||
e.Error(http.StatusInternalServerError, err, "")
|
||||
return
|
||||
}
|
||||
e.OK(c, control.GetId(), "删除成功")
|
||||
e.OK(control.GetId(), "删除成功")
|
||||
}
|
||||
|
||||
func (e *SysRole) UpdateRoleDataScope(c *gin.Context) {
|
||||
log := e.GetLogger(c)
|
||||
func (e SysRole) UpdateRoleDataScope(c *gin.Context) {
|
||||
e.Context = c
|
||||
log := e.GetLogger()
|
||||
control := new(dto.RoleDataScopeReq)
|
||||
db, err := e.GetOrm(c)
|
||||
db, err := e.GetOrm()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
@@ -252,7 +258,7 @@ func (e *SysRole) UpdateRoleDataScope(c *gin.Context) {
|
||||
err = c.Bind(control)
|
||||
if err != nil {
|
||||
log.Errorf("request bind error, %s", err.Error())
|
||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
e.Error(http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
data := &system.SysRole{
|
||||
@@ -266,8 +272,8 @@ func (e *SysRole) UpdateRoleDataScope(c *gin.Context) {
|
||||
s.Log = log
|
||||
err = s.UpdateDataScope(data)
|
||||
if err != nil {
|
||||
e.Error(c, http.StatusInternalServerError, err, "")
|
||||
e.Error(http.StatusInternalServerError, err, "")
|
||||
return
|
||||
}
|
||||
e.OK(c, nil, "操作成功")
|
||||
e.OK(nil, "操作成功")
|
||||
}
|
||||
Reference in new issue
Block a user