package com.sptg.gateway.controller.permissions;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.security.annotation.Security;
import com.sptg.common.security.enums.DataFormatEnum;
import com.sptg.estate.api.constant.EstateSecurityToken;
import com.sptg.permissions.api.constant.PermissionsSecurityToken;
import com.sptg.permissions.api.entity.SmsRecords;
import com.sptg.permissions.api.feigns.SmsFeign;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * title: SmsController
 * package: com.sptg.gateway.controller.estate
 * description: 短信 网关控制器
 *
 *
 *
 */
@RestController
@RequestMapping("/permissions/sms")
@RequiredArgsConstructor
public class SmsController {

    private final SmsFeign smsFeign;

    /**
     * 功能描述:短信页面初始化
     * @return ModelAndView
     *
     *
     */
    @GetMapping("/index")
    @Security(token = PermissionsSecurityToken.SMS_MANAGE,format = DataFormatEnum.VIEW)
    public ModelAndView index(){
        return new ModelAndView("permissions/sms-manage");
    }

    /**
     * 功能描述:短信列表查询
     * @param smsRecords 短信业务对象（含查询条件）
     * @param page 分页条件
     * @return  ResultBean<Page<SmsService>>
     *
     *
     */
    @GetMapping(value = "/showSmsList")
    @Security(token = EstateSecurityToken.ESTATE_UNIT_MANAGE,format = DataFormatEnum.JSON)
    public ResultBean<Page<SmsRecords>> showSmsList(SmsRecords smsRecords, Page<SmsRecords> page) {
        smsRecords.setPage(page);
        return this.smsFeign.pagingByCondition(smsRecords);
    }
}
