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" }
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" }
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() }
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() }
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" }
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") }
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" }
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" }
func (ps *ProjectService) GetAllProjectInfo() (bool, string) { tools.Info("get project info") var projectlist = new([]*Project.Project) ok, result := Project.GetProjectByCreator(ps.Userid, projectlist) if ok == false { if result == 0 { tools.Error("this project have not exist") return false, "get project not exist" } else { return false, "get project all info falied ,please try again later" } } if len(*projectlist) <= 0 { ps.Container["projectinfo"] = nil } else { ps.Container["projectinfo"] = projectlist } return true, "ok" }
func (ps *PersonalService) UpdataPersonWatchingProject() (bool, string) { tools.Info("updata personal WatchingProject") var tr = new([]*Project.Project) ok, result := Project.GetProjectByCreator(ps.Userid, 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["Watching"].(*Common.ModelContainerSlice).ContainerSlice, value) } body, _ := json.Marshal(tr) return true, string(body) }
func (ps *PersonalService) GetPersonFollowing() (bool, string) { tools.Info("get personal Following") var tr = new([]*Person.Person) sqlquery := "select * from `test`.`person` where personid in (select up_personid from `test`.`person` a INNER JOIN `test`.`People_Reletion_Ship` b on a.personid = b.down_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, "this user have no Following" } else { return false, "please try again later" } } ps.Container["following"] = new(Common.ModelContainerSlice) for _, value := range *tr { ps.Container["following"].(*Common.ModelContainerSlice).ContainerSlice = append(ps.Container["following"].(*Common.ModelContainerSlice).ContainerSlice, value) } return true, "ok" }
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" }