1
0

feat: 合并Gin_Vue

This commit is contained in:
TsMask
2023-10-16 20:04:08 +08:00
parent 55fe1d534d
commit 05c7e9b9e8
213 changed files with 20338 additions and 311 deletions

View File

@@ -9,13 +9,13 @@ import (
sysRoleService "ems.agt/features/sys_role/service"
sysUserModel "ems.agt/features/sys_user/model"
"ems.agt/features/sys_user/service"
"ems.agt/lib/core/conf"
"ems.agt/lib/core/utils/ctx"
"ems.agt/lib/core/utils/parse"
"ems.agt/lib/core/vo/result"
"ems.agt/lib/midware"
"ems.agt/lib/services"
"ems.agt/restagent/config"
srcConfig "ems.agt/src/framework/config"
)
// 用户接口添加到路由
@@ -107,14 +107,14 @@ func (s *SysUserApi) List(w http.ResponseWriter, r *http.Request) {
func (s *SysUserApi) Info(w http.ResponseWriter, r *http.Request) {
userId := ctx.Param(r, "userId")
if userId == "" {
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
return
}
// 查询系统角色列表
roles := s.sysRoleService.SelectRoleList(sysRoleModel.SysRole{})
// 不是系统指定管理员需要排除其角色
if !conf.IsAdmin(userId) {
if !srcConfig.IsAdmin(userId) {
rolesFilter := make([]sysRoleModel.SysRole, 0)
for _, r := range roles {
if r.RoleID != "1" {
@@ -137,7 +137,7 @@ func (s *SysUserApi) Info(w http.ResponseWriter, r *http.Request) {
// 检查用户是否存在
user := s.sysUserService.SelectUserById(userId)
if user.Id != userId {
ctx.JSON(w, 200, result.ErrMsg("没有权限访问用户数据!"))
ctx.JSON(w, 200, result.ErrMsg("No permission to access user data!"))
return
}
@@ -161,14 +161,14 @@ func (s *SysUserApi) Add(w http.ResponseWriter, r *http.Request) {
var body sysUserModel.SysUser
err := ctx.ShouldBindJSON(r, &body)
if err != nil || body.Id != "" {
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
return
}
// 检查用户登录账号是否唯一
uniqueUserName := s.sysUserService.CheckUniqueUserName(body.AccountId, "")
if !uniqueUserName {
msg := fmt.Sprintf("新增用户【%s】失败登录账号已存在", body.AccountId)
msg := fmt.Sprintf("[%s] Login account already exists", body.AccountId)
ctx.JSON(w, 200, result.ErrMsg(msg))
return
}
@@ -188,26 +188,26 @@ func (s *SysUserApi) Edit(w http.ResponseWriter, r *http.Request) {
var body sysUserModel.SysUser
err := ctx.ShouldBindJSON(r, &body)
if err != nil || body.Id == "" {
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
return
}
// 检查是否管理员用户
// if conf.IsAdmin(body.Id) {
// if srcConfig.IsAdmin(body.Id) {
// ctx.JSON(w, 200, result.ErrMsg("不允许操作管理员用户"))
// return
// }
user := s.sysUserService.SelectUserById(body.Id)
if user.Id != body.Id {
ctx.JSON(w, 200, result.ErrMsg("没有权限访问用户数据!"))
ctx.JSON(w, 200, result.ErrMsg("No permission to access user data!"))
return
}
// 检查用户登录账号是否唯一
uniqueUserName := s.sysUserService.CheckUniqueUserName(body.AccountId, body.Id)
if !uniqueUserName {
msg := fmt.Sprintf("修改用户【%s】失败登录账号已存在", body.AccountId)
msg := fmt.Sprintf("[%s] Login account already exists", body.AccountId)
ctx.JSON(w, 200, result.ErrMsg(msg))
return
}
@@ -228,7 +228,7 @@ func (s *SysUserApi) Edit(w http.ResponseWriter, r *http.Request) {
func (s *SysUserApi) Remove(w http.ResponseWriter, r *http.Request) {
userIds := ctx.Param(r, "userIds")
if userIds == "" {
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
return
}
// 处理字符转id数组后去重
@@ -243,7 +243,7 @@ func (s *SysUserApi) Remove(w http.ResponseWriter, r *http.Request) {
ctx.JSON(w, 200, result.ErrMsg(err.Error()))
return
}
msg := fmt.Sprintf("删除成功:%d", rows)
msg := fmt.Sprintf("Successfully deleted: %d", rows)
ctx.JSON(w, 200, result.OkMsg(msg))
}
@@ -256,19 +256,19 @@ func (s *SysUserApi) ResetPwd(w http.ResponseWriter, r *http.Request) {
Password string `json:"password" binding:"required"`
}
if err := ctx.ShouldBindJSON(r, &body); err != nil {
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
return
}
// 检查是否管理员用户
if conf.IsAdmin(body.UserID) {
ctx.JSON(w, 200, result.ErrMsg("不允许操作管理员用户"))
if srcConfig.IsAdmin(body.UserID) {
ctx.JSON(w, 200, result.ErrMsg("No permission to access user data!"))
return
}
user := s.sysUserService.SelectUserById(body.UserID)
if user.Id != body.UserID {
ctx.JSON(w, 200, result.ErrMsg("没有权限访问用户数据!"))
ctx.JSON(w, 200, result.ErrMsg("No permission to access user data!"))
return
}
@@ -293,20 +293,20 @@ func (s *SysUserApi) Status(w http.ResponseWriter, r *http.Request) {
Status string `json:"status" binding:"required"`
}
if err := ctx.ShouldBindJSON(r, &body); err != nil {
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
return
}
// 检查是否存在
user := s.sysUserService.SelectUserById(body.UserID)
if user.Id != body.UserID {
ctx.JSON(w, 200, result.ErrMsg("没有权限访问用户数据!"))
ctx.JSON(w, 200, result.ErrMsg("No permission to access user data!"))
return
}
// 与旧值相等不变更
if user.Status == body.Status {
ctx.JSON(w, 200, result.ErrMsg("变更状态与旧值相等!"))
ctx.JSON(w, 200, result.ErrMsg("Change status equals old value!"))
return
}

View File

@@ -8,10 +8,10 @@ import (
sysRoleModel "ems.agt/features/sys_role/model"
sysUserModel "ems.agt/features/sys_user/model"
"ems.agt/lib/core/datasource"
"ems.agt/lib/core/utils/crypto"
"ems.agt/lib/core/utils/date"
"ems.agt/lib/core/utils/parse"
"ems.agt/lib/log"
"ems.agt/src/framework/utils/crypto"
)
// 实例化数据层 RepoSysUser 结构体