瀏覽代碼

casbin合并

huahaiyan 6 年之前
父節點
當前提交
d929c22800

+ 287 - 0
src/dashoo.cn/backend/api/controllers/casbin/district.go

@@ -0,0 +1,287 @@
+package casbin
+
+import (
+	"encoding/json"
+	//	"fmt"
+
+	"dashoo.cn/business2/district"
+	. "dashoo.cn/backend/api/controllers"
+	"dashoo.cn/utils"
+)
+
+// Operations about Users
+type DistrictController struct {
+	BaseController
+}
+
+type DistrictModel struct {
+	Parentid        int    `json:"parentid"`
+	Fullname        string `json:"fullname"`
+	Description     string `json:"description"`
+	HaveChild       int    `json:"havechild"`
+}
+
+// @Title 区域列表
+// @Description 区域列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /list [get]
+func (this *DistrictController) List() {
+	page := this.GetPageInfoForm()
+	svc := district.GetDistrictService(utils.DBE)
+	where := " CreateUserId=" + this.User.Id + ""
+	keyword := this.GetString("keyword")
+	parentid := this.GetString("parentid")
+	if keyword != "" {
+		where = where + " and FullName like '%" + keyword + "%'"
+	}
+	if parentid != "" && parentid != "-1" {
+		ids := svc.GetAllChildByTopId(parentid, this.User.Id)
+		where = where + " and Id in ( " + ids + " )"
+	}
+	list := make([]district.Base_District, 0)
+	total := svc.GetPagingEntitiesWithSortCode(page.CurrentPage, page.Size, "ParentId, CreateOn desc", &list, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 根据用户AccCode get检验主表 客户原始信息内容
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /cellsCollectionDetaillist [get]
+func (this *DistrictController) CellsCollectionDetaillist() {
+	svc := district.GetDistrictService(utils.DBE)
+	where := "'" + this.User.AccCode + "'"
+	list := svc.GetCollectionDetailviewlist(where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title get
+// @Description get SampleType by token
+// @Success 200
+// @router /detailed/:id [get]
+func (this *DistrictController) Detailed() {
+	svc := district.GetDistrictService(utils.DBE)
+	id := this.Ctx.Input.Param(":id")
+	var entity district.Base_District
+	where := " Id=" + id + ""
+	entity = svc.QueryEntity(where)
+	var datainfo DataInfo
+	datainfo.Items = entity
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 组织列表带父级名称
+// @Description
+// @Success 200 {object} business.device.DeviceChannels
+// @router /listbandparentname [get]
+func (this *DistrictController) Listbandparentname() {
+	page := this.GetPageInfoForm()
+	svc := district.GetDistrictService(utils.DBE)
+	where := " a.CreateuserId=" + this.User.Id + ""
+	keyword := this.GetString("keyword")
+	parentid := this.GetString("parentid")
+	if keyword != "" {
+		where = where + " and a.FullName like '%" + keyword + "%'"
+	}
+	if parentid != "" && parentid != "-1" {
+		ids := svc.GetAllChildByTopId(parentid, this.User.Id)
+		where = where + " and a.Id in ( " + ids + " )"
+	}
+	total, list := svc.GetListbandparentname(page.CurrentPage, page.Size, "a.ParentId, a.CreateOn desc", where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 创建区域
+// @Description 创建区域
+// @Param	body	body	business.device.DeviceChannels
+// @Success	200	{object} controllers.Request
+// @router / [post]
+func (this *DistrictController) AddOrganize() {
+	var model OrganizeModel
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	var errinfo ErrorInfo
+	var entity district.Base_District
+	svc := district.GetDistrictService(utils.DBE)
+	// 编辑后添加一条数据
+	entity.FullName = model.Fullname
+	entity.ParentId = model.Parentid
+	entity.Description = model.Description
+	entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+	entity.CreateBy = this.User.Realname
+	entity.AccCode = this.GetAccode()
+
+	_, err := svc.InsertEntity(&entity)
+
+	if err == nil {
+		errinfo.Message = "添加区域成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	} else {
+		errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+}
+
+// @Title 编辑组织
+// @Description 编辑组织
+// @Param	id	path	string	true		"需要修改的传感器编号"
+// @Param	body	body	business.device.DeviceChannels	"传感器信息"
+// @Success	200	{object} controllers.Request
+// @router /:id [put]
+func (this *DistrictController) EditOrganize() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+	var model OrganizeModel
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+
+	var entity district.Base_District
+	var entityempty district.Base_District
+	svc := district.GetDistrictService(utils.DBE)
+
+	has := svc.GetEntityById(id, &entity)
+	if has {
+		entity.FullName = model.Fullname
+		entity.ParentId = model.Parentid
+		entity.Description = model.Description
+		entity.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+		entity.ModifiedBy = this.User.Realname
+		var cols []string = []string{"FullName", "ParentId", "Description", "ModifiedUserId", "ModifiedBy"}
+		err := svc.UpdateEntityAndBackupByCols(id, &entity, &entityempty, cols, utils.ToStr(this.User.Id), this.User.Realname)
+
+		if err == nil {
+			errinfo.Message = "保存成功!"
+			errinfo.Code = 0
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+		} else {
+			errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+			errinfo.Code = -1
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+		}
+	} else {
+		errinfo.Message = "操作失败!操作数据不存在"
+		errinfo.Code = -3
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+}
+
+// @Title 删除组织
+// @Description 删除组织
+// @Param	id		path 	string	true		"需要删除的用户编号"
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /:id [delete]
+func (this *DistrictController) Delete() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	svc := district.GetDistrictService(utils.DBE)
+	if svc.IsHaveChild(id) {
+		errinfo.Message = "操作失败!请先删除下属组织"
+		errinfo.Code = -3
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	if svc.IsHaveUserUse(id) {
+		errinfo.Message = "操作失败!有用户在使用此组织,请先解除绑定"
+		errinfo.Code = -4
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	if svc.IsHaveEquiUse(id) {
+		errinfo.Message = "操作失败!有设备在使用此组织,请先解除绑定"
+		errinfo.Code = -5
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var entity district.Base_District
+	var entityempty district.Base_District
+	err := svc.DeleteEntityAndBackup(id, &entity, &entityempty, utils.ToStr(this.User.Id), this.User.Username)
+
+	if err == nil {
+		errinfo.Message = "删除成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 获取子集列表
+// @Description 获取子集列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /childlist/:id [get]
+func (this *DistrictController) ChildList() {
+	id := this.Ctx.Input.Param(":id")
+	svc := district.GetDistrictService(utils.DBE)
+	where := " Createuserid= " + this.User.Id
+	where = where + " and ParentId = " + id + ""
+
+	list := make([]district.Base_District, 0)
+	svc.GetDatasByCols(&list, where, "Sortcode, CreateOn desc", []string{"Id", "ParentId", "Fullname"})
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 获取父集列表
+// @Description 获取父集列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /parentlist/:id [get]
+func (this *DistrictController) ParentList() {
+	id := this.Ctx.Input.Param(":id")
+	svc := district.GetDistrictService(utils.DBE)
+	var errinfo ErrorInfo
+	errinfo.Message = svc.GetAllParentByTopId(id, this.User.Id)
+	errinfo.Code = 0
+	this.Data["json"] = &errinfo
+	this.ServeJSON()
+}
+
+
+

+ 251 - 0
src/dashoo.cn/backend/api/controllers/casbin/module.go

@@ -0,0 +1,251 @@
+package casbin
+
+import (
+	"dashoo.cn/business2/module"
+	. "dashoo.cn/backend/api/controllers"
+	"encoding/json"
+	"fmt"
+	//	"fmt"
+
+	"dashoo.cn/utils"
+)
+
+// Operations about Users
+type ModuleController struct {
+	BaseController
+}
+
+type ModuleModel struct {
+	Parentid        int    `json:"parentid"`
+	Fullname        string `json:"fullname"`
+	Description     string `json:"description"`
+	HaveChild       int    `json:"havechild"`
+	Navigateurl     string `json:"navigateurl"`
+	Imageindex      string `json:"imageindex"`
+}
+
+// @Title 菜单列表
+// @Description 菜单列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /list [get]
+func (this *ModuleController) List() {
+	page := this.GetPageInfoForm()
+	svc := module.GetModuleService(utils.DBE)
+	//permissionsvc := permission.GetPermissionService(utils.DBE)
+	//ztreecurrentusernodesmodu := permissionsvc.GetModuleAll(this.User.Id, "30")
+	where := " 1=1"
+	keyword := this.GetString("keyword")
+	parentid := this.GetString("parentid")
+	if keyword != "" {
+		where = where + " and FullName like '%" + keyword + "%'"
+	}
+	if parentid != "" && parentid != "-1" {
+		ids := svc.GetChildByTopId(parentid)
+		where = where + " and Id in ( " + ids + " )"
+	}
+	list := make([]module.Base_Module, 0)
+	total := svc.GetPagingEntitiesWithSortCode(page.CurrentPage, page.Size, "ParentId, CreateOn desc", &list, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 菜单列表带父级名称
+// @Description
+// @Success 200 {object} business.device.DeviceChannels
+// @router /listbandparentname [get]
+func (this *ModuleController) Listbandparentname() {
+	page := this.GetPageInfoForm()
+	svc := module.GetModuleService(utils.DBE)
+	where := "1=1"
+	keyword := this.GetString("keyword")
+	parentid := this.GetString("parentid")
+	if keyword != "" {
+		where = where + " and a.Fullname like '%" + keyword + "%'"
+	}
+	if parentid != "" && parentid != "-1" {
+		ids := svc.GetChildByTopId(parentid)
+		where = where + " and a.Id in ( " + ids + " )"
+	}
+	total, list := svc.GetListbandparentname(page.CurrentPage, page.Size, "a.ParentId, a.CreateOn desc", where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 创建菜单
+// @Description 创建菜单
+// @Param	body	body	business.device.DeviceChannels
+// @Success	200	{object} controllers.Request
+// @router / [post]
+func (this *ModuleController) AddOrganize() {
+	var model ModuleModel
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	var errinfo ErrorInfo
+	var entity module.Base_Module
+	svc := module.GetModuleService(utils.DBE)
+	// 编辑后添加一条数据
+	entity.Fullname = model.Fullname
+	entity.Parentid = model.Parentid
+	entity.Description = model.Description
+	entity.Navigateurl = model.Navigateurl
+	entity.Imageindex = model.Imageindex
+	entity.Createuserid, _ = utils.StrTo(this.User.Id).Int()
+	entity.Createby = this.User.Realname
+	entity.Enabled = 1
+	entity.Ismenu = 0000000001
+	entity.Ispublic =1
+	entity.Expand = 1
+	entity.Allowdelete = 1
+	entity.Allowedit =1
+	_, err := svc.InsertEntity(&entity)
+
+	if err == nil {
+		errinfo.Message = "添加菜单成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	} else {
+		errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+}
+
+// @Title 编辑菜单
+// @Description 编辑菜单
+// @Param	id	path	string	true
+// @Param	body	body	business.device.DeviceChannels
+// @Success	200	{object} controllers.Request
+// @router /:id [put]
+func (this *ModuleController) EditOrganize() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model ModuleModel
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+
+	var entity module.Base_Module
+	var entityempty module.Base_Module
+	svc := module.GetModuleService(utils.DBE)
+
+	has := svc.GetEntityById(id, &entity)
+	if has {
+		entity.Fullname = model.Fullname
+		entity.Parentid = model.Parentid
+		entity.Description = model.Description
+		entity.Navigateurl = model.Navigateurl
+		entity.Imageindex = model.Imageindex
+		entity.Modifieduserid, _ = utils.StrTo(this.User.Id).Int()
+		entity.Modifiedby = this.User.Realname
+		var cols []string = []string{"FullName", "ParentId", "Description","NavigateUrl","ImageIndex", "ModifiedUserId", "ModifiedBy"}
+		err := svc.UpdateEntityAndBackupByCols(id, &entity, &entityempty, cols, utils.ToStr(this.User.Id), this.User.Realname)
+
+		if err == nil {
+			errinfo.Message = "保存成功!"
+			errinfo.Code = 0
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+		} else {
+			errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
+			errinfo.Code = -1
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+		}
+	} else {
+		errinfo.Message = "操作失败!操作数据不存在"
+		errinfo.Code = -3
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+}
+
+// @Title 删除菜单
+// @Description 删除菜单
+// @Param	id		path 	string	true
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /:id [delete]
+func (this *ModuleController) Delete() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	svc := module.GetModuleService(utils.DBE)
+	var entity module.Base_Module
+	var entityempty module.Base_Module
+	err := svc.DeleteEntityAndBackup(id, &entity, &entityempty, utils.ToStr(this.User.Id), this.User.Username)
+
+	if err == nil {
+		errinfo.Message = "删除成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 获取子集列表
+// @Description 获取子集列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /childlist/:id [get]
+func (this *ModuleController) ChildList() {
+	id := this.Ctx.Input.Param(":id")
+	svc := module.GetModuleService(utils.DBE)
+	where := " Createuserid= " + this.User.Id
+	where = where + " and ParentId = " + id + ""
+
+	list := make([]module.Base_Module, 0)
+	svc.GetDatasByCols(&list, where, "Sortcode, CreateOn desc", []string{"Id", "ParentId", "Fullname"})
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 获取父集列表
+// @Description 获取父集列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /parentlist/:id [get]
+func (this *ModuleController) ParentList() {
+	id := this.Ctx.Input.Param(":id")
+	svc := module.GetModuleService(utils.DBE)
+	var errinfo ErrorInfo
+	var url string
+	idlist := svc.GetMenuTopItem(url, id)
+	fmt.Println(idlist)
+	errinfo.Message = "test"
+	errinfo.Code = 0
+	this.Data["json"] = &errinfo
+	this.ServeJSON()
+}
+
+
+

+ 2 - 1
src/dashoo.cn/backend/api/controllers/organize.go → src/dashoo.cn/backend/api/controllers/casbin/organize.go

@@ -1,4 +1,4 @@
-package controllers
+package casbin
 
 import (
 	"encoding/json"
@@ -9,6 +9,7 @@ import (
 	"dashoo.cn/business2/permission"
 	"dashoo.cn/backend/api/business/organize"
 	"dashoo.cn/utils"
+	. "dashoo.cn/backend/api/controllers"
 )
 
 // Operations about Users

+ 47 - 1
src/dashoo.cn/backend/api/controllers/permission.go → src/dashoo.cn/backend/api/controllers/casbin/permission.go

@@ -1,9 +1,10 @@
-package controllers
+package casbin
 
 import (
 	"dashoo.cn/business2/permission"
 	"dashoo.cn/utils"
 	"encoding/json"
+	. "dashoo.cn/backend/api/controllers"
 )
 
 type PermissionController struct {
@@ -183,3 +184,48 @@ func (this *PermissionController) Delete() {
 		this.ServeJSON()
 	}
 }
+
+// @Title get
+// @Description get user by token
+// @Param	uid		path 	string	true		"The key for staticblock"
+// @Success 200 {object} models.User
+// @Failure 403 :uid is empty
+// @router /isauth [get]
+func (this *PermissionController) IsAuthorized() {
+
+	percode := this.GetString("percode")
+	svc := permission.GetPermissionService(utils.DBE)
+	var errinfo ErrorInfo
+	isauth := svc.IsAuthorized(this.User.Id, percode)
+	if isauth {
+		errinfo.Message = "有权限"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	} else {
+		errinfo.Message = "无操作权限"
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+}
+
+// @Title 根据多个code获取权限
+// @Description get user by token
+// @Param	uid		path 	string	true		"The key for staticblock"
+// @Success 200 {object} models.User
+// @Failure 403 :uid is empty
+// @router /isauths [get]
+func (this *PermissionController) IsAuthorizeds() {
+	percodes := this.GetString("percodes")
+	svc := permission.GetPermissionService(utils.DBE)
+	auths := svc.IsAuthorizeds(this.User.Id, percodes)
+	this.Data["json"] = auths
+	this.ServeJSON()
+}
+
+
+

+ 12 - 12
src/dashoo.cn/backend/api/controllers/casbin/role.go

@@ -5,7 +5,7 @@ import (
 	"strconv"
 	"strings"
 
-	"dashoo.cn/backend/api/controllers"
+	. "dashoo.cn/backend/api/controllers"
 	"dashoo.cn/business2/district"
 	"dashoo.cn/business2/module"
 	"dashoo.cn/business2/organize"
@@ -16,7 +16,7 @@ import (
 )
 
 type RoleController struct {
-	controllers.BaseController
+	BaseController
 }
 
 type RolePowerAjaxModel struct {
@@ -51,7 +51,7 @@ func (this *RoleController) RoleList() {
 		where = where + " and Realname like '%" + searchkey + "%'"
 	}
 	total := svc.GetRoleList(page.CurrentPage, page.Size, "CreateOn", utils.ToStr(this.User.Id), &roles, where)
-	var datainfo controllers.DataInfo
+	var datainfo DataInfo
 	datainfo.Items = roles
 	datainfo.CurrentItemCount = total
 	this.Data["json"] = &datainfo
@@ -113,7 +113,7 @@ func (this *RoleController) DistrictListGet() {
 func (this *RoleController) RoleOperationPowerPost() {
 	//svc := permission.GetPermissionService(utils.DBE)
 	roleid := this.GetString("id")
-	var errinfo controllers.ErrorInfo
+	var errinfo ErrorInfo
 	if roleid == "" {
 		errinfo.Message = utils.AlertProcess("操作失败!请求信息不完整!")
 		errinfo.Code = -2
@@ -157,7 +157,7 @@ func (this *RoleController) RoleOperationPowerPost() {
 // @router /savedepartmentmessageview [put]
 func (this *RoleController) OrganizePost() {
 	roleid := this.GetString("id")
-	var errinfo controllers.ErrorInfo
+	var errinfo ErrorInfo
 	if roleid == "" {
 		errinfo.Message = utils.AlertProcess("操作失败!请求信息不完整!")
 		errinfo.Code = -2
@@ -198,7 +198,7 @@ func (this *RoleController) OrganizePost() {
 // @router /savedistrict [put]
 func (this *RoleController) DistrictPost() {
 	roleid := this.GetString("id")
-	var errinfo controllers.ErrorInfo
+	var errinfo ErrorInfo
 	if roleid == "" {
 		errinfo.Message = utils.AlertProcess("操作失败!请求信息不完整!")
 		errinfo.Code = -2
@@ -257,7 +257,7 @@ func (this *RoleController) GetRoleItemPowerAjax() {
 func (this *RoleController) RolePowerPost() {
 	//svc := casbin.GetPermissionService(utils.DBE)
 	roleid := this.GetString("id")
-	var errinfo controllers.ErrorInfo
+	var errinfo ErrorInfo
 	if roleid == "" {
 		errinfo.Message = utils.AlertProcess("操作失败!请求信息不完整!")
 		errinfo.Code = -2
@@ -307,7 +307,7 @@ func (this *RoleController) GetUsersForRole() {
 	}
 	total, users := svc.GetUserListForRole(page.CurrentPage, page.Size, roleid, "Id", where)
 
-	var datainfo controllers.DataInfo
+	var datainfo DataInfo
 	datainfo.Items = users
 	datainfo.CurrentItemCount = total
 	this.Data["json"] = &datainfo
@@ -322,7 +322,7 @@ func (this *RoleController) UserRoleAddUser() {
 	inputstr := this.Ctx.Input.Param(":id")
 	serial := strings.Split(inputstr, "_")
 	userids := strings.Split(serial[0], ",")
-	var errinfo controllers.ErrorInfo
+	var errinfo ErrorInfo
 	roleid := serial[1]
 	var err error = nil
 	for i := 0; i < len(userids); i++ {
@@ -354,7 +354,7 @@ func (this *RoleController) UserDelete() {
 	id := serial[0]
 	roleid := serial[1]
 	utils.RBAC.DeleteRoleForUser("uid_"+id, "rid_"+roleid)
-	var errinfo controllers.ErrorInfo
+	var errinfo ErrorInfo
 	var err error = nil
 	if err == nil {
 		errinfo.Message = utils.AlertProcess("删除用户成功!")
@@ -381,7 +381,7 @@ func (this *RoleController) DeleteUserAll() {
 	for i := 0; i < len(users); i++ {
 		utils.RBAC.DeleteRoleForUser("uid_"+utils.ToStr(users[i].Id), "rid_"+roleid)
 	}
-	var errinfo controllers.ErrorInfo
+	var errinfo ErrorInfo
 	var err error = nil
 	if err == nil {
 		errinfo.Message = utils.AlertProcess("删除用户成功!")
@@ -402,7 +402,7 @@ func (this *RoleController) DeleteUserAll() {
 func (this *RoleController) DeleteRole() {
 	roleid := this.Ctx.Input.Param(":id")
 	utils.RBAC.DeleteRole("rid_" + roleid)
-	var errinfo controllers.ErrorInfo
+	var errinfo ErrorInfo
 	var err error = nil
 	if err == nil {
 		errinfo.Message = utils.AlertProcess("删除角色成功!")

+ 48 - 4
src/dashoo.cn/backend/api/controllers/casbin/user.go

@@ -3,16 +3,60 @@ package casbin
 import (
 	"dashoo.cn/business2/userRole"
 	"dashoo.cn/business2/permission"
+	"dashoo.cn/backend/api/models"
 	"strings"
 
-	"dashoo.cn/backend/api/controllers"
+	. "dashoo.cn/backend/api/controllers"
 	"dashoo.cn/utils"
 
 )
 
 // Operations about Users
 type UserController struct {
-	controllers.BaseController
+	BaseController
+}
+
+// @Title get
+// @Description get user by token
+// @Param	uid		path 	string	true		"The key for staticblock"
+// @Success 200 {object} models.User
+// @Failure 403 :uid is empty
+// @router /me [get]
+func (this *UserController) Get() {
+	svc := userRole.GetUserService(utils.DBE)
+	usermodel := svc.GetUserInfoSelf(this.User.Username)
+	//	var companyentity company.Base_Company
+	//	svc.GetEntityById(usermodel.AccCode, &companyentity)
+	var user models.User
+	user.Id = utils.ToStr(usermodel.Id)
+	user.Username = usermodel.Username
+	user.Profile.Address = usermodel.Homeaddress
+	user.Profile.Email = usermodel.Email
+	user.Profile.Realname = usermodel.Realname
+	user.Profile.Roleid = usermodel.Roleid
+	user.Profile.Mobile = usermodel.Mobile
+	user.Profile.Telephone = usermodel.Telephone
+	user.Profile.Photo = usermodel.Photo
+	user.Profile.Description = usermodel.Description
+	user.Profile.Host = this.Ctx.Request.Host
+	user.Profile.AccCode = usermodel.AccCode
+	user.Profile.DepartmentId = usermodel.Departmentid
+	user.Profile.Id = usermodel.Id
+	// todo 从this.User获取用户名,再查询出具体用户
+	//	user := models.User{"user01", "张三", models.Profile{Gender: "male", Age: 20, Address: "china", Email: "123zs@gmail.com", Realname: "ppppppp"}}
+	this.Data["json"] = user
+	this.ServeJSON()
+}
+
+// @Title 获取用户菜单权限
+// @Description 获取用户菜单权限
+// @Success	200	{object} controllers.Request
+// @router /getusermoduletree [get]
+func (this *UserController) GetUserModuleTree() {
+	svc := permission.GetPermissionService(utils.DBE)
+	list := svc.GetModuleAll(this.User.Id, "30000000")
+	this.Data["json"] = list
+	this.ServeJSON()
 }
 
 // @Title 获得用户角色id
@@ -45,7 +89,7 @@ func (this *UserController) List() {
 	}
 	total := svc.GetPagingEntitiesWithOrder(page.CurrentPage, page.Size, "Id", false, &users, where)
 
-	var datainfo controllers.DataInfo
+	var datainfo DataInfo
 	datainfo.Items = users
 	datainfo.CurrentItemCount = total
 	this.Data["json"] = &datainfo
@@ -60,7 +104,7 @@ func (this *UserController) UserPowerPostRole() {
 	inputstr := this.Ctx.Input.Param(":id")
 	serial := strings.Split(inputstr, "_")
 	userid := serial[0]
-	var errinfo controllers.ErrorInfo
+	var errinfo ErrorInfo
 	if userid == "" || userid == "0" {
 		errinfo.Message = "操作失败!请求信息不完整"
 		errinfo.Code = -2

+ 0 - 55
src/dashoo.cn/backend/api/controllers/permissions.go

@@ -1,55 +0,0 @@
-package controllers
-
-import (
-	"dashoo.cn/business2/permission"
-	"dashoo.cn/utils"
-)
-
-// Operations about Users
-type PermissionsController struct {
-	BaseController
-}
-
-// @Title get
-// @Description get user by token
-// @Param	uid		path 	string	true		"The key for staticblock"
-// @Success 200 {object} models.User
-// @Failure 403 :uid is empty
-// @router /isauth [get]
-func (this *PermissionsController) IsAuthorized() {
-
-	percode := this.GetString("percode")
-	svc := permission.GetPermissionService(utils.DBE)
-	var errinfo ErrorInfo
-	isauth := svc.IsAuthorized(this.User.Id, percode)
-	if isauth {
-		errinfo.Message = "有权限"
-		errinfo.Code = 0
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	} else {
-		errinfo.Message = "无操作权限"
-		errinfo.Code = -1
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}
-
-}
-
-// @Title 根据多个code获取权限
-// @Description get user by token
-// @Param	uid		path 	string	true		"The key for staticblock"
-// @Success 200 {object} models.User
-// @Failure 403 :uid is empty
-// @router /isauths [get]
-func (this *PermissionsController) IsAuthorizeds() {
-	percodes := this.GetString("percodes")
-	svc := permission.GetPermissionService(utils.DBE)
-	auths := svc.IsAuthorizeds(this.User.Id, percodes)
-	this.Data["json"] = auths
-	this.ServeJSON()
-}
-
-

+ 0 - 356
src/dashoo.cn/backend/api/controllers/role.go

@@ -1,356 +0,0 @@
-package controllers
-
-import (
-	"encoding/json"
-	"strings"
-
-	"dashoo.cn/backend/api/business/role"
-	"dashoo.cn/backend/api/business/userequipment"
-	"dashoo.cn/business2/module"
-	"dashoo.cn/business2/permission"
-	"dashoo.cn/business2/userRole"
-	"dashoo.cn/utils"
-)
-
-type RoleController struct {
-	BaseController
-}
-
-type RolePowerAjaxModel struct {
-	Operation        []permission.Base_Permissiontree
-	Selecteoperation []permission.Base_Permissiontree
-	Module           []module.ModuleSimplify
-	Selectemodule    []permission.Base_Permissiontree
-}
-
-type RolePerAjaxModel struct {
-	Operation        []permission.Base_Permissionstrtree
-	Selecteoperation []permission.Base_Permissionstrtree
-}
-
-// @Title 角色列表
-// @Description 获取角色列表
-// @Success 200 {object} controllers.Request
-// @router /list [get]
-func (this *RoleController) RoleList() {
-	svc := role.GetRoleService(utils.DBE)
-	var roles []userRole.Base_Role
-	page := this.GetPageInfoForm()
-	searchkey := this.GetString("keyword")
-	where := "IsVisible=1"
-	if searchkey != "" {
-		where = where + " and Realname like '%" + searchkey + "%'"
-	}
-	total := svc.GetRoleList(page.CurrentPage, page.Size, "CreateOn", utils.ToStr(this.User.Id), &roles, where)
-	var datainfo DataInfo
-	datainfo.Items = roles
-	datainfo.CurrentItemCount = total
-	this.Data["json"] = &datainfo
-	this.ServeJSON()
-}
-
-// @Title 创建角色
-// @Description 创建角色
-// @Success	200	{object} controllers.Request
-// @router / [post]
-func (this *RoleController) RoleAddPost() {
-	var roleentity userRole.Base_Role
-	var jsonblob = this.Ctx.Input.RequestBody
-	json.Unmarshal(jsonblob, &roleentity)
-	roleentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-	roleentity.CreateBy = this.User.Realname
-	svc := userRole.GetRoleService(utils.DBE)
-	err := svc.AddRole(&roleentity)
-	var errinfo ErrorInfo
-	if err == nil {
-		errinfo.Message = utils.AlertProcess("创建角色成功!")
-		errinfo.Code = 0
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	} else {
-		errinfo.Message = utils.AlertProcess("创建角色失败!" + err.Error())
-		errinfo.Code = -1
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	}
-}
-
-// @Title 编辑角色
-// @Description 编辑角色
-// @Success	200	{object} controllers.Request
-// @router /:id [put]
-func (this *RoleController) RoleEditPost() {
-	id := this.Ctx.Input.Param(":id")
-	var roleentity userRole.Base_Role
-	var jsonblob = this.Ctx.Input.RequestBody
-	json.Unmarshal(jsonblob, &roleentity)
-	roleentity.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
-	roleentity.ModifiedBy = this.User.Realname
-	svc := userRole.GetRoleService(utils.DBE)
-	var cols []string = []string{"Realname", "Category", "Description", "ModifiedUserId", "ModifiedBy"}
-	_, err := svc.UpdateEntityByIdCols(id, &roleentity, cols)
-	var errinfo ErrorInfo
-	if err == nil {
-		errinfo.Message = utils.AlertProcess("编辑角色成功!")
-		errinfo.Code = 0
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	} else {
-		errinfo.Message = utils.AlertProcess("编辑角色失败!" + err.Error())
-		errinfo.Code = -1
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	}
-}
-
-// @Title 删除角色
-// @Description 删除角色
-// @Success 200 {object} controllers.Request
-// @router /:id [delete]
-func (this *RoleController) RoleDelete() {
-	id := this.Ctx.Input.Param(":id")
-	svc := userRole.GetRoleService(utils.DBE)
-	err := svc.DeleteRole(id)
-	var errinfo ErrorInfo
-	if err == nil {
-		errinfo.Message = utils.AlertProcess("删除角色成功!")
-		errinfo.Code = 0
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	} else {
-		errinfo.Message = utils.AlertProcess("删除角色失败!" + err.Error())
-		errinfo.Code = -1
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	}
-}
-
-// @Title 权限
-// @Description 获取角色列表
-// @Success 200 {object} controllers.Request
-// @router /getpower [get]
-func (this *RoleController) GetRolePowerAjax() {
-	//id := this.GetString("id")
-	//svc := permission.GetPermissionService(utils.DBE)
-	//currentuser := this.User
-	//userid := utils.ToStr(currentuser.Id)
-	//ztreecurrentusernodesope := svc.GetPermissionItemsByUser(userid, "0")
-	//ztreeselectedusernodesope := svc.GetPermissionItemsByRole(id, "0")
-	//
-	//ztreecurrentusernodesmodu := svc.GetModuleAll(userid, "30")
-	//ztreeselectedusernodesmodu := svc.GetModuleTreeAllByRole(id, "30")
-	//rest := RolePowerAjaxModel{ztreecurrentusernodesope, ztreeselectedusernodesope, ztreecurrentusernodesmodu, ztreeselectedusernodesmodu}
-	//this.Data["json"] = &rest
-	//this.ServeJSON()
-}
-
-// @Title 保存权限
-// @Description 保存权限
-// @Success	200	{object} controllers.Request
-// @router /savepower [put]
-func (this *RoleController) RolePowerPost() {
-	//svc := permission.GetPermissionService(utils.DBE)
-	//roleid := this.GetString("id")
-	//var errinfo ErrorInfo
-	//if roleid == "" {
-	//	errinfo.Message = utils.AlertProcess("操作失败!请求信息不完整!")
-	//	errinfo.Code = -2
-	//	this.Data["json"] = &errinfo
-	//	this.ServeJSON()
-	//}
-
-	//	svc.RevokeRolePermission(roleid)       //撤销角色的操作权限
-	//svc.RevokeRoleModulePermission(roleid) //撤销角色的模块访问权限
-	//	operationids := strings.Split(this.GetString("operids"), ",")
-	//moduleids := strings.Split(this.GetString("moduleids"), ",")
-	//uid, _ := utils.StrTo(this.User.Id).Int()
-	//	if this.GetString("operids") != "" {
-	//		for i := 0; i < len(operationids); i++ {
-	//			operationid, _ := utils.StrTo(operationids[i]).Int()
-	//			svc.GrantRolePermission(roleid, operationid, userRole.Base_User{Id: uid, Realname: this.User.Realname})
-	//		}
-	//	}
-//	if this.GetString("moduleids") != "" {
-//		for j := 0; j < len(moduleids); j++ {
-//			moduleid := utils.ToStr(moduleids[j])
-//			svc.GrantRoleModulePermission(roleid, moduleid, userRole.Base_User{Id: uid, Realname: this.User.Realname})
-//		}
-//	}
-//	errinfo.Message = utils.AlertProcess("权限保存成功!")
-//	errinfo.Code = 0
-//	this.Data["json"] = &errinfo
-//	this.ServeJSON()
-}
-
-// @Title 获取角色设备权限
-// @Description 获取角色设备权限
-// @Success 200 {object} controllers.Request
-// @router /getroleequidpower [get]
-func (this *RoleController) GetRoleEquidPowerAjax() {
-	id := this.GetString("id")
-	svc := userequipment.GetUserEquipmentService(utils.DBE)
-	eids := svc.GetEquipmentidsByroleid(id)
-	this.Data["json"] = &eids
-	this.ServeJSON()
-}
-
-// @Title 保存设备权限
-// @Description 保存设备权限
-// @Success	200	{object} controllers.Request
-// @router /saveequpipower [put]
-func (this *RoleController) SaveequpiPower() {
-	svc := userequipment.GetUserEquipmentService(utils.DBE)
-	roleid := this.GetString("id")
-	ids := strings.Split(this.GetString("selectedids"), ",")
-	rid, _ := utils.StrTo(roleid).Int()
-	//清空角色权限
-	svc.ClearRoleEquipment(this.User.AccCode, rid)
-	var uc userequipment.Base_RoleEquipment
-	uc.RoleId = rid
-	uc.AccCode = this.User.AccCode
-	uc.Createuserid, _ = utils.StrTo(this.User.Id).Int()
-	uc.Createby = this.User.Realname
-	for i := 0; i < len(ids); i++ {
-		id, _ := utils.StrTo(ids[i]).Int()
-		if id != 0 {
-			uc.EquipmentId = id
-			svc.InsertEntity(&uc)
-		}
-	}
-	var errinfo ErrorInfo
-	errinfo.Message = utils.AlertProcess("权限保存成功!")
-	errinfo.Code = 0
-	this.Data["json"] = &errinfo
-	this.ServeJSON()
-}
-
-// @Title 权限
-// @Description 获取角色操作列表
-// @Success 200 {object} controllers.Request
-// @router /getItemPower [get]
-func (this *RoleController) GetRoleItemPowerAjax() {
-	id := this.GetString("id")
-	svc := permission.GetPermissionService(utils.DBE)
-	currentuser := this.User
-	userid := utils.ToStr(currentuser.Id)
-	ztreecurrentusernodesope := svc.GetPermissionItemsByUserV2(userid, "0")
-	ztreeselectedusernodesope := svc.GetPermissionItemsByRoleV2(id, "0")
-
-	rest := RolePerAjaxModel{ztreecurrentusernodesope, ztreeselectedusernodesope}
-	this.Data["json"] = &rest
-	this.ServeJSON()
-}
-
-// @Title 保存操作权限
-// @Description 保存权限
-// @Success	200	{object} controllers.Request
-// @router /saveOperationPower [put]
-func (this *RoleController) RoleOperationPowerPost() {
-	//svc := permission.GetPermissionService(utils.DBE)
-	//roleid := this.GetString("id")
-	//var errinfo ErrorInfo
-	//if roleid == "" {
-	//	errinfo.Message = utils.AlertProcess("操作失败!请求信息不完整!")
-	//	errinfo.Code = -2
-	//	this.Data["json"] = &errinfo
-	//	this.ServeJSON()
-	//	return
-	//}
-	//
-	//svc.RevokeRolePermissionV2(roleid) //撤销角色的操作访问权限
-	//operationids := strings.Split(this.GetString("operids"), ",")
-	//uid, _ := utils.StrTo(this.User.Id).Int()
-	//if this.GetString("operids") != "" {
-	//	for i := 0; i < len(operationids); i++ {
-	//		if strings.HasPrefix(operationids[i], "self_") {
-	//			_operationid := []byte(operationids[i])[5:]
-	//			operationid, _ := utils.StrTo(_operationid).Int()
-	//			err := svc.GrantRoleRolePermission(roleid, roleid, operationid, userRole.Base_User{Id: uid, Realname: this.User.Realname})
-	//			if err != nil {
-	//				beego.Debug("insert error:", err)
-	//				continue
-	//			}
-	//		} else {
-	//			operationid, _ := utils.StrTo(operationids[i]).Int()
-	//			err := svc.GrantRolePermission(roleid, operationid, userRole.Base_User{Id: uid, Realname: this.User.Realname})
-	//			if err != nil {
-	//				beego.Debug("insert error:", err)
-	//				continue
-	//			}
-	//		}
-	//	}
-	//}
-	//errinfo.Message = utils.AlertProcess("权限保存成功!")
-	//errinfo.Code = 0
-	//this.Data["json"] = &errinfo
-	//this.ServeJSON()
-}
-
-// @Title 权限
-// @Description 获取角色操作列表
-// @Success 200 {object} controllers.Request
-// @router /getRoleOpsRolePower [get]
-func (this *RoleController) GetRoleItemRoleAjax() {
-	/*id := this.GetString("id")
-	perId := this.GetString("perId")
-	svc := permission.GetPermissionService(utils.DBE)
-	roleIds := svc.GetRoleByRolePermission(id, perId)
-	this.Data["json"] = roleIds
-	this.ServeJSON()*/
-}
-
-// @Title 保存操作权限的角色列表
-// @Description 保存权限
-// @Success	200	{object} controllers.Request
-// @router /saveRoleOpsRolePower [post]
-func (this *RoleController) RoleOperationRolePost() {
-	//svc := permission.GetPermissionService(utils.DBE)
-	//roleid := this.GetString("id")
-	//perid := this.GetString("perId")
-	//var errinfo ErrorInfo
-	//if roleid == "" || perid == "" {
-	//	errinfo.Message = utils.AlertProcess("操作失败!请求信息不完整!")
-	//	errinfo.Code = -2
-	//	this.Data["json"] = &errinfo
-	//	this.ServeJSON()
-	//	return
-	//}
-	//
-	//svc.RevokeRoleRoleScopes(roleid, perid) //撤销角色的操作访问权限
-	//roleIds := strings.Split(this.GetString("roleIds"), ",")
-	//uid, _ := utils.StrTo(this.User.Id).Int()
-	//_perid, _ := utils.StrTo(perid).Int()
-	//if this.GetString("roleIds") != "" {
-	//	for i := 0; i < len(roleIds); i++ {
-	//		err := svc.GrantRoleRolePermission(roleid, roleIds[i], _perid, userRole.Base_User{Id: uid, Realname: this.User.Realname})
-	//		if err != nil {
-	//			beego.Debug("insert error:", err)
-	//		}
-	//	}
-	//}
-	//errinfo.Message = utils.AlertProcess("权限保存成功!")
-	//errinfo.Code = 0
-	//this.Data["json"] = &errinfo
-	//this.ServeJSON()
-}
-
-// @Title 权限
-// @Description 通过角色权限获取用户列表
-// @Success 200 {object} controllers.Request
-// @router /getUsersWithRolePermission [get]
-func (this *RoleController) GetUsersWithRolePermissionAjax() {
-	//perCode := this.GetString("perCode")
-	//svc := permission.GetPermissionService(utils.DBE)
-	//perId := svc.GetPermissionId(perCode)
-	//var errinfo ErrorInfo
-	//if perId == "" {
-	//	errinfo.Message = utils.AlertProcess("权限代码错误")
-	//	errinfo.Code = -1
-	//	this.Data["json"] = &errinfo
-	//	this.ServeJSON()
-	//	return
-	//}
-	//users := svc.GetRolePermissionUserids(this.User.Id, perId, this.User.AccCode)
-	//this.Data["json"] = users
-	//this.ServeJSON()
-}

+ 0 - 924
src/dashoo.cn/backend/api/controllers/user.go

@@ -1,924 +0,0 @@
-package controllers
-
-import (
-	"encoding/json"
-	"strings"
-
-	"dashoo.cn/backend/api/business/device"
-	"dashoo.cn/backend/api/business/logsinfo"
-	"dashoo.cn/backend/api/business/organize"
-	"dashoo.cn/backend/api/business/role"
-	"dashoo.cn/backend/api/business/userchannels"
-	"dashoo.cn/backend/api/models"
-	"dashoo.cn/business2/auth"
-	"dashoo.cn/business2/permission"
-	"dashoo.cn/business2/userRole"
-	"dashoo.cn/utils"
-)
-
-// Operations about Users
-type UserController struct {
-	BaseController
-}
-
-type UserModel struct {
-	Username       string `json:"username"`
-	Realname       string `json:"realname"`
-	Telephone      string `json:"telephone"`
-	Mobile         string `json:"mobile"`
-	Description    string `json:"description"`
-	Photo          string `json:"photo"`
-	Role           string `json:"role"`
-	Id             int    `json:"id"`
-	ChannelIds     string `json:"channelids"`
-	Password       string `json:"password"`
-	DepartmentId   string `json:"departmentid"`
-	DepartmentName string `json:"departmentname"`
-	Sign           string `json:"sign"`
-}
-
-type Note struct {
-	Surplus int `json:"surplus"`
-}
-
-type UserAccountModel struct {
-	ChannelOffNum     int64 `json:"channeloffnum"`
-	ChannelTriggerNum int64 `json:"channeltriggernum"`
-	ChannelNormalNum  int64 `json:"channelnormalnum"`
-	NoteNum           int64 `json:"notenum"`
-	VoiceNum          int64 `json:"voicenum"`
-}
-
-type ChangePwdModel struct {
-	Pwd    string `json:"pass"`
-	NwePwd string `json:"newpass"`
-}
-
-type UserModuleModel struct {
-	A1list string `json:"a1"` // 第一级菜单
-	A2list string `json:"a2"` // 第二级菜单
-}
-
-type RegisteModel struct {
-	Companyname string `json:"companyname"`
-	Username    string `json:"username"`
-	Password    string `json:"password"`
-	Source      string `json:"source"`
-}
-
-// @Title get
-// @Description get user by token
-// @Param	uid		path 	string	true		"The key for staticblock"
-// @Success 200 {object} models.User
-// @Failure 403 :uid is empty
-// @router /me [get]
-func (this *UserController) Get() {
-	svc := userRole.GetUserService(utils.DBE)
-	usermodel := svc.GetUserInfoSelf(this.User.Username)
-	//	var companyentity company.Base_Company
-	//	svc.GetEntityById(usermodel.AccCode, &companyentity)
-	var user models.User
-	user.Id = utils.ToStr(usermodel.Id)
-	user.Username = usermodel.Username
-	user.Profile.Address = usermodel.Homeaddress
-	user.Profile.Email = usermodel.Email
-	user.Profile.Realname = usermodel.Realname
-	user.Profile.Roleid = usermodel.Roleid
-	user.Profile.Mobile = usermodel.Mobile
-	user.Profile.Telephone = usermodel.Telephone
-	user.Profile.Photo = usermodel.Photo
-	user.Profile.Description = usermodel.Description
-	user.Profile.Host = this.Ctx.Request.Host
-	user.Profile.AccCode = usermodel.AccCode
-	user.Profile.DepartmentId = usermodel.Departmentid
-	user.Profile.Id = usermodel.Id
-	// todo 从this.User获取用户名,再查询出具体用户
-	//	user := models.User{"user01", "张三", models.Profile{Gender: "male", Age: 20, Address: "china", Email: "123zs@gmail.com", Realname: "ppppppp"}}
-	this.Data["json"] = user
-	this.ServeJSON()
-}
-
-// @Title 获取账户信息
-// @Description 获取账户信息
-// @Success 200 {object} models.User
-// @router /account [get]
-func (this *UserController) GetAccount() {
-	u, p := this.GetuAndp()
-	var model UserAccountModel
-	svc := userchannels.GetUserChannelService(utils.DBE)
-	channelid := svc.GetChannelids(utils.ToStr(this.User.Id))
-	where := " (CreateUserId=" + utils.ToStr(this.User.Id) + " or Id in (" + strings.Join(channelid, ",") + ")) and DataItem in (" + ChannelItem_Sensor + ")"
-
-	var entity device.Channels
-	model.ChannelNormalNum, _ = svc.GetCount(&entity, where+" and ChannelState in (1,0)")
-	model.ChannelOffNum, _ = svc.GetCount(&entity, where+" and ChannelState in (2)")
-	model.ChannelTriggerNum, _ = svc.GetCount(&entity, where+" and ChannelState in (3)")
-
-	var note Note
-	strUrlnote := utils.Cfg.MustValue("server", "apiurl") + "/accountinfos/get?u=" + u + "&p=" + p + "&source=coldchain&account=" + this.GetAccode() + "&atype=sms"
-	json.Unmarshal(Apiget(strUrlnote), &note)
-	model.NoteNum = int64(note.Surplus)
-
-	//语音剩余
-	var voice Note
-	strUrlvoice := utils.Cfg.MustValue("server", "apiurl") + "/accountinfos/get?u=" + u + "&p=" + p + "&source=coldchain&account=" + this.GetAccode() + "&atype=voice"
-	json.Unmarshal(Apiget(strUrlvoice), &voice)
-	model.VoiceNum = int64(voice.Surplus)
-
-	this.Data["json"] = model
-	this.ServeJSON()
-}
-
-// @Title 获取账户统计信息
-// @Description 获取账户统计信息
-// @Success	200	{object} controllers.Request
-// @router /getaccountingo [get]
-func (this *UserController) GetAccountInfo() {
-
-	//	svcs := equipment.GetEquipmentService(utils.DBE)
-	//	svcrole := role.GetRoleService(utils.DBE)
-	//	roleids := svcrole.GetRoleidsByuid(utils.ToStr(this.User.Id))
-	//	where := " a.AccCode = '" + this.User.AccCode + "'"
-	//	where = where + " and (a.CreateUserId=" + utils.ToStr(this.User.Id) + " or a.Id in (select EquipmentId Id FROM Base_RoleEquipment where RoleId in (" + strings.Join(roleids, ",") + ")))"
-
-	//	devicetotal, _ := svcs.GetEquipmenViewtList(1, 1, "a.Id", where)
-
-	//	//已录入样本
-	//	where1 := " IState =1 and DeletionStateCode=0 "
-
-	//	poweeids := svcs.GetPowerEquipmentids(this.User.AccCode, utils.ToStr(this.User.Id))
-	//	where1 = where1 + " and  a.EquipmentId in(" + strings.Join(poweeids, ",") + ")"
-	//	svc := samplesinfo.GetSamplesInfoService(utils.DBE)
-	//	yilurutotal, _ := svc.GetPagingEntitiesWithOrderSearch(this.User.AccCode, 1, 1, "Id desc", where1)
-	//	// 预录入
-	//	where2 := " a.IState in (2,3,4,7,8) and a.DeletionStateCode=0 "
-	//	yulurutotal, _ := svc.GetPagingEntitiesWithOrderSearch(this.User.AccCode, 1, 1, "Id desc", where2)
-
-	//	//待复存
-	//	where3 := " DeletionStateCode=0 and (IState=6 or ( IState=5 and a.EquipmentId in(" + strings.Join(poweeids, ",") + ")))"
-	//	daifuchuntotal, _ := svc.GetPagingEntitiesWithOrderSearch(this.User.AccCode, 1, 1, "Id desc", where3)
-
-	//	//已归档
-	//	svcf := samplesfileinfo.GetSamplesFileInfoService(utils.DBE)
-	//	where4 := " DeletionStateCode=0  "
-	//	yiguidangtotal, _ := svcf.GetPagingEntitiesWithOrderSearch(this.User.AccCode, 1, 1, "Id desc", where4)
-
-	//	//待办事项
-	//	svcw := samplesapply.GetSamplesApplyService(utils.DBE)
-	//	where_rk := " ApplyType = 1 and ApplyStatus = 0 "
-	//	rktotal, rklist := svcw.GetApplyViewtList(1, 1, this.User.AccCode+SamplesApplyName, "Id", where_rk)
-	//	where_ck := " ApplyType = 2 and ApplyStatus = 0 "
-	//	cktotal, cklist := svcw.GetApplyViewtList(1, 1, this.User.AccCode+SamplesApplyName, "Id", where_ck)
-
-	//	//待随访
-	//	svcsf := flupplan.GetFlupPlanService(utils.DBE)
-	//	where_sf := " a.AccCode='" + this.User.AccCode + "' and a.DeletionStateCode=0 "
-	//	sftotal, _ := svcsf.GetPagingEntitiesWithOrderSearch(1, 1, "a.Id desc", where_sf, this.User.AccCode+DonorstbName)
-
-	//	this.Data["json"] = AccountTjModel{devicetotal, yilurutotal, yulurutotal, daifuchuntotal, yiguidangtotal, sftotal, rktotal, rklist, cktotal, cklist}
-	//	this.ServeJSON()
-}
-
-// @Title get
-// @Description get user by token
-// @Success 200 {object} models.User
-// @router /list [get]
-func (this *UserController) List() {
-	page := this.GetPageInfoForm()
-	keyword := this.GetString("keyword")
-	svc := permission.GetPermissionService(utils.DBE)
-	var users []userRole.Base_User
-
-	//是否开启组织结构
-	//	isopenorg := IsAuthorized(this.User.Id, "coldclouds.user.openorg")
-	//	var orgtree []organize.Base_Organizetree
-	//	svc1 := device.GetDeviceService(utils.DBE)
-	//	uid := utils.ToStr(this.User.Id)
-	//	wherebindingcompany := "CreateUserId=" + uid
-	//	wheredevice := " a.DataItem in (" + ChannelItem_Sensor + ") and a.CreateUserId=" + utils.ToStr(this.User.Id)
-	//	tree := svc1.GetTree_OrgAndDevice(wherebindingcompany, wheredevice, uid, isopenorg)
-	//orgtree = append(tree, organize.Base_Organizetree{Id: 0, ParentId: -1, FullName: this.User.Realname, Icon: "/static/img/1_open.png"})
-	//	orgtree = append(tree, organize.Base_Organizetree{Id: 0, ParentId: -1, FullName: this.User.Realname})
-	//	this.Data["orgtree"] = orgtree
-
-	where := "IsVisible=1 and CreateUserId='" + utils.ToStr(this.User.Id) + "' or Id = '" + utils.ToStr(this.User.Id) + "' "
-	if keyword != "" {
-		where = where + " and Realname like '%" + keyword + "%'"
-	}
-	total := svc.GetPagingEntitiesWithOrder(page.CurrentPage, page.Size, "Id", false, &users, where)
-
-	var datainfo DataInfo
-	datainfo.Items = users
-	datainfo.CurrentItemCount = total
-	this.Data["json"] = &datainfo
-	this.ServeJSON()
-}
-
-// @Title get
-// @Description get user by token
-// @Success 200 {object} models.User
-// @router /usualwithrole [get]
-func (this *UserController) UsualWithRole() {
-	page := this.GetPageInfoForm()
-	keyword := this.GetString("keyword")
-	svc := permission.GetPermissionService(utils.DBE)
-	var users []userRole.UserRoleModel
-	orderby := "a.Id desc"
-	Order := this.GetString("Order")
-	Prop := this.GetString("Prop")
-	if Order != "" && Prop != "" {
-		orderby = Prop + " " + Order
-	}
-	where := "a.IsVisible=1 and d.GroupId is NULL "
-	where += " and ( a.CreateUserId='" + utils.ToStr(this.User.Id) + "' or a.Id = '" + utils.ToStr(this.User.Id) + "' )"
-	if keyword != "" {
-		where = where + " and a.UserName like '%" + keyword + "%'"
-	}
-
-	total, users := svc.GetUserListWithRole(page.CurrentPage, page.Size, orderby, where)
-	var datainfo DataInfo
-	datainfo.Items = users
-	datainfo.CurrentItemCount = total
-	this.Data["json"] = &datainfo
-	this.ServeJSON()
-}
-
-// @Title get
-// @Description get user by token
-// @Success 200 {object} models.User
-// @router /listwithrole [get]
-func (this *UserController) ListWithRole() {
-	//page := this.GetPageInfoForm()
-	//keyword := this.GetString("keyword")
-	//svc := permission.GetPermissionService(utils.DBE)
-	//var users []userRole.UserRoleModel
-	//orderby := "m.Id desc"
-	//Order := this.GetString("Order")
-	//Prop := this.GetString("Prop")
-	//if Order != "" && Prop != "" {
-	//	orderby = Prop + " " + Order
-	//}
-	//where := "a.IsVisible=1 and a.CreateUserId='" + utils.ToStr(this.User.Id) + "' or a.Id = '" + utils.ToStr(this.User.Id) + "' "
-	//if keyword != "" {
-	//	where = where + " and a.Realname like '%" + keyword + "%'"
-	//}
-	//total, users := svc.GetPartnerListWithRole(page.CurrentPage, page.Size, this.User.AccCode+GroupDetailName, orderby, where)
-	//var datainfo DataInfo
-	//datainfo.Items = users
-	//datainfo.CurrentItemCount = total
-	//this.Data["json"] = &datainfo
-	//this.ServeJSON()
-}
-
-// @Title 创建用户
-// @Description 创建用户
-// @Param	body	body	business.device.DeviceChannels	"传感器信息"
-// @Success	200	{object} controllers.Request
-// @router / [post]
-func (this *UserController) AddUser() {
-	/*var model UserModel
-	var jsonblob = this.Ctx.Input.RequestBody
-	json.Unmarshal(jsonblob, &model)
-	var errinfo ErrorDataInfo
-	departidint, _ := utils.StrTo(model.DepartmentId).Int()
-	if departidint < 1 {
-		errinfo.Message = "请选择所属组织!"
-		errinfo.Code = -3
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}
-	//获取组织名称
-	svcorg := organize.GetOrganizeService(utils.DBE)
-	model.DepartmentName = svcorg.GetNameById(model.DepartmentId)
-
-	var userentity userRole.Base_User
-	userentity.Roleid, _ = utils.StrTo(model.Role).Int()
-	if userentity.Roleid == 0 {
-		//userentity.Roleid = 10000123 //普通用户
-	}
-	userentity.Username = model.Username
-	userentity.Realname = model.Realname
-	userentity.Telephone = model.Telephone
-	userentity.Mobile = model.Mobile
-	if model.Sign == "" {
-		userentity.Description = model.Description
-	} else {
-		userentity.Description = model.Sign
-	}
-	userentity.Photo = model.Photo
-
-	currentuser := this.User
-	userentity.Createuserid, _ = utils.StrTo(currentuser.Id).Int()
-	userentity.Createby = currentuser.Realname
-	userentity.AccCode = this.GetAccode()
-
-	userentity.QRCode = utils.GetGuid()
-	userentity.Departmentid = model.DepartmentId
-	userentity.Departmentname = model.DepartmentName
-
-	//salt := utils.GetRandomString(5)
-	//userentity.Userpassword = fmt.Sprintf("%s$%s", salt, utils.EncodePassword("123456", salt))
-	//更改密码算法2014-11-21
-	pwd, key, errrk := utils.TripleDesEncrypt("123456")
-	if errrk != nil {
-		errinfo.Message = "添加失败!" + utils.AlertProcess(errrk.Error())
-		errinfo.Code = -2
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}
-	userentity.Userpassword = pwd
-	userentity.Publickey = key
-	userentity.Auditstatus = 1
-	userentity.Email = userentity.Username
-	svc := userRole.GetUserService(utils.DBE)
-	err := svc.AddUser(&userentity)
-
-	if err == nil {
-		errinfo.Message = "添加用户成功,初始密码为123456!"
-		errinfo.Code = 0
-		errinfo.Item = userentity.Id
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	} else {
-		errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
-		errinfo.Code = -1
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}*/
-}
-
-// @Title 编辑用户
-// @Description 编辑用户
-// @Param	id	path	string	true		"需要修改的传感器编号"
-// @Param	body	body	business.device.DeviceChannels	"传感器信息"
-// @Success	200	{object} controllers.Request
-// @router /:id [put]
-func (this *UserController) EditUser() {
-	id := this.Ctx.Input.Param(":id")
-	var errinfo ErrorInfo
-	if id == "" {
-		errinfo.Message = "操作失败!请求信息不完整"
-		errinfo.Code = -2
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}
-	var model UserModel
-	var jsonblob = this.Ctx.Input.RequestBody
-	json.Unmarshal(jsonblob, &model)
-
-	var userentity userRole.Base_User
-	var userentityempty userRole.Base_User
-	svc := userRole.GetUserService(utils.DBE)
-	has := svc.GetEntityById(id, &userentity)
-	if has {
-		//获取组织名称
-		svcorg := organize.GetOrganizeService(utils.DBE)
-		model.DepartmentName = svcorg.GetNameById(model.DepartmentId)
-		//		roleid, _ := utils.StrTo(model.Role).Int()
-		//		if userentity.Roleid != roleid {
-		//			svc.ClearUserRole(id)
-		//			svc.AddUserToRole(id, model.Role, userentity)
-		//		}
-		userentity.Realname = model.Realname
-		userentity.Telephone = model.Telephone
-		userentity.Mobile = model.Mobile
-		if model.Sign == "" {
-			userentity.Description = model.Description
-		} else {
-			userentity.Description = model.Sign
-		}
-		userentity.Photo = model.Photo
-		//		userentity.Roleid = roleid
-		userentity.Modifieduserid, _ = utils.StrTo(this.User.Id).Int()
-		userentity.Modifiedby = this.User.Realname
-		userentity.Departmentid = model.DepartmentId
-		userentity.Departmentname = model.DepartmentName
-
-		var cols []string = []string{"Realname", "DepartmentId", "DepartmentName", "Telephone", "Mobile", "Description", "Photo", "Modifieduserid", "Modifiedby"}
-
-		err := svc.UpdateEntityAndBackupByCols(id, &userentity, &userentityempty, cols, utils.ToStr(this.User.Id), this.User.Realname)
-
-		if err == nil {
-			errinfo.Message = "保存成功!"
-			errinfo.Code = 0
-			this.Data["json"] = &errinfo
-			this.ServeJSON()
-		} else {
-			errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
-			errinfo.Code = -1
-			this.Data["json"] = &errinfo
-			this.ServeJSON()
-		}
-	} else {
-		errinfo.Message = "操作失败!操作数据不存在"
-		errinfo.Code = -3
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}
-
-}
-
-// @Title 删除用户
-// @Description 删除用户
-// @Param	id		path 	string	true		"需要删除的用户编号"
-// @Success 200 {object} ErrorInfo
-// @Failure 403 :id 为空
-// @router /:id [delete]
-func (this *UserController) Delete() {
-	id := this.Ctx.Input.Param(":id")
-	var errinfo ErrorInfo
-	if id == "" {
-		errinfo.Message = "操作失败!请求信息不完整"
-		errinfo.Code = -2
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}
-	var entity userRole.Base_User
-	var entityempty userRole.Base_User
-	svc := userRole.GetUserService(utils.DBE)
-	err := svc.DeleteEntityAndBackup(id, &entity, &entityempty, utils.ToStr(this.User.Id), this.User.Username)
-	if err == nil {
-		svc.ClearUserRole(id) //清除角色
-		errinfo.Message = "删除成功"
-		errinfo.Code = 0
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	} else {
-		errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
-		errinfo.Code = -1
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	}
-}
-
-// @Title 创建用户
-// @Description 创建用户
-// @Param	id	path	string	true		"需要修改的传感器编号"
-// @Param	body	body	business.device.DeviceChannels	"传感器信息"
-// @Success	200	{object} controllers.Request
-// @router /permission/:id [put]
-func (this *UserController) SetPermission() {
-	id := this.Ctx.Input.Param(":id")
-	var errinfo ErrorInfo
-	if id == "" {
-		errinfo.Message = "操作失败!请求信息不完整"
-		errinfo.Code = -2
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}
-	var model UserModel
-	var jsonblob = this.Ctx.Input.RequestBody
-	json.Unmarshal(jsonblob, &model)
-	svc := userchannels.GetUserChannelService(utils.DBE)
-
-	ids := strings.Split(model.ChannelIds, ",")
-	uid, _ := utils.StrTo(id).Int()
-	svc.ClearUserChannel(uid)
-	var uc userchannels.Base_UserChannels
-	uc.UserId = uid
-	uc.AccCode = this.GetAccode()
-	uc.Createuserid, _ = utils.StrTo(this.User.Id).Int()
-	uc.Createby = this.User.Realname
-	for i := 0; i < len(ids); i++ {
-		id, _ := utils.StrTo(ids[i]).Int()
-		if id != 0 {
-			uc.ChannelsId = id
-			svc.InsertEntity(&uc)
-		}
-	}
-
-	errinfo.Message = "权限调整成功"
-	errinfo.Code = 0
-	this.Data["json"] = &errinfo
-	this.ServeJSON()
-
-}
-
-// @Title 创建用户
-// @Description 创建用户
-// @Param	id	path	string	true		"需要修改的传感器编号"
-// @Param	body	body	business.device.DeviceChannels	"传感器信息"
-// @Success	200	{object} controllers.Request
-// @router /permission/:id [get]
-func (this *UserController) GetPermission() {
-	id := this.Ctx.Input.Param(":id")
-	svc := userchannels.GetUserChannelService(utils.DBE)
-	this.Data["json"] = svc.GetChannelids(id)
-	this.ServeJSON()
-}
-
-// @Title 创建用户
-// @Description 创建用户
-// @Param	id	path	string	true		"需要修改的传感器编号"
-// @Param	body	body	business.device.DeviceChannels	"传感器信息"
-// @Success	200	{object} controllers.Request
-// @router /resetpwd/:id [put]
-func (this *UserController) ResetPassWord() {
-	id := this.Ctx.Input.Param(":id")
-	var errinfo ErrorInfo
-	uid, err := utils.StrTo(id).Int()
-	if err == nil {
-		svcauth := auth.GetAuthServic(utils.DBE)
-		var umodel userRole.Base_User = userRole.Base_User{Id: uid}
-		var entitypaw1, entitypaw2 logsinfo.Userpassword
-		svcauth.UpdateLog(id, &entitypaw1, &entitypaw2, utils.ToStr(this.User.Id), this.User.Realname)
-		errset := svcauth.SetNewPassword3DES(&umodel, "123456")
-		if errset == nil {
-			errinfo.Message = "密码重置成功!已重置为:123456"
-			errinfo.Code = 0
-			this.Data["json"] = &errinfo
-			this.ServeJSON()
-		} else {
-			errinfo.Message = "密码重置失败!" + utils.AlertProcess(err.Error())
-			errinfo.Code = -1
-			this.Data["json"] = &errinfo
-			this.ServeJSON()
-		}
-
-	} else {
-		errinfo.Message = "操作失败!请求信息不完整"
-		errinfo.Code = -2
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	}
-
-}
-
-// @Title 创建用户
-// @Description 创建用户
-// @Param	body	body	business.device.DeviceChannels	"传感器信息"
-// @Success	200	{object} controllers.Request
-// @router /uploadphoto [post]
-func (this *UserController) UploadPhoto() {
-	var path string
-	path = "/static/upload/img/user/"
-	photopath := UploadImage("png", path, this.Ctx.Request)
-
-	this.Data["json"] = photopath
-	this.ServeJSON()
-}
-
-// @Title 创建用户
-// @Description 创建用户
-// @Param	body	body	business.device.DeviceChannels	"传感器信息"
-// @Success	200	{object} controllers.Request
-// @router /membersetting [put]
-func (this *UserController) MemberSetting() {
-	var model models.Profile
-	var jsonblob = this.Ctx.Input.RequestBody
-	json.Unmarshal(jsonblob, &model)
-	var errinfo ErrorInfo
-	svc := userRole.GetUserService(utils.DBE)
-	userentity := svc.GetUserInfoSelf(this.User.Username)
-	userentity.Homeaddress = model.Address
-	userentity.Email = model.Email
-	userentity.Realname = model.Realname
-	userentity.Mobile = model.Mobile
-	userentity.Telephone = model.CompanyCode
-	userentity.Photo = model.Photo
-	userentity.Description = model.Description
-
-	var userentityempty userRole.Base_User
-
-	userentity.Modifieduserid = userentity.Id
-	userentity.Modifiedby = userentity.Realname
-
-	var cols []string = []string{"Realname", "Telephone", "Email", "Photo", "Description", "Modifieduserid", "Modifiedby", "Homeaddress", "Mobile"}
-	err := svc.UpdateEntityAndBackupByCols(userentity.Id, &userentity, &userentityempty, cols, utils.ToStr(this.User.Id), this.User.Realname)
-	if err == nil {
-		//		var companyentity company.Base_Company
-		//		companyentity.Fullname = userentity.Realname
-		//		companyentity.Address = userentity.Homeaddress
-		//		var cols []string = []string{"Fullname", "Address", "OuterPhone", "Manager", "Code"}
-		//		svc.UpdateEntityByIdCols(userentity.AccCode, &companyentity, cols)
-		if "10000120" == this.User.Roles { // 企业管理员
-			//修改根组织
-			var orgentity organize.Base_Organize
-			orgentity.Fullname = userentity.Realname
-			var orgcols []string = []string{"Fullname"}
-			svc.UpdateEntityByIdCols(userentity.Departmentid, &orgentity, orgcols)
-		}
-		errinfo.Message = "设置成功"
-		errinfo.Code = 0
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	} else {
-		errinfo.Message = "设置失败!" + utils.AlertProcess(err.Error())
-		errinfo.Code = 0
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	}
-}
-
-// @Title 修改密码
-// @Description 修改密码
-// @Param	body	body	business.device.DeviceChannels	"传感器信息"
-// @Success	200	{object} controllers.Request
-// @router /userchangepwd [put]
-func (this *UserController) UserChangePWD() {
-	var model ChangePwdModel
-	var jsonblob = this.Ctx.Input.RequestBody
-	json.Unmarshal(jsonblob, &model)
-	var errinfo ErrorInfo
-
-	svcauth := auth.GetAuthServic(utils.DBE)
-	var user userRole.Base_User
-
-	if svcauth.VerifyUser3DES(this.User.Username, model.Pwd, &user) {
-		var entitypaw1, entitypaw2 logsinfo.Userpassword
-		idint, _ := utils.StrTo(this.User.Id).Int()
-		var umodel userRole.Base_User = userRole.Base_User{Id: idint}
-		svcauth.UpdateLog(this.User.Id, &entitypaw1, &entitypaw2, this.User.Id, this.User.Realname)
-		err := svcauth.SetNewPassword3DES(&umodel, model.NwePwd)
-		if err != nil {
-			errinfo.Message = "修改失败!" + err.Error()
-			errinfo.Code = -2
-			this.Data["json"] = &errinfo
-			this.ServeJSON()
-		} else {
-			errinfo.Message = "密码修改成功"
-			errinfo.Code = 0
-			this.Data["json"] = &errinfo
-			this.ServeJSON()
-		}
-	} else {
-		errinfo.Message = "修改失败!当前密码输入错误"
-		errinfo.Code = -1
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}
-
-}
-
-// @Title 按样本类型统计样本数量
-// @Description 按样本类型统计样本数量
-// @Success	200	{object} controllers.Request
-// @router /gettotalbysampletype [get]
-//func (this *UserController) GetTotalByGroupbysampletype() {
-//	diseases := this.GetString("diseases")
-//	svc := samplesinfo.GetSamplesInfoService(utils.DBE)
-//	where := " a.DeletionStateCode=0 "
-//	if diseases != "" {
-//		where = where + " and c.PathologicalNum = '" + diseases + "'"
-//	}
-//	this.Data["json"] = svc.GetTJBysampletype(this.User.AccCode, where)
-//	this.ServeJSON()
-//}
-
-// @Title 按设备统计样本数量
-// @Description 按设备统计样本数量
-// @Success	200	{object} controllers.Request
-// @router /gettotalbygroupbydevice [get]
-//func (this *UserController) GetTotalByGroupbydevice() {
-//	svcrole := role.GetRoleService(utils.DBE)
-//	roleids := svcrole.GetRoleidsByuid(utils.ToStr(this.User.Id))
-//	where := " a.AccCode = '" + this.User.AccCode + "'"
-//	where = where + " and b.IState =1 and b.DeletionStateCode=0 and (a.CreateUserId=" + utils.ToStr(this.User.Id) + " or a.Id in (select EquipmentId Id FROM Base_RoleEquipment where RoleId in (" + strings.Join(roleids, ",") + ")))"
-
-//	svc := samplesinfo.GetSamplesInfoService(utils.DBE)
-
-//	this.Data["json"] = svc.GetTJBydevice(this.User.AccCode, where)
-//	this.ServeJSON()
-//}
-
-// @Title 用户角色设置
-// @Description 用户角色设置
-// @Success	200	{object} controllers.Request
-// @router /setuserrole/:id [put]
-func (this *UserController) UserPowerPostRole() {
-	//svc := userRole.GetUserService(utils.DBE)
-	//inputstr := this.Ctx.Input.Param(":id")
-	//serial := strings.Split(inputstr, "_")
-	//userid := serial[0]
-	//var errinfo ErrorInfo
-	//if userid == "" || userid == "0" {
-	//	errinfo.Message = "操作失败!请求信息不完整"
-	//	errinfo.Code = -2
-	//	this.Data["json"] = &errinfo
-	//	this.ServeJSON()
-	//	return
-	//}
-	//roleids := strings.Split(serial[1], ",")
-	//svc.ClearUserRole(userid)
-	//entity := svc.GetReport(userid)
-	//var err error = nil
-	//for i := 0; i < len(roleids); i++ {
-	//	if roleids[i] != "0" && roleids[i] != "" {
-	//		err = svc.AddUserToRole(userid, roleids[i], entity[0])
-	//	}
-	//}
-	//if err == nil {
-	//	errinfo.Message = utils.AlertProcess("用户角色调整成功!")
-	//	errinfo.Code = 0
-	//	this.Data["json"] = &errinfo
-	//	this.ServeJSON()
-	//} else {
-	//	errinfo.Message = utils.AlertProcess("用户角色调整失败!" + err.Error())
-	//	errinfo.Code = -1
-	//	this.Data["json"] = &errinfo
-	//	this.ServeJSON()
-	//}
-}
-
-// @Title 获得用户角色id
-// @Description 获得用户角色id
-// @Success	200	{object} controllers.Request
-// @router /getuserrole/:id [get]
-func (this *UserController) UserPowerCheckRole() {
-	userid := this.Ctx.Input.Param(":id")
-	svc := role.GetRoleService(utils.DBE)
-	roleofuser := svc.GetSelfRoleids(userid)
-	this.Data["json"] = &roleofuser
-	this.ServeJSON()
-}
-
-// @Title 注册管理账号
-// @Description 注册管理账号
-// @Param	body	body	business.device.DeviceChannels	"传感器信息"
-// @Success	200	{object} controllers.Request
-// @router /registemanage [put]
-//func (this *UserController) Registerput() {
-
-//	var model RegisteModel
-//	var jsonblob = this.Ctx.Input.RequestBody
-//	json.Unmarshal(jsonblob, &model)
-//	var errinfo ErrorInfo
-
-//	var user userRole.Base_User
-//	user.Username = model.Username
-//	user.Realname = model.Companyname
-//	//	this.ParseForm(&user) //去页面数值
-//	svc := company.GetCompanyService(utils.DBE)
-//	err, comacccode := svc.AddCompany(user.Realname, user.Username) //这两个参数传到company库,返回id
-//	if err == nil {
-//		svcuser := userRole.GetUserService(utils.DBE)
-//		user.AccCode = comacccode //id传到 user库的acccode
-//		pass := model.Password    //取到前台密码
-//		//更改密码算法2014-11-21
-//		pwd, key, errrk := utils.TripleDesEncrypt(pass)
-//		if errrk != nil {
-//			errinfo.Message = "添加失败!" + utils.AlertProcess(errrk.Error())
-//			errinfo.Code = -2
-//			this.Data["json"] = &errinfo
-//			this.ServeJSON()
-//			return
-//		}
-//		user.Roleid = 10000120 //企业用户
-//		user.Auditstatus = 1
-//		user.Userpassword = pwd
-//		user.Publickey = key
-//		user.Email = user.Username
-//		err = svcuser.AddUser(&user)
-
-//		svcSampleOrgan := sampleorgan.GetSampleOrganService(utils.DBE)
-//		var entityOrgan sampleorgan.SampleOrgan
-//		entityOrgan.AccCode = comacccode
-//		entityOrgan.TNode = "SystemInner"
-//		entityOrgan.TNodeParent = "0"
-//		entityOrgan.Item = 1
-//		entityOrgan.Code = "ALL"
-//		entityOrgan.Name = "全部"
-//		entityOrgan.CreateBy = user.Username
-//		entityOrgan.CreateUserId = user.Id
-//		_, err = svcSampleOrgan.InsertEntity(&entityOrgan)
-//		svcPrintScheme := printscheme.GetPrintSchemeService(utils.DBE)
-//		var listPrintScheme []printscheme.PrintScheme
-//		var listPrintScheme_new []printscheme.PrintScheme
-//		listPrintScheme = svcPrintScheme.GetPrintSchemeList("IsSystem=2")
-//		for i := 0; i < len(listPrintScheme); i++ {
-//			listPrintScheme[i].IsSystem = 1
-//			listPrintScheme[i].CreateBy = user.Username
-//			listPrintScheme[i].CreateUserId = user.Id
-//			listPrintScheme[i].AccCode = user.AccCode
-//			listPrintScheme_new = append(listPrintScheme_new, listPrintScheme[i])
-//		}
-//		svc.InsertEntity(&listPrintScheme_new)
-//		if err == nil {
-//			//创建表结构
-//			err := svc.CreateSampleDonorTable(user.AccCode, model.Source)
-//			if err != nil {
-//				fmt.Println(err.Error())
-//			}
-//			//写入账户信息,赠送短信
-//			var accountinfo accountinfo.AccountInfo
-//			accountinfo.ProjectSourse = "biobank"
-//			accountinfo.ProjectAccount = user.AccCode
-//			accountinfo.ProjectAccountName = user.Realname
-//			accountinfo.SurplusCount = 50
-//			accountinfo.ActionType = "sms"
-//			u, p := this.GetuAndp()
-//			strUrl := utils.Cfg.MustValue("server", "apiurl") + "/accountinfos/?u=" + u + "&p=" + p
-//			Apipost(strUrl, "POST", accountinfo)
-
-//			//添加一条组织根节点
-//			var entityorg organize.Base_Organize
-//			// 编辑后添加一条数据
-//			entityorg.Fullname = model.Companyname
-//			entityorg.Parentid = 0
-//			entityorg.Createuserid = user.Id
-//			entityorg.Createby = user.Realname
-//			entityorg.AccCode = user.AccCode
-//			svcuser.InsertEntity(&entityorg)
-
-//			//修改用户的组织id
-//			user.Departmentid = utils.ToStr(entityorg.Id)
-//			user.Departmentname = entityorg.Fullname
-//			var usercols []string = []string{"Departmentid", "Departmentname"}
-//			svcuser.UpdateEntityByIdCols(user.Id, &user, usercols)
-
-//			errinfo.Message = "注册用户成功!"
-//			errinfo.Code = 0
-//			this.Data["json"] = &errinfo
-//			this.ServeJSON()
-//		} else {
-//			errinfo.Message = "注册失败!" + utils.AlertProcess(err.Error())
-//			errinfo.Code = -2
-//			this.Data["json"] = &errinfo
-//			this.ServeJSON()
-//			return
-//		}
-//	} else {
-//		errinfo.Message = "注册失败!" + utils.AlertProcess(err.Error())
-//		errinfo.Code = -3
-//		this.Data["json"] = &errinfo
-//		this.ServeJSON()
-//		return
-//	}
-
-//}
-
-// @Title 获取用户菜单权限
-// @Description 获取用户菜单权限
-// @Success	200	{object} controllers.Request
-// @router /getusermodule [get]
-func (this *UserController) GetUserModule() {
-	//svc := permission.GetPermissionService(utils.DBE)
-	//var model UserModuleModel
-	//model.A1list = svc.GetModuleAllNamesByCode(this.User.Id, "A1")
-	//model.A2list = svc.GetModuleAllNamesByCode(this.User.Id, "A2")
-	//this.Data["json"] = model
-	//this.ServeJSON()
-}
-
-// @Title 获取用户菜单权限
-// @Description 获取用户菜单权限
-// @Success	200	{object} controllers.Request
-// @router /getusermoduletree [get]
-func (this *UserController) GetUserModuleTree() {
-	svc := permission.GetPermissionService(utils.DBE)
-	list := svc.GetModuleAll(this.User.Id, "30000000")
-	this.Data["json"] = list
-	this.ServeJSON()
-}
-
-// @Title CheckToken
-// @Description create token
-// @Param	body		body 	models.User4CreateToken		true		"The user info for create token"
-// @Success 200 {object} models.UserToken
-// @Failure 403 body is empty
-// @router /checkUserPwd [post]
-func (this *UserController) CheckUserPwd() {
-	var errinfo ErrorInfo
-	realName := this.GetString("RealName")
-	if len(realName) == 0 {
-		errinfo.Message = "参数错误"
-		errinfo.Code = -1
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}
-
-	svc := auth.GetAuthServic(utils.DBE)
-	var user4CreateToken models.User4CreateToken
-	json.Unmarshal(this.Ctx.Input.RequestBody, &user4CreateToken)
-	svc2 := userRole.GetUserService(utils.DBE)
-	usermodel := svc2.GetUserInfoByRealName(realName)
-	var user userRole.Base_User
-	if svc.VerifyUser3DES(usermodel.Username, user4CreateToken.Password, &user) {
-		if user.Realname != realName {
-			errinfo.Message = "账号不匹配,无权进行此操作!"
-			errinfo.Code = -1
-			this.Data["json"] = &errinfo
-			this.ServeJSON()
-			return
-		}
-		errinfo.Message = "登录成功"
-		errinfo.Code = 0
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	} else {
-		errinfo.Message = "密码错误,无权进行此操作!"
-		errinfo.Code = -1
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-	}
-}

+ 11 - 26
src/dashoo.cn/backend/api/routers/router.go

@@ -43,11 +43,6 @@ func init() {
 				&controllers.TokenController{},
 			),
 		),
-		beego.NSNamespace("/users",
-			beego.NSInclude(
-				&controllers.UserController{},
-			),
-		),
 		beego.NSNamespace("/casbin/users",
 			beego.NSInclude(
 				&casbin.UserController{},
@@ -58,6 +53,17 @@ func init() {
 				&casbin.RoleController{},
 			),
 		),
+		beego.NSNamespace("/casbin/permission",
+			beego.NSInclude(
+				&casbin.PermissionController{},
+			),
+		),
+		beego.NSNamespace("/casbin/organizes",
+			beego.NSInclude(
+				&casbin.OrganizesController{},
+			),
+		),
+
 		//授权码管理
 		beego.NSNamespace("/channels",
 			beego.NSInclude(
@@ -222,28 +228,7 @@ func init() {
 			),
 		),
 
-		beego.NSNamespace("/permission",
-			beego.NSInclude(
-				&controllers.PermissionController{},
-			),
-		),
-		beego.NSNamespace("/organizes",
-			beego.NSInclude(
-				&controllers.OrganizesController{},
-			),
-		),
-		//角色管理
-		beego.NSNamespace("/role",
-			beego.NSInclude(
-				&controllers.RoleController{},
-			),
-		),
 
-		beego.NSNamespace("/permissions",
-			beego.NSInclude(
-				&controllers.PermissionsController{},
-			),
-		),
 	)
 	beego.AddNamespace(ns)
 }

+ 1 - 1
src/dashoo.cn/backend/api/swagger/swagger.json

@@ -7139,7 +7139,7 @@
                 }
             }
         },
-        "/users/me": {
+        "/casbin/users/me": {
             "get": {
                 "tags": [
                     "users"

+ 1 - 1
src/dashoo.cn/backend/api/swagger/swagger.yml

@@ -4531,7 +4531,7 @@ paths:
         "200":
           schema:
             $ref: '#/definitions/models.User'
-  /users/me:
+  /casbin/users/me:
     get:
       tags:
       - users

+ 2 - 2
src/dashoo.cn/frontend_web/nuxt.config.ignore.js

@@ -106,7 +106,7 @@ module.exports = {
   ],
   auth: {
     user: {
-     endpoint: 'users/me',
+     endpoint: 'casbin/users/me',
      propertyName: '',
      resetOnFail: true
    },
@@ -146,7 +146,7 @@ module.exports = {
   ** 客户端使用:process.env.appclient 服务端使用:context.appclient
   */
   env: {
-    appclient: 'biobank', //因顿LIMS:lims,样本库:biobank,细胞制备:cellbank,样本搜索判断,登录跳转判断
+    appclient: 'lims', //因顿LIMS:lims,样本库:biobank,细胞制备:cellbank,样本搜索判断,登录跳转判断
     imgserverhost: 'http://47.92.212.59:10091', // 本地测试服务地址,图片上传文件
     // imgserverhost: 'http://52.80.133.197:10091', // 服务地址,图片上传文件
     // imgserverhost: 'http://52.80.133.197:9081', // BioBank服务地址,图片上传文件

+ 1 - 1
src/dashoo.cn/frontend_web/nuxt.config.js

@@ -133,7 +133,7 @@ module.exports = {
   ],
   auth: {
     user: {
-      endpoint: 'users/me',
+      endpoint: 'casbin/users/me',
       propertyName: '',
       resetOnFail: true
     },

+ 1 - 1
src/dashoo.cn/frontend_web/src/components/sidebar.vue

@@ -157,7 +157,7 @@ export default class Sidebar extends Vue {
 
   async beforeMount () {
     // 暂时从本地取菜单
-    let {data: menus1} = await this.$axios.get('users/getusermoduletree')
+    let {data: menus1} = await this.$axios.get('casbin/users/getusermoduletree')
     let menus = this.toolfun_gettreejson(menus1, 'id', 'pId', 'id,name,url,icon')
     if (menus[0].id == '30000000') {
       menus = menus[0].children

+ 1 - 1
src/dashoo.cn/frontend_web/src/components/sidebar1.vue

@@ -89,7 +89,7 @@ export default class Sidebar extends Vue {
 
   async beforeMount () {
     // 暂时从本地取菜单
-    let {data: menus1} = await this.$axios.get('users/getusermoduletree')
+    let {data: menus1} = await this.$axios.get('casbin/users/getusermoduletree')
     let menus = this.toolfun_gettreejson(menus1, 'id', 'pId', 'id,name,url,icon')
     if (menus[0].id == '30000000') {
       menus = menus[0].children

+ 7 - 7
src/dashoo.cn/frontend_web/src/pages/system/organize.vue

@@ -187,7 +187,7 @@
           IsInnerOrganize: this.organizeform.IsInnerOrganize
         }
         // request
-        this.$axios.get('/organizes/listbandparentname', {
+        this.$axios.get('casbin/organizes/listbandparentname', {
             params
           })
           .then(res => {
@@ -215,7 +215,7 @@
         let params = {
           IsInnerOrganize: this.organizeform.IsInnerOrganize
         }
-        _this.$axios.get('/organizes/list', {
+        _this.$axios.get('casbin/organizes/list', {
             params
           })
           .then(res => {
@@ -296,7 +296,7 @@
         let _this = this
         if (item === 1) {
           if (this.parentid !== '') {
-            this.$axios.get('/organizes/parentlist/' + this.parentid, {})
+            this.$axios.get('casbin/organizes/parentlist/' + this.parentid, {})
               .then(res => {
                 if (res.data.code === 0) {
                   _this.dialogtitle = `新增组织`
@@ -322,7 +322,7 @@
               })
           }
         } else if (item === 2) {
-          this.$axios.get('/organizes/parentlist/' + v.Parentid, {})
+          this.$axios.get('casbin/organizes/parentlist/' + v.Parentid, {})
             .then(res => {
               if (res.data.code === 0) {
                 _this.dialogtitle = `编辑组织信息(${v.Fullname})`
@@ -373,7 +373,7 @@
             }
             if (_this.operatingitem === 1) {
               _this.organizeform.IsInnerOrganize = 1
-              _this.$axios.post('organizes/', _this.organizeform)
+              _this.$axios.post('casbin/organizes/', _this.organizeform)
                 .then(res => {
                   // response
                   if (res.data.code === 0) {
@@ -398,7 +398,7 @@
                 })
             } else if (_this.operatingitem === 2) {
               _this.organizeform.IsInnerOrganize = 1
-              _this.$axios.put('organizes/' + _this.organizeform.id, _this.organizeform)
+              _this.$axios.put('casbin/organizes/' + _this.organizeform.id, _this.organizeform)
                 .then(res => {
                   // response
                   if (res.data.code === 0) {
@@ -432,7 +432,7 @@
           cancelButtonText: '取消',
           type: 'warning'
         }).then(() => {
-          _this.$axios.delete('organizes/' + val.Id, null)
+          _this.$axios.delete('casbin/organizes/' + val.Id, null)
             .then(res => {
               // response
               if (res.data.code === 0) {