parent
b01ec72aa6
commit
814d6fa0ab
@ -0,0 +1,23 @@ |
||||
export const USER_UNKNOWN = 0 |
||||
|
||||
// export const USER_RELATION_TYPE_UNKNOWN = 1;
|
||||
|
||||
// export const USER_RELATION_TYPE_PARENT = 2;
|
||||
|
||||
export const USER_RELATION_TYPE_FRIEND = 3 |
||||
|
||||
export const USER_RELATION_TYPE_GOODFRIEND = 4 |
||||
|
||||
// should be deprecated is useless
|
||||
|
||||
// export const USER_RELATION_TYPE_ENEMY = 5; // should be deprecated is useless
|
||||
|
||||
export const USER_RELATION_TYPE_DELETED = 6 |
||||
|
||||
export const USER_RELATION_TYPE_RRHH = 7 |
||||
|
||||
export const USER_RELATION_TYPE_BOSS = 8 |
||||
|
||||
export const USER_RELATION_TYPE_HRM_REQUEST = 9 |
||||
|
||||
export const USER_RELATION_TYPE_FRIEND_REQUEST = 10 |
@ -1,15 +1,62 @@ |
||||
import api from "../config/api" |
||||
|
||||
export default { |
||||
/** |
||||
* @param {string} iri |
||||
* @returns {Promise<axios.AxiosResponse<any>>} |
||||
* @param {Object} [params] |
||||
* @returns {Promise<Object>} |
||||
*/ |
||||
async function find(iri) { |
||||
return await api.get(iri) |
||||
} |
||||
async get(iri, params = {}) { |
||||
const { data } = await api.get(iri, { |
||||
params, |
||||
}) |
||||
|
||||
return data |
||||
}, |
||||
|
||||
/** |
||||
* @param {string} endpoint |
||||
* @param {Object} searchParams |
||||
* @returns {Promise<{totalItems, items}>} |
||||
*/ |
||||
async getCollection(endpoint, searchParams = {}) { |
||||
const { data } = await api.get(endpoint, { |
||||
params: searchParams, |
||||
}) |
||||
|
||||
async function post(params) { |
||||
return await api.post("/api/resource_links", params) |
||||
return { |
||||
totalItems: data.totalItems, |
||||
items: data["hydra:member"], |
||||
} |
||||
}, |
||||
|
||||
/** |
||||
* @param {string} endpoint |
||||
* @param {Object} [params] |
||||
* @returns {Promise<Object>} |
||||
*/ |
||||
async post(endpoint, params) { |
||||
const { data } = await api.post(endpoint, params) |
||||
|
||||
return data |
||||
}, |
||||
|
||||
export { find, post } |
||||
/** |
||||
* @param {string} endpoint |
||||
* @param {Object} params |
||||
* @returns {Promise<Object>} |
||||
*/ |
||||
async postForm(endpoint, params) { |
||||
const { data } = await api.postForm(endpoint, params) |
||||
|
||||
return data |
||||
}, |
||||
|
||||
/** |
||||
* @param {string} iri |
||||
* @returns {Promise<void>} |
||||
*/ |
||||
async delete(iri) { |
||||
await api.delete(iri) |
||||
}, |
||||
} |
||||
|
@ -0,0 +1,33 @@ |
||||
import baseService from "./baseService" |
||||
|
||||
/** |
||||
* @param {number} cId |
||||
* @param {Object} params |
||||
* @returns {Promise<Object>} |
||||
*/ |
||||
async function findCourseHomeInro(cId, params) { |
||||
return await baseService.get(`/course/${cId}/getToolIntro`, params) |
||||
} |
||||
|
||||
/** |
||||
* @param {number} cId |
||||
* @param {Object} params |
||||
* @returns {Promise<Object>} |
||||
*/ |
||||
async function addToolIntro(cId, params) { |
||||
return baseService.post(`/course/${cId}/addToolIntro`, params) |
||||
} |
||||
|
||||
/** |
||||
* @param {number} toolIntroId |
||||
* @returns {Promise<Object>} |
||||
*/ |
||||
async function findById(toolIntroId) { |
||||
return await baseService.get(`/api/c_tool_intros/${toolIntroId}`) |
||||
} |
||||
|
||||
export default { |
||||
findCourseHomeInro, |
||||
addToolIntro, |
||||
findById, |
||||
} |
@ -0,0 +1,13 @@ |
||||
import baseService from "./baseService" |
||||
|
||||
/** |
||||
* @param {Object} searchParams |
||||
* @returns {Promise<{totalItems, items}>} |
||||
*/ |
||||
async function findAll(searchParams) { |
||||
return await baseService.getCollection("/api/course_rel_users", searchParams) |
||||
} |
||||
|
||||
export default { |
||||
findAll, |
||||
} |
@ -0,0 +1,26 @@ |
||||
import baseService from "./baseService" |
||||
|
||||
/** |
||||
* @param {Object} params |
||||
* @returns {Promise<{totalItems, items}>} |
||||
*/ |
||||
async function findAll(params) { |
||||
return await baseService.getCollection("/api/message_tags", params) |
||||
} |
||||
|
||||
/** |
||||
* @param {string} userIri |
||||
* @param {string} searchTerm |
||||
* @returns {Promise<{totalItems, items}>} |
||||
*/ |
||||
async function searchUserTags(userIri, searchTerm) { |
||||
return await findAll({ |
||||
user: userIri, |
||||
tag: searchTerm, |
||||
}) |
||||
} |
||||
|
||||
export default { |
||||
findAll, |
||||
searchUserTags, |
||||
} |
@ -0,0 +1,11 @@ |
||||
import api from "../config/api" |
||||
|
||||
async function toogleStudentView() { |
||||
const { data } = await api.get("/toggle_student_view") |
||||
|
||||
return data |
||||
} |
||||
|
||||
export default { |
||||
toogleStudentView, |
||||
} |
@ -1,5 +1,9 @@ |
||||
import { post } from "./baseService" |
||||
import api from "../config/api" |
||||
|
||||
export default { |
||||
post, |
||||
async create(params) { |
||||
const { data } = await api.post("/api/resource_links", params) |
||||
|
||||
return data |
||||
}, |
||||
} |
||||
|
@ -0,0 +1,13 @@ |
||||
import baseService from "./baseService" |
||||
|
||||
/** |
||||
* @param {Object} searchParams |
||||
* @returns {Promise<{totalItems, items}>} |
||||
*/ |
||||
async function findAll(searchParams) { |
||||
return await baseService.getCollection("/api/session_rel_course_rel_users", searchParams) |
||||
} |
||||
|
||||
export default { |
||||
findAll, |
||||
} |
@ -1,8 +1,9 @@ |
||||
import { ENTRYPOINT } from "../config/entrypoint" |
||||
import axios from "axios" |
||||
import baseService from "./baseService" |
||||
|
||||
const sessionRelUserService = { |
||||
findAll: (params) => axios.get(ENTRYPOINT + "session_rel_users", { params }).then((response) => response.data), |
||||
async function findAll(params) { |
||||
return await baseService.getCollection("/api/session_rel_users", params) |
||||
} |
||||
|
||||
export default sessionRelUserService |
||||
export default { |
||||
findAll, |
||||
} |
||||
|
@ -1,5 +1,13 @@ |
||||
import { find } from "./baseService" |
||||
import api from "../config/api" |
||||
|
||||
export default { |
||||
find |
||||
/** |
||||
* @param {string} iri |
||||
* @returns {Promise<Object>} |
||||
*/ |
||||
async find(iri) { |
||||
const { data } = await api.get(iri) |
||||
|
||||
return data |
||||
}, |
||||
} |
||||
|
@ -0,0 +1,50 @@ |
||||
import baseService from "./baseService" |
||||
import { USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_FRIEND_REQUEST } from "../constants/entity/userreluser" |
||||
|
||||
/** |
||||
* @param {Object} searchParams |
||||
* @returns {Promise<{totalItems, items}>} |
||||
*/ |
||||
async function findAll(searchParams = {}) { |
||||
return await baseService.getCollection("/api/user_rel_users", searchParams) |
||||
} |
||||
|
||||
/** |
||||
* @param {string} userIri |
||||
* @returns {Promise<Array<Object>>} |
||||
*/ |
||||
async function getFriendList(userIri) { |
||||
const { items } = await findAll({ |
||||
user: userIri, |
||||
relationType: [USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_FRIEND_REQUEST], |
||||
}) |
||||
|
||||
return items |
||||
} |
||||
|
||||
async function sendFriendRequest(userIri, friendIri) { |
||||
return await baseService.post("/api/user_rel_users", { |
||||
user: userIri, |
||||
friend: friendIri, |
||||
relationType: USER_RELATION_TYPE_FRIEND_REQUEST, |
||||
}) |
||||
} |
||||
|
||||
/** |
||||
* @param {string} userIri |
||||
* @param {string} searchTerm |
||||
* @returns {Promise<{totalItems, items}>} |
||||
*/ |
||||
async function searchRelationshipByUsername(userIri, searchTerm) { |
||||
return await findAll({ |
||||
user: userIri, |
||||
"friend.username": searchTerm, |
||||
}) |
||||
} |
||||
|
||||
export default { |
||||
findAll, |
||||
getFriendList, |
||||
sendFriendRequest, |
||||
searchRelationshipByUsername, |
||||
} |
@ -0,0 +1,31 @@ |
||||
import baseService from "./baseService" |
||||
|
||||
/** |
||||
* @param {string} userIri |
||||
* @returns {Promise<Object>} |
||||
*/ |
||||
async function find(userIri) { |
||||
return await baseService.get(userIri) |
||||
} |
||||
|
||||
/** |
||||
* @param {Object} searchParams |
||||
* @returns {Promise<{totalItems, items}>} |
||||
*/ |
||||
async function findAll(searchParams) { |
||||
return await baseService.getCollection("/api/users", searchParams) |
||||
} |
||||
|
||||
/** |
||||
* @param {string} username |
||||
* @returns {Promise<{totalItems, items}>} |
||||
*/ |
||||
async function findByUsername(username) { |
||||
return await baseService.getCollection("/api/users", { username }) |
||||
} |
||||
|
||||
export default { |
||||
find, |
||||
findAll, |
||||
findByUsername, |
||||
} |
@ -1,25 +1,57 @@ |
||||
import axios from "axios" |
||||
import baseService from "./baseService" |
||||
|
||||
export default { |
||||
/** |
||||
* @param {string} searchTerm |
||||
* @returns {Promise<Object>} { totalItems, items } |
||||
* @returns {Promise<{totalItems, items}>} |
||||
*/ |
||||
search: async (searchTerm) => { |
||||
const response = {} |
||||
|
||||
try { |
||||
const { data } = await axios.get("/api/usergroups/search", { |
||||
params: { search: searchTerm }, |
||||
return await baseService.getCollection("/api/usergroups/search", { |
||||
search: searchTerm, |
||||
}) |
||||
}, |
||||
|
||||
response.totalItems = data["hydra:totalItems"] |
||||
response.items = data["hydra:member"] |
||||
} catch { |
||||
response.totalItems = 0 |
||||
response.items = [] |
||||
} |
||||
/** |
||||
* @param {Object} params |
||||
* @returns {Promise<Object>} |
||||
*/ |
||||
async createGroup(params) { |
||||
return await baseService.post("/api/usergroups", params) |
||||
}, |
||||
|
||||
/** |
||||
* @param {number} groupId |
||||
* @param {Object} params |
||||
* @returns {Promise<Object>} |
||||
*/ |
||||
async uploadPicture(groupId, params) { |
||||
return await baseService.postForm(`/social-network/upload-group-picture/${groupId}`, params) |
||||
}, |
||||
|
||||
/** |
||||
* @returns {Promise<Array>} |
||||
*/ |
||||
async listNewest() { |
||||
const { items } = await baseService.getCollection("/api/usergroup/list/newest") |
||||
|
||||
return items |
||||
}, |
||||
|
||||
/** |
||||
* @returns {Promise<Array>} |
||||
*/ |
||||
async listPopular() { |
||||
const { items } = await baseService.getCollection("/api/usergroup/list/popular") |
||||
|
||||
return items |
||||
}, |
||||
|
||||
/** |
||||
* @returns {Promise<Array>} |
||||
*/ |
||||
async listMine() { |
||||
const { items } = await baseService.getCollection("/api/usergroup/list/my") |
||||
|
||||
return response |
||||
return items |
||||
}, |
||||
} |
||||
|
Loading…
Reference in new issue