
package com.tmerclub.cloud.biz.controller.platform;

import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.PhoneUtil;
import com.tmerclub.cloud.biz.dto.NotifyLogDTO;
import com.tmerclub.cloud.biz.service.NotifyLogService;
import com.tmerclub.cloud.biz.vo.NotifyLogVO;
import com.tmerclub.cloud.common.database.dto.PageDTO;
import com.tmerclub.cloud.common.database.vo.PageVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @author lhd
 * @date 2021-05-14 09:35:32
 */
@RestController("platformNotifyLogController")
@RequestMapping("/p/notifyLog")
@Tag(name = "消息日志")
public class NotifyLogController {

    @Autowired
    private NotifyLogService notifyLogService;

    @GetMapping("/page")
    @Operation(summary = "获取列表", description = "分页获取列表")
    public ServerResponseEntity<PageVO<NotifyLogVO>> page(@Valid PageDTO pageDTO, NotifyLogDTO notifyLogDTO) {
        PageVO<NotifyLogVO> notifyLogPage = notifyLogService.page(pageDTO, notifyLogDTO);

        for (NotifyLogVO record : notifyLogPage.getList()) {
            if (Objects.nonNull(record.getUserMobile())) {
                record.setUserMobile(PhoneUtil.hideBetween(record.getUserMobile()).toString());
            }
        }
        return ServerResponseEntity.success(notifyLogPage);
    }
}
