From 63645d248c765244488cd34dbc1bb6528ca6b7c7 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期二, 05 九月 2023 09:58:13 +0800
Subject: [PATCH] 修复编译

---
 system-service/controllers/user.go |  682 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 341 insertions(+), 341 deletions(-)

diff --git a/system-service/controllers/user.go b/system-service/controllers/user.go
index 09fe57a..561ae19 100644
--- a/system-service/controllers/user.go
+++ b/system-service/controllers/user.go
@@ -1,342 +1,342 @@
-package controllers
-
-import (
-	"basic.com/valib/bhomeclient.git"
-	"basic.com/valib/logger.git"
-	"strconv"
-	"vamicro/system-service/models"
-	"vamicro/system-service/service"
-	"vamicro/system-service/vo"
-)
-
-type UserController struct{}
-
-// @Summary 娣诲姞鐢ㄦ埛
-// @Description 娣诲姞鐢ㄦ埛
-// @Accept json
-// @Produce json
-// @Tags 鐢ㄦ埛
-// @Param user body vo.UserVo true "鏂板缓鐢ㄦ埛淇℃伅"
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
-// @Router /data/api-v/user/add [post]
-func (uc UserController) Add(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
-	var userVo vo.UserVo
-	if err := c.BindJSON(&userVo);err !=nil {
-		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
-	}
-	var sv service.UserService
-	flag,data := sv.AddUser(userVo)
-	if flag {
-		return &bhomeclient.Reply{ Success: true, Data: data }
-	} else {
-		return &bhomeclient.Reply{ Msg: data}
-	}
-}
-
-// @Summary 鐢ㄦ埛鐧诲綍
-// @Description 鐢ㄦ埛鐧诲綍
-// @Accept json
-// @Produce json
-// @Tags 鐢ㄦ埛
-// @Param user body vo.UserVo true "鐢ㄦ埛淇℃伅"
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
-// @Router /data/api-u/sys/login [post]
-func (uc UserController) Login(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
-	userName := c.PostForm("username")
-	password := c.PostForm("password")
-	logger.Debug("username:", userName, "password:", password)
-	logger.Debug("鏂扮殑newcode")
-	if userName == "" || password == "" {
-		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
-	}
-	var sv service.UserService
-	flag, info := sv.Login(vo.UserVo{
-		UserName: userName,
-		Password: password,
-	})
-	if flag {
-		return &bhomeclient.Reply{ Success: true, Data: info }
-	} else if "鏈巿鏉冪敤鎴�" == info.RoleName {
-		return &bhomeclient.Reply{ Msg: "鎺堟潈宸茶繃鏈燂紝璇疯喘涔版柊鐨勬巿鏉�"}
-	} else {
-		return &bhomeclient.Reply{ Msg: "鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒"}
-	}
-}
-
-
-// @Summary 鍒锋柊鐢ㄦ埛token
-// @Description 鍒锋柊鐢ㄦ埛token
-// @Accept json
-// @Produce json
-// @Tags 鐢ㄦ埛
-// @Param user body vo.UserVo true "鐢ㄦ埛淇℃伅"
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
-// @Router /data/api-u/sys/refresh_token [get]
-func (uc UserController) RefreshToken(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
-	userId := c.Header("Login_user_id")
-	logger.Debug("current userId:", userId)
-
-	return &bhomeclient.Reply{ Success: true, Data: ""}
-}
-
-// @Summary 鐢ㄦ埛閫�鍑虹櫥褰�
-// @Description 鐢ㄦ埛閫�鍑虹櫥褰�
-// @Accept json
-// @Produce json
-// @Tags 鐢ㄦ埛
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
-// @Router /data/api-u/sys/logout [post]
-func (uc UserController) Logout(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
-	return &bhomeclient.Reply{ Success: true, Msg: "閫�鍑烘垚鍔�"}
-}
-
-// @Summary 鏌ユ壘鎵�鏈夌敤鎴�
-// @Description 鏌ユ壘鎵�鏈夌敤鎴�
-// @Accept json
-// @Produce json
-// @Tags 鐢ㄦ埛
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
-// @Router /data/api-u/users/findAllUser [get]
-func (uc UserController) FindAllUser(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
-	userId := c.Header("Login_user_id")
-	if userId == "" {
-		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
-	}
-	var sv service.UserService
-	d,err := sv.FindAll(userId)
-	if err ==nil {
-		return &bhomeclient.Reply{ Success: true, Data: d}
-	} else {
-		return &bhomeclient.Reply{ Msg: err.Error()}
-	}
-}
-
-type DelUsers struct {
-	Ids         []string  `json:"ids"`
-}
-
-// @Security ApiKeyAuth
-// @Summary 鍒犻櫎鐢ㄦ埛,鏀寔鎵归噺鍒犻櫎
-// @Description 鍒犻櫎鐢ㄦ埛锛屾敮鎸佹壒閲忓垹闄�
-// @Accept json
-// @Produce json
-// @Tags 鐢ㄦ埛
-// @Param reqBody body controllers.DelUsers true "鍒犻櫎鐢ㄦ埛id鏁扮粍鍙傛暟"
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
-// @Router /data/api-v/user/delUser [post]
-func (uc UserController) DelUser(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
-	var reqBody DelUsers
-	err := c.BindJSON(&reqBody)
-	if err != nil || len(reqBody.Ids) == 0 {
-		return &bhomeclient.Reply{ Msg: "璇锋眰鍙傛暟鏈夎"}
-	}
-
-	count := 0
-	for _,uId := range reqBody.Ids {
-		var u models.SysUser
-		if rows, e := u.SelectById(uId);e == nil && rows >0  && u.Username !="basic" {
-			if b,_ := u.DeleteById(uId);b {
-				count++
-			}
-		}
-	}
-	if count >0 {
-		return &bhomeclient.Reply{ Success: true, Data: "鎴愬姛鍒犻櫎:"+strconv.Itoa(count)+"涓�"}
-	} else {
-		return &bhomeclient.Reply{ Msg: "鍒犻櫎澶辫触"}
-	}
-}
-
-// @Summary 缂栬緫姝ょ敤鎴凤紝杩斿洖姝ょ敤鎴风殑鏉冮檺鑿滃崟
-// @Description 缂栬緫姝ょ敤鎴凤紝杩斿洖姝ょ敤鎴风殑鏉冮檺鑿滃崟
-// @Accept json
-// @Produce json
-// @Tags 鐢ㄦ埛
-// @Param userId formData string true "鐢ㄦ埛id"
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
-// @Router /data/api-v/user/findById [post]
-func (uc UserController) FindById(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
-	loginUserId := c.Header("Login_user_id")
-	userId := c.PostForm("userId")
-	logger.Debug("userid鎷垮埌:::", userId)
-	if userId == "" {
-		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
-	}
-	var sv service.UserService
-	userAuth, err := sv.FindByUserId(userId)
-	if err != nil {
-		logger.Debug("userid鏌ヨ澶辫触:::", userId)
-		return &bhomeclient.Reply{ Msg: "鏌ヨ澶辫触"}
-	}
-	var sv2 service.SysMenuService
-	var menuIds = make(map [string]string, 0)
-	for _,item := range userAuth.Menus {
-		menuIds[item.Id] = item.Id
-	}
-
-	d, err := sv2.GetMenuTree(loginUserId, menuIds)
-	if err ==nil {
-		return &bhomeclient.Reply{ Success: true, Data: d }
-	} else {
-		return &bhomeclient.Reply{ Msg: "鏌ヨ澶辫触"}
-	}
-}
-
-// @Summary 鏇存柊鐢ㄦ埛鍚嶏紝瀵嗙爜鍜岃彍鍗曟潈闄�
-// @Description 鏇存柊鐢ㄦ埛鍚嶏紝瀵嗙爜鍜岃彍鍗曟潈闄�
-// @Accept json
-// @Produce json
-// @Tags 鐢ㄦ埛
-// @Param userVo body vo.UserEditVo true "鐢ㄦ埛鍙婃潈闄愪俊鎭�"
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
-// @Router /data/api-v/user/saveAuth [post]
-func (uc UserController) SaveAuth(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
-	var userEditVo vo.UserEditVo
-	userId := c.Header("Login_user_id")
-	err := c.BindJSON(&userEditVo)
-	if err !=nil || userEditVo.Id =="" {
-		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
-	}
-	var sv service.UserService
-	err = sv.SaveAuth(&userEditVo, userId)
-	if nil == err {
-		return &bhomeclient.Reply{ Success: true, Msg: "鏇存柊鎴愬姛"}
-	} else {
-		return &bhomeclient.Reply{ Msg: "鏇存柊澶辫触锛�" + err.Error()}
-	}
-}
-
-// @Security ApiKeyAuth
-// @Summary 淇敼鐢ㄦ埛瀵嗙爜
-// @Description 淇敼鐢ㄦ埛瀵嗙爜
-// @Accept x-www-form-urlencoded
-// @Produce json
-// @Tags 鐢ㄦ埛
-// @Param userId formData string true "鐢ㄦ埛id"
-// @Param oldPwd formData string true "鏃у瘑鐮�"
-// @Param newPwd formData string true "鏂板瘑鐮�"
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
-// @Router /data/api-u/user/updatePwd [post]
-func (uc UserController) UpdatePwd(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
-	userId := c.Header("Login_user_id")
-	oldPwd := c.PostForm("oldPwd")
-	newPwd := c.PostForm("newPwd")
-	tarGetId := c.PostForm("userId")
-	if tarGetId != "" {
-		if  newPwd == "" {
-			return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
-		}
-	} else {
-		if userId == "" || oldPwd == "" || newPwd == "" {
-			return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
-		}
-		tarGetId = userId
-	}
-
-	var sv service.UserService
-	succ,err :=  sv.UpdatePwd(tarGetId, oldPwd, newPwd, userId)
-	if succ {
-		return &bhomeclient.Reply{ Success: true, Msg: "鏇存柊鎴愬姛"}
-	} else {
-		return &bhomeclient.Reply{ Msg: err.Error()}
-	}
-}
-
-// @Security ApiKeyAuth
-// @Summary 涓婁紶鐢ㄦ埛澶村儚
-// @Description 涓婁紶鐢ㄦ埛澶村儚
-// @Accept x-www-form-urlencoded
-// @Produce json
-// @Tags 鐢ㄦ埛
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
-// @Router /data/api-u/users/uploadHeadPic [post]
-func (uc UserController) UploadHeadPic(h *bhomeclient.WrapperHandler, c *bhomeclient.Request)*bhomeclient.Reply{
-	file,err := c.FormFile()
-	if err==nil {
-		var sv service.UserService
-		if file.Name == "" || len(file.Bytes) == 0 {
-			return &bhomeclient.Reply{ Msg: "澶村儚涓婁紶閿欒"}
-		}
-		filename := file.Name
-		headPic ,err := sv.UploadHeadPic(file.Bytes, filename)
-		if err != nil {
-			if err.Error() == "pic format error" {
-				return &bhomeclient.Reply{ Msg: "澶村儚鍙厑璁竕pg,jpeg,png鐨勬牸寮�"}
-			} else {
-				return &bhomeclient.Reply{ Msg: "澶村儚涓婁紶閿欒!"}
-			}
-		}
-		return &bhomeclient.Reply{ Success: true, Data: headPic }
-	}
-	return &bhomeclient.Reply{ Msg: "鏈壘鍒颁笂浼犲浘鐗�"}
-}
-
-// @Security ApiKeyAuth
-// @Summary 鏇存柊鐢ㄦ埛澶村儚锛屾樀绉�
-// @Description 鏇存柊鐢ㄦ埛澶村儚锛屾樀绉�
-// @Accept json
-// @Produce json
-// @Tags 鐢ㄦ埛
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
-func (uc UserController) UpdateProfile(h *bhomeclient.WrapperHandler, c *bhomeclient.Request)*bhomeclient.Reply{
-	var userEditVo vo.UserEditVo
-	err := c.BindJSON(&userEditVo)
-	if err !=nil || userEditVo.Id =="" {
-		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
-	}
-	var sv service.UserService
-	if sv.UpdateProfile(&userEditVo) {
-		var userSer service.UserService
-		Profile := userSer.GetProfile(userEditVo.Id)
-		return &bhomeclient.Reply{ Success: true,Msg: "鏇存柊鎴愬姛",Data: Profile}
-	} else {
-		return &bhomeclient.Reply{ Msg: "鏇存柊澶辫触"}
-	}
-}
-
-// @Security ApiKeyAuth
-// @Summary 涓婁紶鐢ㄦ埛澶村儚
-// @Description 涓婁紶鐢ㄦ埛澶村儚
-// @Accept x-www-form-urlencoded
-// @Produce json
-// @Tags 鐢ㄦ埛
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
-// @Router /data/api-u/users/defHeadPics [get]
-func (uc UserController) DefHeadPics(h *bhomeclient.WrapperHandler, c *bhomeclient.Request)*bhomeclient.Reply {
-	var headPic models.DefHeadPic
-	headPics, err := headPic.FindAll()
-	if nil == err {
-		return &bhomeclient.Reply{ Success: true, Data: headPics }
-	} else {
-		return &bhomeclient.Reply{ Success: false, Data: headPics }
-	}
-}
-
-// @Security ApiKeyAuth
-// @Summary 鑾峰彇褰撳墠鐢ㄦ埛淇℃伅
-// @Description 鑾峰彇褰撳墠鐢ㄦ埛淇℃伅
-// @Accept x-www-form-urlencoded
-// @Produce json
-// @Tags 鐢ㄦ埛
-// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
-// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
-// @Router /data/api-u/users/profile [get]
-func (uc UserController) Profile(h *bhomeclient.WrapperHandler, c *bhomeclient.Request)*bhomeclient.Reply {
-	var userSer service.UserService
-	userId := c.Header("Login_user_id")
-	Profile := userSer.GetProfile(userId)
-	logger.Debug("getProfile1:",Profile.UseIconType)
-	return &bhomeclient.Reply{ Success: true, Data: Profile }
+package controllers
+
+import (
+	"basic.com/valib/bhomeclient.git"
+	"basic.com/valib/logger.git"
+	"strconv"
+	"vamicro/system-service/models"
+	"vamicro/system-service/service"
+	"vamicro/system-service/vo"
+)
+
+type UserController struct{}
+
+// @Summary 娣诲姞鐢ㄦ埛
+// @Description 娣诲姞鐢ㄦ埛
+// @Accept json
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Param user body vo.UserVo true "鏂板缓鐢ㄦ埛淇℃伅"
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
+// @Router /data/api-v/user/add [post]
+func (uc UserController) Add(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
+	var userVo vo.UserVo
+	if err := c.BindJSON(&userVo);err !=nil {
+		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
+	}
+	var sv service.UserService
+	flag,data := sv.AddUser(userVo)
+	if flag {
+		return &bhomeclient.Reply{ Success: true, Data: data }
+	} else {
+		return &bhomeclient.Reply{ Msg: data}
+	}
+}
+
+// @Summary 鐢ㄦ埛鐧诲綍
+// @Description 鐢ㄦ埛鐧诲綍
+// @Accept json
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Param user body vo.UserVo true "鐢ㄦ埛淇℃伅"
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
+// @Router /data/api-u/sys/login [post]
+func (uc UserController) Login(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
+	userName := c.PostForm("username")
+	password := c.PostForm("password")
+	logger.Debug("username:", userName, "password:", password)
+	logger.Debug("鏂扮殑newcode")
+	if userName == "" || password == "" {
+		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
+	}
+	var sv service.UserService
+	flag, info := sv.Login(vo.UserVo{
+		UserName: userName,
+		Password: password,
+	})
+	if flag {
+		return &bhomeclient.Reply{ Success: true, Data: info }
+	} else if "鏈巿鏉冪敤鎴�" == info.RoleName {
+		return &bhomeclient.Reply{ Msg: "鎺堟潈宸茶繃鏈燂紝璇疯喘涔版柊鐨勬巿鏉�"}
+	} else {
+		return &bhomeclient.Reply{ Msg: "鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒"}
+	}
+}
+
+
+// @Summary 鍒锋柊鐢ㄦ埛token
+// @Description 鍒锋柊鐢ㄦ埛token
+// @Accept json
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Param user body vo.UserVo true "鐢ㄦ埛淇℃伅"
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
+// @Router /data/api-u/sys/refresh_token [get]
+func (uc UserController) RefreshToken(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
+	userId := c.Header("Login_user_id")
+	logger.Debug("current userId:", userId)
+
+	return &bhomeclient.Reply{ Success: true, Data: ""}
+}
+
+// @Summary 鐢ㄦ埛閫�鍑虹櫥褰�
+// @Description 鐢ㄦ埛閫�鍑虹櫥褰�
+// @Accept json
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
+// @Router /data/api-u/sys/logout [post]
+func (uc UserController) Logout(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
+	return &bhomeclient.Reply{ Success: true, Msg: "閫�鍑烘垚鍔�"}
+}
+
+// @Summary 鏌ユ壘鎵�鏈夌敤鎴�
+// @Description 鏌ユ壘鎵�鏈夌敤鎴�
+// @Accept json
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
+// @Router /data/api-u/users/findAllUser [get]
+func (uc UserController) FindAllUser(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
+	userId := c.Header("Login_user_id")
+	if userId == "" {
+		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
+	}
+	var sv service.UserService
+	d,err := sv.FindAll(userId)
+	if err ==nil {
+		return &bhomeclient.Reply{ Success: true, Data: d}
+	} else {
+		return &bhomeclient.Reply{ Msg: err.Error()}
+	}
+}
+
+type DelUsers struct {
+	Ids         []string  `json:"ids"`
+}
+
+// @Security ApiKeyAuth
+// @Summary 鍒犻櫎鐢ㄦ埛,鏀寔鎵归噺鍒犻櫎
+// @Description 鍒犻櫎鐢ㄦ埛锛屾敮鎸佹壒閲忓垹闄�
+// @Accept json
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Param reqBody body controllers.DelUsers true "鍒犻櫎鐢ㄦ埛id鏁扮粍鍙傛暟"
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
+// @Router /data/api-v/user/delUser [post]
+func (uc UserController) DelUser(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
+	var reqBody DelUsers
+	err := c.BindJSON(&reqBody)
+	if err != nil || len(reqBody.Ids) == 0 {
+		return &bhomeclient.Reply{ Msg: "璇锋眰鍙傛暟鏈夎"}
+	}
+
+	count := 0
+	for _,uId := range reqBody.Ids {
+		var u models.SysUser
+		if rows, e := u.SelectById(uId);e == nil && rows >0  && u.Username !="basic" {
+			if b,_ := u.DeleteById(uId);b {
+				count++
+			}
+		}
+	}
+	if count >0 {
+		return &bhomeclient.Reply{ Success: true, Data: "鎴愬姛鍒犻櫎:"+strconv.Itoa(count)+"涓�"}
+	} else {
+		return &bhomeclient.Reply{ Msg: "鍒犻櫎澶辫触"}
+	}
+}
+
+// @Summary 缂栬緫姝ょ敤鎴凤紝杩斿洖姝ょ敤鎴风殑鏉冮檺鑿滃崟
+// @Description 缂栬緫姝ょ敤鎴凤紝杩斿洖姝ょ敤鎴风殑鏉冮檺鑿滃崟
+// @Accept json
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Param userId formData string true "鐢ㄦ埛id"
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
+// @Router /data/api-v/user/findById [post]
+func (uc UserController) FindById(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
+	loginUserId := c.Header("Login_user_id")
+	userId := c.PostForm("userId")
+	logger.Debug("userid鎷垮埌:::", userId)
+	if userId == "" {
+		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
+	}
+	var sv service.UserService
+	userAuth, err := sv.FindByUserId(userId)
+	if err != nil {
+		logger.Debug("userid鏌ヨ澶辫触:::", userId)
+		return &bhomeclient.Reply{ Msg: "鏌ヨ澶辫触"}
+	}
+	var sv2 service.SysMenuService
+	var menuIds = make(map [string]string, 0)
+	for _,item := range userAuth.Menus {
+		menuIds[item.Id] = item.Id
+	}
+
+	d, err := sv2.GetMenuTree(loginUserId, menuIds)
+	if err ==nil {
+		return &bhomeclient.Reply{ Success: true, Data: d }
+	} else {
+		return &bhomeclient.Reply{ Msg: "鏌ヨ澶辫触"}
+	}
+}
+
+// @Summary 鏇存柊鐢ㄦ埛鍚嶏紝瀵嗙爜鍜岃彍鍗曟潈闄�
+// @Description 鏇存柊鐢ㄦ埛鍚嶏紝瀵嗙爜鍜岃彍鍗曟潈闄�
+// @Accept json
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Param userVo body vo.UserEditVo true "鐢ㄦ埛鍙婃潈闄愪俊鎭�"
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
+// @Router /data/api-v/user/saveAuth [post]
+func (uc UserController) SaveAuth(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
+	var userEditVo vo.UserEditVo
+	userId := c.Header("Login_user_id")
+	err := c.BindJSON(&userEditVo)
+	if err !=nil || userEditVo.Id =="" {
+		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
+	}
+	var sv service.UserService
+	err = sv.SaveAuth(&userEditVo, userId)
+	if nil == err {
+		return &bhomeclient.Reply{ Success: true, Msg: "鏇存柊鎴愬姛"}
+	} else {
+		return &bhomeclient.Reply{ Msg: "鏇存柊澶辫触锛�" + err.Error()}
+	}
+}
+
+// @Security ApiKeyAuth
+// @Summary 淇敼鐢ㄦ埛瀵嗙爜
+// @Description 淇敼鐢ㄦ埛瀵嗙爜
+// @Accept x-www-form-urlencoded
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Param userId formData string true "鐢ㄦ埛id"
+// @Param oldPwd formData string true "鏃у瘑鐮�"
+// @Param newPwd formData string true "鏂板瘑鐮�"
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
+// @Router /data/api-u/user/updatePwd [post]
+func (uc UserController) UpdatePwd(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{
+	userId := c.Header("Login_user_id")
+	oldPwd := c.PostForm("oldPwd")
+	newPwd := c.PostForm("newPwd")
+	tarGetId := c.PostForm("userId")
+	if tarGetId != "" {
+		if  newPwd == "" {
+			return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
+		}
+	} else {
+		if userId == "" || oldPwd == "" || newPwd == "" {
+			return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
+		}
+		tarGetId = userId
+	}
+
+	var sv service.UserService
+	succ,err :=  sv.UpdatePwd(tarGetId, oldPwd, newPwd, userId)
+	if succ {
+		return &bhomeclient.Reply{ Success: true, Msg: "鏇存柊鎴愬姛"}
+	} else {
+		return &bhomeclient.Reply{ Msg: err.Error()}
+	}
+}
+
+// @Security ApiKeyAuth
+// @Summary 涓婁紶鐢ㄦ埛澶村儚
+// @Description 涓婁紶鐢ㄦ埛澶村儚
+// @Accept x-www-form-urlencoded
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
+// @Router /data/api-u/users/uploadHeadPic [post]
+func (uc UserController) UploadHeadPic(h *bhomeclient.WrapperHandler, c *bhomeclient.Request)*bhomeclient.Reply{
+	file,err := c.FormFile()
+	if err==nil {
+		var sv service.UserService
+		if file.Name == "" || len(file.Bytes) == 0 {
+			return &bhomeclient.Reply{ Msg: "澶村儚涓婁紶閿欒"}
+		}
+		filename := file.Name
+		headPic ,err := sv.UploadHeadPic(file.Bytes, filename)
+		if err != nil {
+			if err.Error() == "pic format error" {
+				return &bhomeclient.Reply{ Msg: "澶村儚鍙厑璁竕pg,jpeg,png鐨勬牸寮�"}
+			} else {
+				return &bhomeclient.Reply{ Msg: "澶村儚涓婁紶閿欒!"}
+			}
+		}
+		return &bhomeclient.Reply{ Success: true, Data: headPic }
+	}
+	return &bhomeclient.Reply{ Msg: "鏈壘鍒颁笂浼犲浘鐗�"}
+}
+
+// @Security ApiKeyAuth
+// @Summary 鏇存柊鐢ㄦ埛澶村儚锛屾樀绉�
+// @Description 鏇存柊鐢ㄦ埛澶村儚锛屾樀绉�
+// @Accept json
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
+func (uc UserController) UpdateProfile(h *bhomeclient.WrapperHandler, c *bhomeclient.Request)*bhomeclient.Reply{
+	var userEditVo vo.UserEditVo
+	err := c.BindJSON(&userEditVo)
+	if err !=nil || userEditVo.Id =="" {
+		return &bhomeclient.Reply{ Msg: "鍙傛暟鏈夎"}
+	}
+	var sv service.UserService
+	if sv.UpdateProfile(&userEditVo) {
+		var userSer service.UserService
+		Profile := userSer.GetProfile(userEditVo.Id)
+		return &bhomeclient.Reply{ Success: true,Msg: "鏇存柊鎴愬姛",Data: Profile}
+	} else {
+		return &bhomeclient.Reply{ Msg: "鏇存柊澶辫触"}
+	}
+}
+
+// @Security ApiKeyAuth
+// @Summary 涓婁紶鐢ㄦ埛澶村儚
+// @Description 涓婁紶鐢ㄦ埛澶村儚
+// @Accept x-www-form-urlencoded
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
+// @Router /data/api-u/users/defHeadPics [get]
+func (uc UserController) DefHeadPics(h *bhomeclient.WrapperHandler, c *bhomeclient.Request)*bhomeclient.Reply {
+	var headPic models.DefHeadPic
+	headPics, err := headPic.FindAll()
+	if nil == err {
+		return &bhomeclient.Reply{ Success: true, Data: headPics }
+	} else {
+		return &bhomeclient.Reply{ Success: false, Data: headPics }
+	}
+}
+
+// @Security ApiKeyAuth
+// @Summary 鑾峰彇褰撳墠鐢ㄦ埛淇℃伅
+// @Description 鑾峰彇褰撳墠鐢ㄦ埛淇℃伅
+// @Accept x-www-form-urlencoded
+// @Produce json
+// @Tags 鐢ㄦ埛
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}"
+// @Router /data/api-u/users/profile [get]
+func (uc UserController) Profile(h *bhomeclient.WrapperHandler, c *bhomeclient.Request)*bhomeclient.Reply {
+	var userSer service.UserService
+	userId := c.Header("Login_user_id")
+	Profile := userSer.GetProfile(userId)
+	logger.Debug("getProfile1:",Profile.UseIconType)
+	return &bhomeclient.Reply{ Success: true, Data: Profile }
 }
\ No newline at end of file

--
Gitblit v1.8.0