package org.springblade.gateway.client_gateway.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.ldt.notice.entity.NoticeManagement;
import org.springblade.ldt.notice.service.INoticeManagementContentService;
import org.springblade.ldt.notice.service.INoticeManagementService;
import org.springblade.ldt.notice.vo.NoticeManagementVO;
import org.springblade.ldt.notice.wrapper.NoticeManagementWrapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: lianghanqiang
 * @description:
 * @since: 8/24/21 -- 3:10 PM
 */
@Api(tags = "商户会员用户模块")
@RestController
@RequestMapping("/client/member")
@AllArgsConstructor
public class ClientMemberController {

	private INoticeManagementService noticeManagementService;
	private INoticeManagementContentService noticeManagementContentService;

	@GetMapping("getNotices")
	@ApiOperation(value = "根据会员用户id获取相关公告通知")
	public R<IPage<NoticeManagementVO>> submitAudit(Long id, Query query) {
		IPage<NoticeManagement> pages = noticeManagementService.page(Condition.getPage(query),
			Wrappers.<NoticeManagement>lambdaQuery().eq(NoticeManagement::getReceiverId, id).orderByAsc(NoticeManagement::getIsRead));
		return R.data(NoticeManagementWrapper.build(noticeManagementContentService).pageVO(pages));
	}

}
