package cn.iocoder.yudao.module.basic.controller.app.businessinfo;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.basic.convert.businessinfo.BusinessInfoConvert;
import cn.iocoder.yudao.module.basic.dal.dataobject.businessinfo.BusinessInfoDO;
import cn.iocoder.yudao.module.basic.service.businessinfo.BusinessInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Api(tags = "APP移动端 - 商户")
@RestController
@RequestMapping("/basic/business-info")
@Validated
public class BusinessInfoAppController {

    @Resource
    private BusinessInfoService businessInfoService;

    @GetMapping("/get")
    @PermitAll // 无需登陆
    @ApiOperation("获得商户")
    @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
    public CommonResult<BusinessInfoDO> getBusinessInfo(@RequestParam("id") Long id) {
        BusinessInfoDO businessInfo = businessInfoService.getBusinessInfo(id);
        return success(BusinessInfoConvert.INSTANCE.convert(businessInfo));
    }

}
