Commit dac54b71 authored by 黄智's avatar 黄智

新增用户更新状态接口

parent cd9bb6ae
...@@ -4,7 +4,7 @@ import ( ...@@ -4,7 +4,7 @@ import (
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
) )
type DictionaryBase struct { type DictBase struct {
Id string `json:"id" xorm:"pk autoincr" ` //id Id string `json:"id" xorm:"pk autoincr" ` //id
Class int `json:"class"` //菜单分组id Class int `json:"class"` //菜单分组id
Name string `json:"name" ` //字典名称 Name string `json:"name" ` //字典名称
...@@ -22,7 +22,7 @@ type DictionaryBase struct { ...@@ -22,7 +22,7 @@ type DictionaryBase struct {
Sort int64 `json:"sort" ` //排序字段 降序排列 Sort int64 `json:"sort" ` //排序字段 降序排列
} }
type ComponentDict struct { type Dict struct {
Id string `json:"id" xorm:"id"` //主键ID Id string `json:"id" xorm:"id"` //主键ID
Class int `json:"class" xorm:"class"` //组件分类(1开发语言与版本 2中间件类型与中间件 3云组件类型 4模块类型 5所属区域 6操作系统 7对象类型 8SQL类型 9调研评估结果 10任务阶段 11测试文档类型 12验收问题类型 13Q&A问题类型 14文档类型) Class int `json:"class" xorm:"class"` //组件分类(1开发语言与版本 2中间件类型与中间件 3云组件类型 4模块类型 5所属区域 6操作系统 7对象类型 8SQL类型 9调研评估结果 10任务阶段 11测试文档类型 12验收问题类型 13Q&A问题类型 14文档类型)
Name string `json:"name" xorm:"name"` //组件名称 Name string `json:"name" xorm:"name"` //组件名称
...@@ -40,15 +40,15 @@ type ComponentDict struct { ...@@ -40,15 +40,15 @@ type ComponentDict struct {
Sort int `json:"sort" xorm:"sort autoincr"` //排序字段 降序排列 Sort int `json:"sort" xorm:"sort autoincr"` //排序字段 降序排列
} }
func (c ComponentDict) TableName() string { func (c Dict) TableName() string {
return "dict" return "dict"
} }
type ComponentDictClass struct { type DictClass struct {
ClassId int `json:"class_id" xorm:"class_id"` //字典类别id ClassId int `json:"class_id" xorm:"class_id"` //字典类别id
ClassName string `json:"class_name" xorm:"class_name"` //字典类别名称 ClassName string `json:"class_name" xorm:"class_name"` //字典类别名称
} }
func (c ComponentDictClass) TableName() string { func (c DictClass) TableName() string {
return "dict_class" return "dict_class"
} }
...@@ -2,18 +2,19 @@ package request ...@@ -2,18 +2,19 @@ package request
import "gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime" import "gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
type ComponentDictReq struct { type DictReq struct {
Id string `json:"id" form:"id"` //主键ID Id string `json:"id" form:"id"` //主键ID
Status int `json:"status" form:"status"`
Class int `json:"class" form:"class" binding:"oneof=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14"` //组件分类(1开发语言与版本 2中间件类型与中间件 3云组件类型 4模块类型 5所属区域 6操作系统 7对象类型 8SQL类型 9调研评估结果 10任务阶段 11测试文档类型 12验收问题类型 13Q&A问题类型 14文档类型) Class int `json:"class" form:"class" binding:"oneof=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14"` //组件分类(1开发语言与版本 2中间件类型与中间件 3云组件类型 4模块类型 5所属区域 6操作系统 7对象类型 8SQL类型 9调研评估结果 10任务阶段 11测试文档类型 12验收问题类型 13Q&A问题类型 14文档类型)
ParentId string `json:"parent_id" form:"parent_id"` //父级ID ParentId string `json:"parent_id" form:"parent_id"` //父级ID
} }
type ComponentDictTreeReq struct { type DictTreeReq struct {
Class int `json:"class" form:"class" binding:"oneof=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14"` //组件分类(1开发语言与版本 2中间件类型与中间件 3云组件类型 4模块类型 5所属区域 6操作系统 7对象类型 8SQL类型 9调研评估结果 10任务阶段 11测试文档类型 12验收问题类型 13Q&A问题类型 14文档类型) Class int `json:"class" form:"class" binding:"oneof=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14"` //组件分类(1开发语言与版本 2中间件类型与中间件 3云组件类型 4模块类型 5所属区域 6操作系统 7对象类型 8SQL类型 9调研评估结果 10任务阶段 11测试文档类型 12验收问题类型 13Q&A问题类型 14文档类型)
ParentId string `json:"parent_id" form:"parent_id"` //父级ID ParentId string `json:"parent_id" form:"parent_id"` //父级ID
} }
type AddComponentDictReq struct { type AddDictReq struct {
Class int `json:"class" form:"class" binding:"required,oneof=1 2 3 4 5 6 7 8 9 10 11 12 13 14"` //组件分类(1开发语言与版本 2中间件类型与中间件 3云组件类型 4模块类型 5所属区域 6操作系统 7对象类型 8SQL类型 9调研评估结果 10任务阶段 11测试文档类型 12验收问题类型 13Q&A问题类型 14文档类型) Class int `json:"class" form:"class" binding:"required,oneof=1 2 3 4 5 6 7 8 9 10 11 12 13 14"` //组件分类(1开发语言与版本 2中间件类型与中间件 3云组件类型 4模块类型 5所属区域 6操作系统 7对象类型 8SQL类型 9调研评估结果 10任务阶段 11测试文档类型 12验收问题类型 13Q&A问题类型 14文档类型)
ParentId string `json:"parent_id" form:"parent_id"` //父级ID ParentId string `json:"parent_id" form:"parent_id"` //父级ID
Name string `json:"name" form:"name" binding:"required"` //字典标签 Name string `json:"name" form:"name" binding:"required"` //字典标签
...@@ -23,7 +24,7 @@ type AddComponentDictReq struct { ...@@ -23,7 +24,7 @@ type AddComponentDictReq struct {
MaxVal string `json:"max_val" form:"max_val"` //最小值 MaxVal string `json:"max_val" form:"max_val"` //最小值
} }
type UpdateComponentDictReq struct { type UpdateDictReq struct {
Id string `json:"id" form:"id" binding:"required"` //组件ID Id string `json:"id" form:"id" binding:"required"` //组件ID
ParentId string `json:"parent_id" form:"parent_id"` //父级ID ParentId string `json:"parent_id" form:"parent_id"` //父级ID
Name string `json:"name" form:"name" binding:"required"` //字典标签 Name string `json:"name" form:"name" binding:"required"` //字典标签
......
...@@ -43,8 +43,8 @@ type SystemUserDetailReq struct { ...@@ -43,8 +43,8 @@ type SystemUserDetailReq struct {
Id string `json:"id" form:"id" vd:"len($)>0;msg:'请输入id'"` // id Id string `json:"id" form:"id" vd:"len($)>0;msg:'请输入id'"` // id
} }
type SystemUserStateReq struct { type SystemUserStateReq struct {
Id string `json:"id" form:"id" vd:"len($)>0;msg:'请输入id'"` // id Id int `json:"id" form:"id" vd:"len($)>0;msg:'请输入id'"` // id
State string `json:"state" vd:"len($)>0;msg:'请填写状态'"` // Id State int `json:"state" vd:"len($)>0;msg:'请填写状态'"` // Id
} }
type SystemUserEditPasswordReq struct { type SystemUserEditPasswordReq struct {
Id int `json:"id" form:"id" vd:"$>0;msg:'请输入id'"` // id Id int `json:"id" form:"id" vd:"$>0;msg:'请输入id'"` // id
......
package response package response
type ComponentDictListRes struct { type DictListRes struct {
Id string `json:"id" column:"id"` //主键ID Id string `json:"id" column:"id"` //主键ID
Class int `json:"class" column:"class"` //组件分类(1开发语言与版本 2中间件类型与中间件 3云组件类型 4模块类型 5所属区域 6操作系统 7对象类型 8SQL类型 9调研评估结果 10任务阶段 11测试文档类型 12验收问题类型 13Q&A问题类型 14文档类型) Class int `json:"class" column:"class"` //组件分类(1开发语言与版本 2中间件类型与中间件 3云组件类型 4模块类型 5所属区域 6操作系统 7对象类型 8SQL类型 9调研评估结果 10任务阶段 11测试文档类型 12验收问题类型 13Q&A问题类型 14文档类型)
Name string `json:"name" column:"name"` //组件名称 Name string `json:"name" column:"name"` //组件名称
ParentId string `json:"parent_id" column:"parent_id"` //父id ParentId string `json:"parent_id" column:"parent_id"` //父id
Children []*ComponentDictListRes `json:"children,omitempty"` Status int `json:"status"`
MinVal string `json:"min_val" ` //最大值
MaxVal string `json:"max_val"`
Sort int `json:"sort"`
Children []*DictListRes `json:"children,omitempty"`
} }
//type ComponentDictTreeRes struct { //type ComponentDictTreeRes struct {
......
...@@ -10,14 +10,14 @@ import ( ...@@ -10,14 +10,14 @@ import (
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/service" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/service"
) )
type ComponentDict struct{} type Dict struct{}
// List 组件列表 // List 组件列表
func (d ComponentDict) List(c *gin.Context) { func (d Dict) List(c *gin.Context) {
var ( var (
err error err error
req request.ComponentDictReq req request.DictReq
) )
if err = c.ShouldBind(&req); err != nil { if err = c.ShouldBind(&req); err != nil {
...@@ -25,26 +25,24 @@ func (d ComponentDict) List(c *gin.Context) { ...@@ -25,26 +25,24 @@ func (d ComponentDict) List(c *gin.Context) {
return return
} }
//user, _ := header.GetUserContext(c) svc := new(service.Dict)
svc := new(service.ComponentDict)
svc.Ctx = c svc.Ctx = c
svc.User = header.GetUser(c) svc.User = header.GetUser(c)
componentDict, err := svc.List(req) result, err := svc.List(req)
if err != nil { if err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), "") SendJsonResponse(c, resp.InvalidParam.WithError(err), "")
return return
} }
SendJsonResponse(c, resp.OK, componentDict) SendJsonResponse(c, resp.OK, result)
} }
// DictTree 字典列表-树结构 // DictTree 字典列表-树结构
func (d ComponentDict) DictTree(c *gin.Context) { func (d Dict) DictTree(c *gin.Context) {
var ( var (
err error err error
req request.ComponentDictTreeReq req request.DictTreeReq
) )
if err = c.ShouldBind(&req); err != nil { if err = c.ShouldBind(&req); err != nil {
...@@ -54,7 +52,7 @@ func (d ComponentDict) DictTree(c *gin.Context) { ...@@ -54,7 +52,7 @@ func (d ComponentDict) DictTree(c *gin.Context) {
//user, _ := header.GetUserContext(c) //user, _ := header.GetUserContext(c)
svc := new(service.ComponentDict) svc := new(service.Dict)
svc.Ctx = c svc.Ctx = c
componentDictTreeRes, err := svc.DictTree(req) componentDictTreeRes, err := svc.DictTree(req)
...@@ -67,11 +65,11 @@ func (d ComponentDict) DictTree(c *gin.Context) { ...@@ -67,11 +65,11 @@ func (d ComponentDict) DictTree(c *gin.Context) {
} }
// Add 新增字典 // Add 新增字典
func (d ComponentDict) Add(c *gin.Context) { func (d Dict) Add(c *gin.Context) {
var ( var (
err error err error
req request.AddComponentDictReq req request.AddDictReq
) )
if err = c.ShouldBind(&req); err != nil { if err = c.ShouldBind(&req); err != nil {
...@@ -79,7 +77,7 @@ func (d ComponentDict) Add(c *gin.Context) { ...@@ -79,7 +77,7 @@ func (d ComponentDict) Add(c *gin.Context) {
return return
} }
svc := new(service.ComponentDict) svc := new(service.Dict)
svc.Ctx = c svc.Ctx = c
svc.User = header.GetUser(c) svc.User = header.GetUser(c)
...@@ -93,11 +91,11 @@ func (d ComponentDict) Add(c *gin.Context) { ...@@ -93,11 +91,11 @@ func (d ComponentDict) Add(c *gin.Context) {
} }
// Update 修改字典 // Update 修改字典
func (d ComponentDict) Update(c *gin.Context) { func (d Dict) Update(c *gin.Context) {
var ( var (
err error err error
req request.UpdateComponentDictReq req request.UpdateDictReq
) )
if err = c.ShouldBind(&req); err != nil { if err = c.ShouldBind(&req); err != nil {
...@@ -105,7 +103,7 @@ func (d ComponentDict) Update(c *gin.Context) { ...@@ -105,7 +103,7 @@ func (d ComponentDict) Update(c *gin.Context) {
return return
} }
svc := new(service.ComponentDict) svc := new(service.Dict)
svc.Ctx = c svc.Ctx = c
svc.User = header.GetUser(c) svc.User = header.GetUser(c)
...@@ -119,7 +117,7 @@ func (d ComponentDict) Update(c *gin.Context) { ...@@ -119,7 +117,7 @@ func (d ComponentDict) Update(c *gin.Context) {
} }
// Del 删除字典 // Del 删除字典
func (d ComponentDict) Del(c *gin.Context) { func (d Dict) Del(c *gin.Context) {
var ( var (
err error err error
...@@ -135,7 +133,7 @@ func (d ComponentDict) Del(c *gin.Context) { ...@@ -135,7 +133,7 @@ func (d ComponentDict) Del(c *gin.Context) {
return return
} }
svc := new(service.ComponentDict) svc := new(service.Dict)
svc.Ctx = c svc.Ctx = c
//svc.User = &user //svc.User = &user
...@@ -149,7 +147,7 @@ func (d ComponentDict) Del(c *gin.Context) { ...@@ -149,7 +147,7 @@ func (d ComponentDict) Del(c *gin.Context) {
} }
// List 组件列表 // List 组件列表
func (d ComponentDict) ClassList(c *gin.Context) { func (d Dict) ClassList(c *gin.Context) {
var ( var (
err error err error
...@@ -160,9 +158,9 @@ func (d ComponentDict) ClassList(c *gin.Context) { ...@@ -160,9 +158,9 @@ func (d ComponentDict) ClassList(c *gin.Context) {
className = c.Param("class_name") className = c.Param("class_name")
} }
svc := new(service.ComponentDict) svc := new(service.Dict)
svc.Ctx = c svc.Ctx = c
//svc.User = &user svc.User = header.GetUser(c)
classList, err := svc.ClassList(className) classList, err := svc.ClassList(className)
if err != nil { if err != nil {
SendJsonResponse(c, resp.FAIL.WithError(err), "") SendJsonResponse(c, resp.FAIL.WithError(err), "")
...@@ -173,29 +171,29 @@ func (d ComponentDict) ClassList(c *gin.Context) { ...@@ -173,29 +171,29 @@ func (d ComponentDict) ClassList(c *gin.Context) {
} }
// List 组件列表 // List 组件列表
func (d ComponentDict) ManageList(c *gin.Context) { //func (d Dict) ManageList(c *gin.Context) {
//
var ( // var (
err error // err error
req request.DictManageListReq // req request.DictManageListReq
) // )
//
if err = c.ShouldBind(&req); err != nil { // if err = c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), "") // SendJsonResponse(c, resp.InvalidParam.WithError(err), "")
return // return
} // }
//svc := new(service.ComponentDict) //svc := new(service.Dict)
//svc.Ctx = c //svc.Ctx = c
////svc.User = &user ////svc.User = &user
//manageList, err := svc.ManageList(req) //manageList, err := svc.ManageList(req)
//if err != nil { //if err != nil {
// resp.Json(c, resp.FAIL.WithMsg(err.Error())) // resp.Json(c, resp.FAIL.WithMsg(err.Error()))
// return // return
//} //}
// //
//resp.Json(c, resp.OK.WithData(manageList)) //resp.Json(c, resp.OK.WithData(manageList))
//
SendJsonResponse(c, resp.OK, nil) // SendJsonResponse(c, resp.OK, nil)
//
} //}
...@@ -162,3 +162,19 @@ func ResetSystemUserPassword(c *gin.Context) { ...@@ -162,3 +162,19 @@ func ResetSystemUserPassword(c *gin.Context) {
} }
SendJsonResponse(c, resp.OK, nil) SendJsonResponse(c, resp.OK, nil)
} }
func SystemUserUpdateState(c *gin.Context) {
params := request.SystemUserStateReq{}
if err := c.ShouldBindJSON(&params); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil)
return
}
svc := service.User{User: header.GetUser(c)}
err := svc.SystemUserUpdateState(params)
if err != nil {
SendJsonResponse(c, err, nil)
return
}
SendJsonResponse(c, resp.OK, nil)
}
...@@ -14,13 +14,13 @@ func initDictRoute(e *gin.Engine) { ...@@ -14,13 +14,13 @@ func initDictRoute(e *gin.Engine) {
//系统字典 //系统字典
componentDictController := new(controller.ComponentDict) dict := new(controller.Dict)
base.POST("", componentDictController.Add) //新增字典 base.POST("", dict.Add) //新增字典
base.PUT("", componentDictController.Update) //修改字典 base.PUT("", dict.Update) //修改字典
base.DELETE("", componentDictController.Del) //删除字典 base.DELETE("", dict.Del) //删除字典
base.GET("", componentDictController.List) //字典列表 base.GET("", dict.List) //字典列表
base.GET("/dict_tree", componentDictController.DictTree) //字典列表-树结构 base.GET("/tree", dict.DictTree) //字典列表-树结构
base.GET("/class_list", componentDictController.ClassList) //字典分类列表 base.GET("/classList", dict.ClassList) //字典分类列表
base.GET("/manage_list", componentDictController.ManageList) //字典管理列表 //base.GET("/manage_list", dict.ManageList) //字典管理列表
} }
...@@ -43,6 +43,8 @@ func Load(r *gin.Engine, middleware ...gin.HandlerFunc) { ...@@ -43,6 +43,8 @@ func Load(r *gin.Engine, middleware ...gin.HandlerFunc) {
InitSystemRoleRouter(r) InitSystemRoleRouter(r)
// 初始化菜单相关路由(r) // 初始化菜单相关路由(r)
InitSystemMenuRouter(r) InitSystemMenuRouter(r)
// 初始化字典相关路由(r)
initDictRoute(r)
// 初始化指标配置路由 // 初始化指标配置路由
InitMetricConfigRouter(r) InitMetricConfigRouter(r)
// 初始化预警规则配置路由 // 初始化预警规则配置路由
......
...@@ -24,6 +24,7 @@ func InitSystemUserRouter(e *gin.Engine) { ...@@ -24,6 +24,7 @@ func InitSystemUserRouter(e *gin.Engine) {
base.POST("/updatePwd", controller.SystemUserEditPassword) // 修改账户密码 base.POST("/updatePwd", controller.SystemUserEditPassword) // 修改账户密码
base.POST("/resetPwd", controller.ResetSystemUserPassword) // 重置账户密码 base.POST("/resetPwd", controller.ResetSystemUserPassword) // 重置账户密码
base.POST("/updateState", controller.SystemUserUpdateState) // 重置账户密码
} }
} }
...@@ -15,12 +15,12 @@ import ( ...@@ -15,12 +15,12 @@ import (
"time" "time"
) )
type ComponentDict struct { type Dict struct {
Ctx *gin.Context Ctx *gin.Context
User entity.SystemUserInfo User entity.SystemUserInfo
} }
func (c *ComponentDict) Check(id, parentId string, name string) (err error) { func (c *Dict) Check(id, parentId string, name string) (err error) {
db, err := client.GetDbClient() db, err := client.GetDbClient()
if err != nil { if err != nil {
...@@ -34,7 +34,7 @@ func (c *ComponentDict) Check(id, parentId string, name string) (err error) { ...@@ -34,7 +34,7 @@ func (c *ComponentDict) Check(id, parentId string, name string) (err error) {
session.Where("id != ?", id) session.Where("id != ?", id)
} }
cnt, err := session.Count(&entity.ComponentDict{}) cnt, err := session.Count(&entity.Dict{})
if err != nil { if err != nil {
err = errors.Wrap(err, "数据库查重失败!") err = errors.Wrap(err, "数据库查重失败!")
return return
...@@ -52,17 +52,17 @@ func (c *ComponentDict) Check(id, parentId string, name string) (err error) { ...@@ -52,17 +52,17 @@ func (c *ComponentDict) Check(id, parentId string, name string) (err error) {
return return
} }
func (c *ComponentDict) List(req request.ComponentDictReq) (componentDictListRes []*response.ComponentDictListRes, err error) { func (c *Dict) List(req request.DictReq) (dictListRes []*response.DictListRes, err error) {
db, err := client.GetDbClient() db, err := client.GetDbClient()
if err != nil { if err != nil {
err = resp.DbConnectError.WithError(err) err = resp.DbConnectError.WithError(err)
return componentDictListRes, err return dictListRes, err
} }
session := db.NewSession() session := db.NewSession()
session.Select("id,class,name,parent_id").Table("dict") session.Select("id,class,name,parent_id,status,min_val,max_val,sort").Table("dict")
session.Where("WHERE status = 0 AND is_delete = 0 ") session.Where("is_delete = 0 ")
if req.Id != "" { if req.Id != "" {
session.Where("id = ? ", req.Id) session.Where("id = ? ", req.Id)
...@@ -73,16 +73,19 @@ func (c *ComponentDict) List(req request.ComponentDictReq) (componentDictListRes ...@@ -73,16 +73,19 @@ func (c *ComponentDict) List(req request.ComponentDictReq) (componentDictListRes
if req.Class != 0 { if req.Class != 0 {
session.Where("class = ? ", req.Class) session.Where("class = ? ", req.Class)
} }
if req.Status != 0 {
session.Where("status = ? ", req.Status)
}
err = session.OrderBy(" name").Find(&componentDictListRes) err = session.OrderBy(" class,sort").Find(&dictListRes)
if err != nil { if err != nil {
return componentDictListRes, resp.DbSelectError return dictListRes, resp.DbSelectError.WithError(err)
} }
return return
} }
func (c *ComponentDict) DictTree(req request.ComponentDictTreeReq) (componentDictTreeRes []*response.ComponentDictListRes, err error) { func (c *Dict) DictTree(req request.DictTreeReq) (componentDictTreeRes []*response.DictListRes, err error) {
listReq := request.ComponentDictReq{ listReq := request.DictReq{
Class: req.Class, Class: req.Class,
ParentId: "", ParentId: "",
} }
...@@ -96,27 +99,27 @@ func (c *ComponentDict) DictTree(req request.ComponentDictTreeReq) (componentDic ...@@ -96,27 +99,27 @@ func (c *ComponentDict) DictTree(req request.ComponentDictTreeReq) (componentDic
return return
} }
func getTreeIterative(list []*response.ComponentDictListRes, parentId string) []*response.ComponentDictListRes { func getTreeIterative(list []*response.DictListRes, parentId string) []*response.DictListRes {
memo := make(map[string]*response.ComponentDictListRes) memo := make(map[string]*response.DictListRes)
for _, v := range list { for _, v := range list {
if _, ok := memo[v.Id]; ok { if _, ok := memo[v.Id]; ok {
v.Children = memo[v.Id].Children v.Children = memo[v.Id].Children
memo[v.Id] = v memo[v.Id] = v
} else { } else {
v.Children = make([]*response.ComponentDictListRes, 0) v.Children = make([]*response.DictListRes, 0)
memo[v.Id] = v memo[v.Id] = v
} }
if _, ok := memo[v.ParentId]; ok { if _, ok := memo[v.ParentId]; ok {
memo[v.ParentId].Children = append(memo[v.ParentId].Children, memo[v.Id]) memo[v.ParentId].Children = append(memo[v.ParentId].Children, memo[v.Id])
} else { } else {
memo[v.ParentId] = &response.ComponentDictListRes{Children: []*response.ComponentDictListRes{memo[v.Id]}} memo[v.ParentId] = &response.DictListRes{Children: []*response.DictListRes{memo[v.Id]}}
} }
} }
return memo[parentId].Children return memo[parentId].Children
} }
func (c *ComponentDict) Add(req request.AddComponentDictReq) (err error) { func (c *Dict) Add(req request.AddDictReq) (err error) {
//检查重复 //检查重复
err = c.Check("", req.ParentId, req.Name) err = c.Check("", req.ParentId, req.Name)
...@@ -124,7 +127,7 @@ func (c *ComponentDict) Add(req request.AddComponentDictReq) (err error) { ...@@ -124,7 +127,7 @@ func (c *ComponentDict) Add(req request.AddComponentDictReq) (err error) {
return return
} }
componentDict := &entity.ComponentDict{ componentDict := &entity.Dict{
Id: util.GetUUID(), Id: util.GetUUID(),
Class: req.Class, Class: req.Class,
Name: req.Name, Name: req.Name,
...@@ -155,7 +158,7 @@ func (c *ComponentDict) Add(req request.AddComponentDictReq) (err error) { ...@@ -155,7 +158,7 @@ func (c *ComponentDict) Add(req request.AddComponentDictReq) (err error) {
} }
func (c *ComponentDict) Update(req request.UpdateComponentDictReq) (err error) { func (c *Dict) Update(req request.UpdateDictReq) (err error) {
//检查重复 //检查重复
err = c.Check(req.Id, req.ParentId, req.Name) err = c.Check(req.Id, req.ParentId, req.Name)
...@@ -184,7 +187,7 @@ func (c *ComponentDict) Update(req request.UpdateComponentDictReq) (err error) { ...@@ -184,7 +187,7 @@ func (c *ComponentDict) Update(req request.UpdateComponentDictReq) (err error) {
} }
func (c *ComponentDict) Del(id int) (err error) { func (c *Dict) Del(id int) (err error) {
db, err := client.GetDbClient() db, err := client.GetDbClient()
if err != nil { if err != nil {
...@@ -207,7 +210,7 @@ func (c *ComponentDict) Del(id int) (err error) { ...@@ -207,7 +210,7 @@ func (c *ComponentDict) Del(id int) (err error) {
} }
func (c *ComponentDict) ClassList(className string) (classList []response.ClassListRes, err error) { func (c *Dict) ClassList(className string) (classList []response.ClassListRes, err error) {
db, err := client.GetDbClient() db, err := client.GetDbClient()
if err != nil { if err != nil {
...@@ -221,7 +224,7 @@ func (c *ComponentDict) ClassList(className string) (classList []response.ClassL ...@@ -221,7 +224,7 @@ func (c *ComponentDict) ClassList(className string) (classList []response.ClassL
session.Where("class_name like ?", "%"+className+"%") session.Where("class_name like ?", "%"+className+"%")
} }
session.OrderBy("class_name") session.OrderBy("class_id")
//执行查询 //执行查询
err = session.Table("dict_class").Find(&classList) err = session.Table("dict_class").Find(&classList)
...@@ -232,13 +235,12 @@ func (c *ComponentDict) ClassList(className string) (classList []response.ClassL ...@@ -232,13 +235,12 @@ func (c *ComponentDict) ClassList(className string) (classList []response.ClassL
return return
} }
// //func (c *Dict) ManageList(req request.DictManageListReq) (componentDictTreeRes []*response.DictListRes, err error) {
//func (c *ComponentDict) ManageList(req request.DictManageListReq) (componentDictTreeRes []*response.ComponentDictListRes, err error) { // listReq := request.DictReq{
// listReq := request.ComponentDictReq{
// Class: req.Class, // Class: req.Class,
// ParentId: -1, // ParentId: -1,
// } // }
// componentDictList, err := c.ist(listReq) // componentDictList, err := c.list(listReq)
// if err != nil { // if err != nil {
// return // return
// } // }
...@@ -247,10 +249,10 @@ func (c *ComponentDict) ClassList(className string) (classList []response.ClassL ...@@ -247,10 +249,10 @@ func (c *ComponentDict) ClassList(className string) (classList []response.ClassL
// //
// return // return
//} //}
//func (c *Dict) list(req request.DictReq) (componentDictListRes []*response.DictListRes, err error) {
// //
//func (c *ComponentDict) list(req request.ComponentDictReq) (componentDictListRes []*response.ComponentDictListRes, err error) { // finder := zorm.NewFinder().Append("select id,class,name,parent_id from " + new(entity.Dict).GetTableName())
//
// finder := zorm.NewFinder().Append("select id,class,name,parent_id from " + new(entity.ComponentDict).GetTableName())
// finder.Append("WHERE status = 0 AND is_delete = 0 ") // finder.Append("WHERE status = 0 AND is_delete = 0 ")
// //
// if req.Id != 0 { // if req.Id != 0 {
......
...@@ -283,7 +283,7 @@ func (s *SystemMenu) GetGroupDict() (interface{}, error) { ...@@ -283,7 +283,7 @@ func (s *SystemMenu) GetGroupDict() (interface{}, error) {
if err != nil { if err != nil {
return nil, resp.DbConnectError.ErrorDetail(err) return nil, resp.DbConnectError.ErrorDetail(err)
} }
dict := make([]entity.DictionaryBase, 0) dict := make([]entity.DictBase, 0)
err = db.Table("dict").Where("is_delete = 0 and status = 1").And("class = 4").Find(&dict) err = db.Table("dict").Where("is_delete = 0 and status = 1").And("class = 4").Find(&dict)
if err != nil { if err != nil {
conf.Logger.Error("查询字典失败", zap.Error(err)) conf.Logger.Error("查询字典失败", zap.Error(err))
......
...@@ -10,8 +10,10 @@ import ( ...@@ -10,8 +10,10 @@ import (
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/response" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/response"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/client" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/client"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/conf" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/conf"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/util" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/util"
"time"
"xorm.io/xorm" "xorm.io/xorm"
"go.uber.org/zap" "go.uber.org/zap"
...@@ -282,6 +284,24 @@ func (o *User) CheckRepetition(input request.CheckRepetition) error { ...@@ -282,6 +284,24 @@ func (o *User) CheckRepetition(input request.CheckRepetition) error {
return nil return nil
} }
func (u *User) SystemUserUpdateState(params request.SystemUserStateReq) error {
db, err := client.GetDbClient()
if err != nil {
return resp.DbConnectError.WithData(err)
}
_, err = db.Table("system_user").Cols("state,updated_by").Where("id = ? ", params.Id).Update(map[string]interface{}{
"updated_by": u.User.Id,
"state": params.State,
"updated_time": jsontime.Time(time.Now()),
})
if err != nil {
return resp.DbSelectError.WithData(err)
}
return nil
}
// SystemUserEditPassword 修改密码 // SystemUserEditPassword 修改密码
func SystemUserEditPassword(params request.SystemUserEditPasswordReq) (err error) { func SystemUserEditPassword(params request.SystemUserEditPasswordReq) (err error) {
db, err := client.GetDbClient() db, err := client.GetDbClient()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment