示例#1
0
//通过res_name查询资源记录
func (resource *Resource) QueryResByResName(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	queryUrl := common.GetUrlParam(r)
	res := GetResByResName(queryUrl["res_name"][0])
	ret := make(map[string]interface{})
	ret["resource"] = res
	common.Write(w, ret)
}
示例#2
0
//通过openId获取用户资源权限列表
func (oauth *OAuth) QueryPersonResList(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	queryUrl := common.GetUrlParam(r)
	openId := queryUrl["open_id"][0]
	personRes := GetPersonResList(openId)
	ret := make(map[string]interface{})
	ret["personRes"] = personRes
	common.Write(w, ret)
}
示例#3
0
//修改资源状态
func (resource *Resource) ModifyResourceStatus(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	queryUrl := common.GetUrlParam(r)
	status, err := strconv.Atoi(queryUrl["status"][0])
	if err != nil {
		fmt.Println("status convert int failure")
	}
	resId, err2 := strconv.Atoi(queryUrl["res_id"][0])
	if err2 != nil {
		fmt.Println("res_id convert int failure")
	}
	result := UpdateResStatus(status, resId)
	ret := make(map[string]interface{})
	ret["result"] = result
	common.Write(w, ret)
}
示例#4
0
//增加资源记录
func (resource *Resource) AddResource(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	queryUrl := common.GetUrlParam(r)
	var res Resource
	res.App_id = queryUrl["app_id"][0]
	res.Res_name = queryUrl["res_name"][0]
	res.Res_cname = queryUrl["res_cname"][0]
	resType, err := strconv.Atoi(queryUrl["res_type"][0])
	if err != nil {
		fmt.Println("resType convert int failure")
	}
	res.Res_type = resType
	res.Res_target = queryUrl["res_target"][0]
	res.Res_desc = queryUrl["res_desc"][0]
	status, err := strconv.Atoi(queryUrl["status"][0])
	if err != nil {
		fmt.Println("status convert int failure")
	}
	res.Status = status
	result := InsertResource(res)
	ret := make(map[string]interface{})
	ret["result"] = result
	common.Write(w, ret)
}