Replace getDefaultApplication() with getUserApplication().

This commit is contained in:
Yang Luo 2021-07-11 23:49:06 +08:00
parent 2be7d28a6c
commit dc0712c8a5
5 changed files with 16 additions and 20 deletions

View File

@ -82,7 +82,7 @@ p, *, *, GET, /api/get-application, *, *
p, *, *, GET, /api/get-users, *, * p, *, *, GET, /api/get-users, *, *
p, *, *, GET, /api/get-user, *, * p, *, *, GET, /api/get-user, *, *
p, *, *, GET, /api/get-organizations, *, * p, *, *, GET, /api/get-organizations, *, *
p, *, *, GET, /api/get-default-application, *, * p, *, *, GET, /api/get-user-application, *, *
p, *, *, GET, /api/get-default-providers, *, * p, *, *, GET, /api/get-default-providers, *, *
p, *, *, POST, /api/upload-avatar, *, * p, *, *, POST, /api/upload-avatar, *, *
p, *, *, POST, /api/unlink, *, * p, *, *, POST, /api/unlink, *, *

View File

@ -44,23 +44,19 @@ func (c *ApiController) GetApplication() {
c.ServeJSON() c.ServeJSON()
} }
// @Title GetDefaultApplication // @Title GetUserApplication
// @Description get the detail of the default application // @Description get the detail of the user's application
// @Param owner query string true "The owner of the application." // @Param id query string true "The id of the user"
// @Success 200 {object} object.Application The Response object // @Success 200 {object} object.Application The Response object
// @router /get-default-application [get] // @router /get-user-application [get]
func (c *ApiController) GetDefaultApplication() { func (c *ApiController) GetUserApplication() {
//owner := c.Input().Get("owner") id := c.Input().Get("id")
user := object.GetUser(id)
if c.GetSessionUser() == "" { if user == nil {
c.Data["json"] = nil c.ResponseError("No such user.")
c.ServeJSON()
return return
} }
username := c.GetSessionUser()
user := object.GetUser(username)
c.Data["json"] = object.GetApplicationByUser(user) c.Data["json"] = object.GetApplicationByUser(user)
c.ServeJSON() c.ServeJSON()
} }

View File

@ -73,7 +73,7 @@ func initAPI() {
beego.Router("/api/get-applications", &controllers.ApiController{}, "GET:GetApplications") beego.Router("/api/get-applications", &controllers.ApiController{}, "GET:GetApplications")
beego.Router("/api/get-application", &controllers.ApiController{}, "GET:GetApplication") beego.Router("/api/get-application", &controllers.ApiController{}, "GET:GetApplication")
beego.Router("/api/get-default-application", &controllers.ApiController{}, "GET:GetDefaultApplication") beego.Router("/api/get-user-application", &controllers.ApiController{}, "GET:GetUserApplication")
beego.Router("/api/update-application", &controllers.ApiController{}, "POST:UpdateApplication") beego.Router("/api/update-application", &controllers.ApiController{}, "POST:UpdateApplication")
beego.Router("/api/add-application", &controllers.ApiController{}, "POST:AddApplication") beego.Router("/api/add-application", &controllers.ApiController{}, "POST:AddApplication")
beego.Router("/api/delete-application", &controllers.ApiController{}, "POST:DeleteApplication") beego.Router("/api/delete-application", &controllers.ApiController{}, "POST:DeleteApplication")

View File

@ -49,7 +49,7 @@ class UserEditPage extends React.Component {
UNSAFE_componentWillMount() { UNSAFE_componentWillMount() {
this.getUser(); this.getUser();
this.getOrganizations(); this.getOrganizations();
this.getDefaultApplication(); this.getUserApplication();
} }
getUser() { getUser() {
@ -70,8 +70,8 @@ class UserEditPage extends React.Component {
}); });
} }
getDefaultApplication() { getUserApplication() {
ApplicationBackend.getDefaultApplication("admin") ApplicationBackend.getUserApplication(this.state.organizationName, this.state.userName)
.then((application) => { .then((application) => {
this.setState({ this.setState({
application: application, application: application,

View File

@ -28,8 +28,8 @@ export function getApplication(owner, name) {
}).then(res => res.json()); }).then(res => res.json());
} }
export function getDefaultApplication(owner) { export function getUserApplication(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-default-application?owner=${owner}`, { return fetch(`${Setting.ServerUrl}/api/get-user-application?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET", method: "GET",
credentials: "include" credentials: "include"
}).then(res => res.json()); }).then(res => res.json());