示例#1
0
文件: personal.go 项目: oldtree/One
func HandlePersonProjectGet(c *gin.Context) {
	var result = make(map[string]interface{}, 16)
	var userid string
	var cookieid string

	userid = c.Request.Header.Get("userid")

	if userid == "" {
		cookie, err := c.Request.Cookie("one")
		if err != nil {
			tools.Info(err.Error())
		}

		if cookie != nil {
			cookieid = cookie.Value
			tools.Info(cookieid)
		}

	}

	ser := new(Service.PersonalService)
	ser.Userid = tools.ToInt64(userid)
	ser.ActionType = 1
	ok, _ := ser.ProcessService()
	result["code"] = ok
	result["result"] = ser.Container
	if ok == false {
		tools.Info(result)
	}
	c.Redirect(301, "/people/"+userid)
}
示例#2
0
func (ps *PersonalService) PostPersonActive() (bool, string) {
	tools.Info("post personal Active")
	actmodel := Person.NewPersonAct()
	actmodel.Personid = ps.Userid

	actmodel.Createtime = time.Now().Unix()
	actmodel.TargetGroupid = ps.Userid
	actmodel.TargetGroupName = "one"
	actmodel.TargetOrganizationId = ps.Userid
	actmodel.TargetOrganizationName = "one"
	actmodel.TargetPersonName = "one"
	actmodel.TargetProjectId = ps.Userid
	actmodel.TargetProjectName = "one"
	actmodel.ActionTargetType = Person.PERSONAL_ACTIVE_TARGET_SELF
	actmodel.ActionType = Person.PERSONAL_EMAOTION_ACTIVE
	actmodel.TopicContent = "coldplay"
	ok := actmodel.Insert()

	if ok == false {
		tools.Info("post personal Active failed")
		return false, "post active error"
	}
	ps.Container["active"] = new(Common.ModelContainerSlice)
	ps.Container["active"].(*Common.ModelContainerSlice).ContainerSlice = append(ps.Container["active"].(*Common.ModelContainerSlice).ContainerSlice, actmodel)
	return true, "post active ok"
}
示例#3
0
文件: personal.go 项目: oldtree/One
func HandlePersonFollowingGet(c *gin.Context) {
	var result = make(map[string]interface{}, 16)
	var userid string
	var cookieid string

	userid = c.Request.Header.Get("userid")
	if userid == "" {
		cookie, err := c.Request.Cookie("one")
		if err != nil {
			tools.Info(err.Error())
		}

		if cookie != nil {
			cookieid = cookie.Value
			tools.Info(cookieid)
		}

	}

	ser := new(Service.PersonalService)
	ser.ServerType = Service.PERSONAAL_FOLLOWING_SERVICE_TYPE
	ser.Userid = tools.ToInt64(userid)
	ser.ActionType = 1
	ser.Params = make(map[string]interface{}, 16)
	ok, _ := ser.ProcessService()

	result["code"] = ok
	result["result"] = ser.Container

	if ok == false {
		tools.Info(result)
	}
	c.JSON(200, result)

}
示例#4
0
func (p *ProjectAct) Insert() bool {
	p.Createtime = time.Now().Unix()
	err := ProjectCon.Insert(p)
	if err != nil {
		tools.Info("insert info error")
		tools.Info(p)
		return false
	}

	tools.Info("insert info success")
	tools.Info(p)
	return true
}
示例#5
0
文件: project.go 项目: oldtree/One
func HandleProjectAllGet(c *gin.Context) {
	var result = make(map[string]interface{}, 16)
	var userid string
	//var cookieid string
	var projectid string
	userid = c.Params.ByName("personid")

	if userid == "" {
		result["code"] = 400
		result["descrip"] = "userid is empty"
		result["data"] = nil
		c.JSON(200, result)
		return
	}

	ser := new(Service.ProjectService)
	ser.Userid = tools.ToInt64(userid)
	ser.Projectid = tools.ToInt64(projectid)

	ser.ActionType = Service.PROJECT_GET_ACTION
	ser.ServerType = Service.PROJECT_ALL_SERVICE_TYPE
	ok, _ := ser.ProcessService()
	result["code"] = 0
	result["descrip"] = "ok"
	result["data"] = ser.Container
	if ok == false {
		tools.Info(result)
		c.JSON(200, result)
		return
	}
	c.JSON(200, result)
	return

}
示例#6
0
func (p *Project) Get() (bool, int) {
	log.Println("get Project")
	object := orm.NewOrm()
	log.Println(*p)
	err := object.Read(p)
	if err != nil {
		if err == orm.ErrNoRows {
			tools.Info(err)
			return false, 0
		} else {
			tools.Info(err)
			return false, -1
		}
	}
	return true, 1
}
示例#7
0
func (ps *ProjectService) CreateProjectInfo() (bool, string) {
	tools.Info("create new project")
	project := Project.NewProject()
	project.Projectid = ps.Projectid
	project.Projectname = ps.Params["projectname"].(string)
	project.Star = 0
	project.Creator = ps.Params["creator"].(string)
	project.Watching = 1
	ok, _ := project.Get()

	if ok {
		return false, "Process error : this project has been created"
	}

	ok, result := project.Insert()
	if ok == false {
		if result == 0 {
			tools.Error("create project failed")
			return false, "create project failed"
		} else {
			return false, "create project failed ,please try again later"
		}
	}
	return true, "ok"
}
示例#8
0
func (ps *ProjectService) UpdataProjectInfo() (bool, string) {
	tools.Info("updata project")
	project := Project.NewProject()

	project.Projectid = ps.Projectid

	ok, result := project.Get()
	if ok == false {
		if result == 0 {
			tools.Error("this project have not exist")
			return false, "this project have not exist"
		} else {
			return false, "get project failed ,please try again later"
		}
	}
	project.Projectname = ps.Params["projectname"].(string)
	project.Star = 0
	project.Creator = ps.Params["creator"].(string)
	project.Watching = 1
	ok, result = project.Update()
	if ok == false {
		if result == 0 {
			tools.Error("this project have not exist")
			return false, "update project have not exist"
		} else {
			return false, "update project failed ,please try again later"
		}
	}
	return true, "ok"
}
示例#9
0
func init() {
	tools.Info("mongo db is start up........")
	Session, err := mgo.Dial("127.0.0.1:27017")

	if err != nil {
		tools.Error(err)
	}

	Session.SetMode(mgo.Monotonic, true)

	Person.InitDBConnection(Session)
	Project.InitDBConnection(Session)

	tools.Info("db has been start up")

}
示例#10
0
func (p *ProjectAct) GetBatch(pb *[]*ProjectAct) bool {
	err := ProjectCon.Find(bson.M{"personid": p.ProjectId}).Batch(5)
	err.All(pb)
	tools.Info("get personact betch")

	return true

}
示例#11
0
func (p *Project) Delete() (bool, int) {
	log.Println("Delete Project")
	object := orm.NewOrm()
	p.Mtime = time.Now().Unix()
	p.Updated = time.Now().String()
	length, err := object.Delete(p)
	if err != nil {
		if err == orm.ErrNoRows {
			tools.Info(length, err)
			return false, 0
		} else {
			tools.Info(err)
			return false, -1
		}
	}
	return true, 1
}
示例#12
0
文件: login.go 项目: oldtree/One
func HandleLoginGet(c *gin.Context) {
	var result = make(map[string]interface{}, 16)
	var cookieid string
	var cookie = new(http.Cookie)

	cookie, err := c.Request.Cookie("one")
	if err != nil {
		tools.Info(err.Error())
	}

	if cookie != nil {
		cookieid = cookie.Value
		tools.Info(cookieid)
	}

	result["error"] = "login"
	c.JSON(200, result)

}
示例#13
0
func (ps *ProjectService) DeleteProjectActive() (bool, string) {
	tools.Info("delete project")
	projectact := Project.ProjectAct{}
	projectact.ProjectId = ps.Projectid
	ok := projectact.Delete()
	if !ok {
		return false, "Process error"
	}
	return true, "ok"
}
示例#14
0
文件: personal.go 项目: oldtree/One
func HandlePersonalMain(c *gin.Context) {
	var main = "personmain.html"

	var result = make(map[string]interface{}, 16)
	var userid string
	var cookieid string

	if c.Request.Method == "GET" || c.Request.Method == "get" {
		userid = c.Params.ByName("personid")
		if userid == "" {
			cookie, err := c.Request.Cookie("one")
			if err != nil {
				tools.Info(err.Error())
			}

			if cookie != nil {
				cookieid = cookie.Value
				tools.Info(cookieid)
			}

		}

		ser := new(Service.PersonalService)
		ser.ActionType = 1
		ser.Userid = tools.ToInt64(userid)
		ok, _ := ser.ProcessService()
		ser.ServerType = Service.PERSONAAL_ALL_SERVICE_TYPE
		result["code"] = ok
		result["result"] = ser.Container
		if ok == false {
			tools.Info(result)
		}

	} else {
		HandleAllPost(c)
	}

	if models.UsingJsonReturn {
		c.JSON(200, result)
	} else {
		c.HTML(200, main, nil)
	}
}
示例#15
0
文件: login.go 项目: oldtree/One
func HandleLoginPost(c *gin.Context) {
	var userid string
	var cookieid string
	var cookie = new(http.Cookie)

	userid = c.Request.Header.Get("email")

	password := c.Request.Header.Get("password")
	if userid == "" {
		cookie, err := c.Request.Cookie("one")
		if err != nil {
			tools.Info(err.Error())
		}

		if cookie != nil {
			cookieid = cookie.Value
			tools.Info(cookieid)
		}

	}

	ser := new(Service.PersonalService)
	ser.ServerType = Service.PERSONAAL_LOGINLOGOUT_SERVICE_TYPE
	ser.ActionType = Service.PERSONAL_POST_ACTION
	ser.Params = make(map[string]interface{})
	ser.Params["userid"] = userid
	ser.Params["password"] = password
	ser.ProcessService()

	cookie.Name = "one"
	cookie.Value = userid
	cookie.MaxAge = 3600
	c.Request.AddCookie(cookie)
	if ser.Result["data"] != nil {
		tools.Info("user login success")
		c.Redirect(301, "/people/"+userid)
	} else {
		tools.Info("user login failed")
		c.JSON(200, ser.Result)
	}

}
示例#16
0
文件: UserModels.go 项目: oldtree/One
func (p *Person) Delete() (bool, int) {
	log.Println("Delete person")
	object := orm.NewOrm()
	p.Updated = time.Now().Unix()
	length, err := object.Delete(p)
	if err != nil {
		tools.Info(length, err)
		return false, -1
	}
	return true, 1
}
示例#17
0
func (ps *ProjectService) UpdateProjectForker() (bool, string) {
	tools.Info("get project watcher")
	tools.Info(ps.Userid)
	var tr = new([]*Person.Person)

	ok, result := Person.QueryPersonByProjectIdFork(ps.Projectid, tr)
	if ok == false {
		if result == 0 {
			tools.Error("this project have not exist")
			return false, "uodate project forker not exist"
		} else {
			return false, "update project forker falied ,please try again later"
		}
	}
	ps.Container["watcher"] = new(Common.ModelContainerSlice)
	for _, value := range *tr {
		ps.Container["watcher"].(*Common.ModelContainerSlice).ContainerSlice = append(ps.Container["fork"].(*Common.ModelContainerSlice).ContainerSlice, value)
	}
	return true, "ok"
}
示例#18
0
文件: personal.go 项目: oldtree/One
func HandlePersonProjectPost(c *gin.Context) {
	var result = make(map[string]interface{}, 16)
	var userid string
	var cookieid string

	if c.Request.Method == "GET" || c.Request.Method == "get" {
		userid = c.Request.Header.Get("userid")

		if userid == "" {
			cookie, err := c.Request.Cookie("one")
			if err != nil {
				tools.Info(err.Error())
			}

			if cookie != nil {
				cookieid = cookie.Value
				tools.Info(cookieid)
			}

		}

		ser := new(Service.PersonalService)
		ser.Userid = tools.ToInt64(userid)
		ser.ActionType = 1
		ok, _ := ser.ProcessService()
		result["code"] = ok
		result["result"] = ser.Container
		if ok == false {
			tools.Info(result)
		}
		c.Redirect(301, "/people/"+userid)
		//c.JSON(200, result)
	} else if c.Request.Method == "post" || c.Request.Method == "POST" {
		HandleAllPost(c)
	} else {
		tools.Info("else branch")
		result["error"] = "Bad Request"
		c.Redirect(301, "/login")
		//c.JSON(200, result)
	}
}
示例#19
0
func (ps *PersonalService) GetPersonFollower() (bool, string) {
	tools.Info("get personal Follower")
	tools.Info(ps.Userid)
	var tr = new([]*Person.Person)
	sqlquery := "select * from `test`.`person` where  personid in (select down_personid from `test`.`person` a INNER JOIN `test`.`People_Reletion_Ship` b on a.personid = b.up_personid WHERE personid = '%v');"
	sqlquery = fmt.Sprintf(sqlquery, ps.Userid)
	ok, result := Person.QueryPesonByReletionShipWithPerson(sqlquery, tr)
	if ok == false {
		if result == 0 {
			tools.Error("this user have no Following")
			return false, "update error"
		} else {
			return false, "please try again later"
		}
	}
	ps.Container["follower"] = new(Common.ModelContainerSlice)
	for _, value := range *tr {
		ps.Container["follower"].(*Common.ModelContainerSlice).ContainerSlice = append(ps.Container["follower"].(*Common.ModelContainerSlice).ContainerSlice, value)
	}
	return true, "ok"
}
示例#20
0
文件: personal.go 项目: oldtree/One
func HandlePersonFollowingPost(c *gin.Context) {
	var result = make(map[string]interface{}, 16)
	var userid string
	var cookieid string

	userid = c.Request.Header.Get("userid")

	if userid == "" {
		cookie, err := c.Request.Cookie("one")
		if err != nil {
			tools.Info(err.Error())
		}

		if cookie != nil {
			cookieid = cookie.Value
			tools.Info(cookieid)
		}

	}

	followingid := c.Request.Header.Get("followingid")

	ser := new(Service.PersonalService)
	ser.ServerType = Service.PERSONAAL_FOLLOWING_SERVICE_TYPE
	ser.Userid = tools.ToInt64(userid)
	ser.ActionType = 2
	ser.Params = make(map[string]interface{}, 16)
	ser.Params["up_personid"] = followingid
	ser.Params["down_personid"] = userid
	ok, re := ser.ProcessService()

	result["code"] = ok
	result["result"] = re

	if ok == false {
		tools.Info(result)
	}
	c.Redirect(302, "/people/"+followingid+"/following")
}
示例#21
0
func (p *Project) Update() (bool, int) {
	log.Println("update Project")
	object := orm.NewOrm()
	p.Mtime = time.Now().Unix()
	p.Updated = time.Now().String()

	length, err := object.Update(p)
	if err != nil {
		tools.Info(length, err)
		return false, -1
	}
	return true, 1
}
示例#22
0
func (p *Organization) Insert() (bool, int) {
	log.Println("Insert Organization")
	object := orm.NewOrm()
	p.Mtime = time.Now().Unix()
	p.Ctime = time.Now().Unix()
	p.Updated = time.Now().String()
	p.Created = time.Now().String()
	length, err := object.Insert(p)
	if err != nil {
		tools.Info(length, err)
		return false, -1
	}
	return true, 1
}
示例#23
0
func (ps *PersonalService) GetPersonActive() (bool, string) {
	tools.Info("get personal Active")
	useract := Person.NewPersonAct()
	useract.Personid = ps.Userid
	ok := useract.Get()
	if ok == false {
		tools.Info("get personal Active failed")
		return false, ""
	}
	var pb = new([]*Person.PersonAct)
	useract.GetBatch(pb)
	ps.Container["active"] = new(Common.ModelContainerSlice)
	if pb != nil {
		for _, value := range *pb {
			ps.Container["active"].(*Common.ModelContainerSlice).ContainerSlice = append(ps.Container["active"].(*Common.ModelContainerSlice).ContainerSlice, value)
		}
		return true, "get active ok"
	} else {
		return false, "get active empty"
	}

	return true, "get active ok"
}
示例#24
0
文件: personal.go 项目: oldtree/One
func HandlePersonActiveGet(c *gin.Context) {
	var result = make(map[string]interface{}, 16)
	var userid string
	var cookieid string

	userid = c.Params.ByName("personid")

	if userid == "" {
		cookie, err := c.Request.Cookie("one")
		if err != nil {
			tools.Info(err.Error())
		}

		if cookie != nil {
			cookieid = cookie.Value
			tools.Info(cookieid)
		}

	}

	ser := new(Service.PersonalService)
	ser.ServerType = Service.PERSONAAL_ACTIVE_SERVICE_TYPE
	ser.Userid = tools.ToInt64(userid)
	ser.ActionType = 1
	ser.Params = make(map[string]interface{}, 16)
	ser.Params["personid"] = userid
	ok, _ := ser.ProcessService()

	result["code"] = ok
	result["result"] = ser.Container

	if ok == false {
		c.Redirect(302, "/people/"+userid)
		return
	}
	c.JSON(200, result)
}
示例#25
0
func (ps *PersonalService) PostPersonFollowing() (bool, string) {
	tools.Info("get personal Following")
	sqlquery := "INSERT INTO  `test`.`People_Reletion_Ship` (`up_personid`,`down_personid`,`reletion_type`) VALUES ('%v','%v',%v);"
	sqlquery = fmt.Sprintf(sqlquery, ps.Params["up_personid"], ps.Params["down_personid"], 4)
	ok, result := Person.InsertPersonByReletionShipWithPerson(sqlquery)
	if ok == false {
		if result == 0 {
			tools.Error("this user have no Following")
			return false, "post error"
		} else {
			return false, "please try again later"
		}
	}
	return ps.GetPersonFollowing()
}
示例#26
0
func (ps *ProjectService) GetProjectInfo() (bool, string) {
	tools.Info("get project info")
	project := Project.NewProject()
	project.Projectid = ps.Projectid
	ok, result := project.Get()
	if ok == false {
		if result == 0 {
			tools.Error("this project have not exist")
			return false, "this project have not exist"
		} else {
			return false, "get project failed ,please try again later"
		}
	}
	ps.Container["projectinfo"] = project
	return true, "ok"
}
示例#27
0
func (ps *PersonalService) DeletePersonFollowing() (bool, string) {
	tools.Info("get personal Following")

	sqlquery := "delete * from `test`.`People_Reletion_Ship` where  up_personid = '%v' and  down_personid = '%v';"
	sqlquery = fmt.Sprintf(sqlquery, ps.Params["up_personid"], ps.Params["down_personid"])
	ok, result := Person.QueryPesonByReletionShipWithPerson(sqlquery, nil)
	if ok == false {
		if result == 0 {
			tools.Error("this user have no Following")
			return false, "update error"
		} else {
			return false, "please try again later"
		}
	}
	return ps.GetPersonFollowing()
}
示例#28
0
func (ps *PersonalService) UpdataPersonInfo() (bool, string) {
	tools.Info("updata personal info")
	user := Person.NewPerson()
	user.Personid = ps.Userid
	ok, result := user.Update()
	if ok == false {
		if result == 0 {
			tools.Error("this user is not exist")
			return false, "this user is not exist"
		} else {
			return false, "please try again later"
		}

	}
	ps.Container["personalinfo"] = user
	return true, "ok"
}
示例#29
0
文件: project.go 项目: oldtree/One
func HandleProjectStaticsGet(c *gin.Context) {
	var result = make(map[string]interface{}, 16)
	var userid string
	var projectid string
	//	var cookieid string

	ser := new(Service.ProjectService)
	ser.Userid = tools.ToInt64(userid)
	ser.Projectid = tools.ToInt64(projectid)
	ser.ActionType = Service.PROJECT_GET_ACTION
	ok, _ := ser.ProcessService()
	result["code"] = ok
	result["result"] = ser.Container
	if ok == false {
		tools.Info(result)
	}

}
示例#30
0
func (ps *PersonalService) DeletePersonProject() (bool, string) {
	tools.Info("delete personal Project")
	var tr = new([]*Project.Project)
	ok, result := Project.GetProjectByCreator(ps.Userid, tr)
	if ok == false {
		if result == 0 {
			tools.Error("this user is not exist")
			return false, "this user have no project"
		} else {
			return false, "please try again later"
		}
	}
	ps.Container["project"] = new(Common.ModelContainerSlice)
	for _, value := range *tr {
		ps.Container["project"].(*Common.ModelContainerSlice).ContainerSlice = append(ps.Container["project"].(*Common.ModelContainerSlice).ContainerSlice, value)
	}
	return true, "ok"
}