<%_ if (position === 'import') { _%>
  <%_ if (clientTheme === 'vben' && clientFramework === 'vue') { _%>
import { AnnoCategory } from '@/models/enumerations/anno-category.model';
  <%_ } _%>
  <%_ if (clientTheme === 'antd' && clientFramework === 'react') { _%>
import { AnnoCategory } from '@/models/enumerations/anno-category.model';
  <%_ } _%>
  <%_ if (clientFramework === 'angular' && clientTheme === 'alain') { _%>
import { AnnoCategory } from '@/models/enumerations/anno-category.model';
  <%_ } _%>
<%_ } _%>
<%_ if (position === 'method') { _%>
  <%_ if (clientTheme === 'vben' && clientFramework === 'vue') { _%>
  retrieveUnread(category: AnnoCategory, params: object): Promise<PageRecord<IAnnouncement>> {
    const paginationQuery = {
      page: 0,
      size: 5,
      ...params,
    };
    const options = buildPaginationQueryOpts(paginationQuery);
    return defHttp.get({ url: apiUrl + '/current-user/unread/' + category + `?${qs.stringify(options, { arrayFormat: 'repeat' })}` });
  },
  release(id: number): Promise<IAnnouncement> {
    return defHttp.put({ url: `${apiUrl}/${id}/release` });
  },
  read(id: number):  Promise<any> {
    return defHttp.put({ url: `${apiUrl}/${id}/read` });
  },
  <%_ } _%>
  <%_ if (clientFramework === 'antd' && clientFramework === 'react') { _%>

export async function retrieveUnread(category: AnnoCategory): Promise<any> {
  const paginationQuery = {
    page: 0,
    size: 5
  };
  return request<any>(`${apiUrl}/current-user/unread/${category}`, {method: 'GET', params: paginationQuery});
}

export async function release(id: number): Promise<IAnnouncement> {
  return request<IAnnouncement>(`${apiUrl}/${id}/release`, {method: 'PUT'});
}

export async function read(id: number):  Promise<any> {
  return request<any>(`${apiUrl}/${id}/read`, {method: 'PUT'});
}
  <%_ } _%>
  <%_ if (clientFramework === 'angular' && clientTheme === 'alain') { _%>
  retrieveUnread(category: AnnoCategory): Observable<PageData<IAnnouncement>> {
    const paginationQuery = {
      page: 0,
      size: 5
    };
    return this.http.get<IAnnouncement[]>(`${this.resourceUrl}/current-user/unread/${category}`, paginationQuery, { observe: 'response'}).pipe(
      map((res: HttpResponse<IAnnouncement[]>) => this.convertDateArrayFromServer(res)),
      map(res => {
        return {
          total: Number(res.headers.get('X-Total-Count') || '0'),
          items: res.body,
        } as PageData<IAnnouncement>;
      }),
    );
  }

  release(id: number): Observable<IAnnouncement> {
    return this.http.put<IAnnouncement>(`${this.resourceUrl}/${id}/release`);
  }

  read(id: number):  Observable<any> {
    return this.http.put<any>(`${this.resourceUrl}/${id}/read`);
  }
  <%_ } _%>
<%_ } _%>
