diff --git a/nuxt/components/data/Pagenation.vue b/nuxt/components/data/Pagenation.vue index ac467ee..7a5b687 100644 --- a/nuxt/components/data/Pagenation.vue +++ b/nuxt/components/data/Pagenation.vue @@ -1,5 +1,5 @@ + + diff --git a/nuxt/pages/admin/content/list.vue b/nuxt/pages/admin/content/list.vue new file mode 100644 index 0000000..bc2133a --- /dev/null +++ b/nuxt/pages/admin/content/list.vue @@ -0,0 +1,194 @@ + + + diff --git a/nuxt/stores/contents/index.ts b/nuxt/stores/contents/index.ts new file mode 100644 index 0000000..b89036b --- /dev/null +++ b/nuxt/stores/contents/index.ts @@ -0,0 +1,140 @@ +import type { + ContentListQueryType, + ContentListType, + ContentType +} from '~/types/contents'; +import { cloneDeep } from 'lodash-es'; +import type { Page } from '~/types/common'; +import { defineStore } from 'pinia'; +import { ref } from 'vue'; +import { useAxios } from '~/composables/useAxios'; +import { message } from 'ant-design-vue'; + +const DEFAULT_CONTENT_QUERY: ContentListQueryType = { + keyword: '', + orgId: '', + page: 1, + siteId: '', + size: 10, + type: '' +}; + +const DEFAULT_CONTENTS_LIST: Page = { + content: [], + totalElements: 0, + totalPages: 0 +}; + +const DEFAULT_CONTENTS: ContentType = { + contentTitle: '', + contentPlain: '', + contents: '', + frstRegDt: '', + frstRgtrId: '', + lastMdfcnDt: '', + lastMdfrId: '', + orgId: '', + siteId: '', + useYn: true +}; + +export const useContentStore = defineStore('useContentStore', () => { + const contentsQuery = ref( + cloneDeep(DEFAULT_CONTENT_QUERY) + ); + + const contentsList = ref>( + cloneDeep(DEFAULT_CONTENTS_LIST) + ); + + const contents = ref(cloneDeep(DEFAULT_CONTENTS)); + const initialValue = ref(''); + + const resetContentListQuery = () => { + contentsQuery.value = cloneDeep(DEFAULT_CONTENT_QUERY); + }; + + const resetContentList = () => { + contentsList.value = cloneDeep(DEFAULT_CONTENTS_LIST); + }; + + const resetContents = () => { + contents.value = cloneDeep(DEFAULT_CONTENTS); + initialValue.value = ''; + }; + + const initContentsQuery = () => { + contentsQuery.value = cloneDeep(DEFAULT_CONTENT_QUERY); + }; + + const searchContentList = async () => { + try { + const { data } = await useAxios().get( + '/api/admin/contents/contentsList', + { + params: { + ...contentsQuery.value + } + } + ); + + contentsList.value = data; + } catch (e) { + message.error('사이트 리스트를 불러오는데 실패하였습니다.'); + } + }; + + const searchContents = async (contentId: number) => { + try { + const { data } = await useAxios().get('/api/admin/contents/detail', { + params: { + contentId + } + }); + + contents.value = data; + initialValue.value = data.contents; + } catch (e) { + message.error('컨텐츠 정보를 불러오는데 실패하였습니다.'); + } + }; + + const updateContents = () => { + console.log(contents.value); + return useAxios().post( + '/api/admin/contents/updateContents', + contents.value + ); + }; + + const deleteContents = async (data: ContentType[]) => { + try { + const params = new URLSearchParams(); + data.forEach((item) => { + params.append('contentId', String(item.contentId)); + }); + + await useAxios().post('/api/admin/contents/deleteContents', null, { + params + }); + message.success('컨텐츠 정보가 삭제 되었습니다.'); + } catch (e) { + message.error('컨텐츠 정보 삭제에 실패하였습니다.'); + } + }; + + return { + contentsQuery, + contentsList, + contents, + initialValue, + resetContentListQuery, + searchContentList, + searchContents, + resetContentList, + resetContents, + initContentsQuery, + deleteContents, + updateContents + }; +}); diff --git a/nuxt/stores/index.ts b/nuxt/stores/index.ts new file mode 100644 index 0000000..a24eec1 --- /dev/null +++ b/nuxt/stores/index.ts @@ -0,0 +1,99 @@ +import type { SiteType } from '~/types/sys/site'; +import type { GridCodeType } from '~/types'; +import { defineStore } from 'pinia'; +import { computed, ref } from 'vue'; +import { useAxios } from '~/composables/useAxios'; + +export const useLoadingStore = defineStore('useLoadingStore', () => { + const loadCount = ref(0); + + const incrementLoadCount = () => { + loadCount.value++; + }; + + const decrementLoadCount = () => { + loadCount.value--; + }; + + const resetLoadCount = () => { + loadCount.value = 0; + }; + + const isLoading = computed(() => { + return loadCount.value > 0; + }); + + return { + isLoading, + resetLoadCount, + incrementLoadCount, + decrementLoadCount + }; +}); + +export const useDefaultStore = defineStore('useDefaultStore', () => { + const siteInfo = ref({ + siteId: '', + siteName: '', + siteDescription: '', + siteDomain: '', + siteType: '', + sitePrefix: '', + siteLocale: '', + siteLogo: '', + bscUrl: '', + lgnUrl: '', + delYn: false, + useYn: true, + frstRgtrId: '', + frstRegDt: '', + lastMdfrId: '', + lastMdfcnDt: '' + }); + + const fetchSiteInfo = async () => { + const { data } = await useAxios().get('/api/admin/siteInfo'); + siteInfo.value = data; + }; + + return { siteInfo, fetchSiteInfo }; +}); + +export const useCommonCodeStore = defineStore('useCommonCodeStore', () => { + const searchCommonCodeList = async ( + codeGroupId: string + ): Promise => { + const { data } = await useAxios().get('/api/admin/code/codeList', { + params: { + codeGroupId + } + }); + return data; + }; + + const searchSiteCodeList = async (): Promise => { + const { data } = await useAxios().get('/api/admin/code/siteList'); + return data; + }; + + const searchInstCodeList = async (): Promise => { + const { data } = await useAxios().get( + '/api/admin/code/instList' + ); + return data; + }; + + const searchRoleCodeList = async (): Promise => { + const { data } = await useAxios().get( + '/api/admin/code/roleList' + ); + return data; + }; + + return { + searchInstCodeList, + searchSiteCodeList, + searchCommonCodeList, + searchRoleCodeList + }; +}); diff --git a/nuxt/types/common/index.ts b/nuxt/types/common/index.ts new file mode 100644 index 0000000..e7acb8b --- /dev/null +++ b/nuxt/types/common/index.ts @@ -0,0 +1,10 @@ +export type Page = { + content: T[]; + totalElements: number; + totalPages: number; +}; + +export type PagingQuery = { + page: number; + size: number; +}; diff --git a/nuxt/types/contents/index.ts b/nuxt/types/contents/index.ts new file mode 100644 index 0000000..7f9a38b --- /dev/null +++ b/nuxt/types/contents/index.ts @@ -0,0 +1,32 @@ +export type ContentListQueryType = { + page: number; + size: number; + siteId: string; + orgId: string; + keyword: string; + type: '' | 'TITLE' | 'CONTENT'; +}; + +export type ContentListType = { + contentId: number; + contentTitle: string; + useYn: boolean; + frstRgtrId: string; + frstRegDt: string; + lastMdfrId: string; + lastMdfcnDt: string; +}; + +export type ContentType = { + contentId?: number; + siteId: string; + orgId: string; + contentTitle: string; + contents: string; + contentPlain: string; + useYn: boolean; + frstRgtrId: string; + frstRegDt: string; + lastMdfrId: string; + lastMdfcnDt: string; +}; diff --git a/nuxt/types/index.ts b/nuxt/types/index.ts new file mode 100644 index 0000000..6f159bd --- /dev/null +++ b/nuxt/types/index.ts @@ -0,0 +1,20 @@ +export type PagingQueryType = { + page: number; + size: number; +}; + +export type GridCodeType = { + label?: string; + text?: string; + value: string; +}; + +export type FileInfoType = { + fileId: number; + fileOriginalName: string; + filePath: string; + fileMimeType: string; + fileSize: number; + fileAltText: string; + fileDownloadCount: number; +};