package com.younike.member;

import com.younike.common.core.controller.BaseController;
import com.younike.common.core.domain.AjaxResult;
import com.younike.framework.config.MemberAccess;
import com.younike.system.domain.SysConfig;
import com.younike.system.service.ISysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 配置Controller
 *
 * @author zulu.chen
 * @date 2022-01-04
 */
@Api("member配置接口")
@RestController
@RequestMapping("/member/config")
public class MemberConfigController extends BaseController{

    @Autowired
    private ISysConfigService sysConfigService;



    /**
     * 查询会员订单追踪信息
     */
    @ApiOperation("获取商家入驻链接")
    @GetMapping("/enter")
    @MemberAccess
    public AjaxResult getServerTimeSections() {

        SysConfig polite = sysConfigService.polite("merchant.register.link");
        if(ObjectUtils.isEmpty(polite)){
            return AjaxResult.error("商家入驻链接不存在");
        }
        return AjaxResult.success("成功",polite.getConfigValue());
    }



    @ApiOperation("商家是否可使用优金豆")
    @MemberAccess
    @GetMapping
    public AjaxResult polite() {

        SysConfig config = sysConfigService.polite("home.pay.user-ujd");
        if (ObjectUtils.isEmpty(config)) {
            return AjaxResult.error("查无数据");
        }

        return AjaxResult.success(new Boolean(config.getConfigValue()));
    }


}
