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-user, *, *
p, *, *, GET, /api/get-organizations, *, *
p, *, *, GET, /api/get-default-application, *, *
p, *, *, GET, /api/get-user-application, *, *
p, *, *, GET, /api/get-default-providers, *, *
p, *, *, POST, /api/upload-avatar, *, *
p, *, *, POST, /api/unlink, *, *

View File

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

View File

@ -73,7 +73,7 @@ func initAPI() {
beego.Router("/api/get-applications", &controllers.ApiController{}, "GET:GetApplications")
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/add-application", &controllers.ApiController{}, "POST:AddApplication")
beego.Router("/api/delete-application", &controllers.ApiController{}, "POST:DeleteApplication")

View File

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

View File

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