package com.fs.qw;

import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.domain.R;
import com.fs.common.core.domain.entity.SysDictData;
import com.fs.common.utils.StringUtils;
import com.fs.qw.param.QwConfigSignatureParam;
import com.fs.qw.service.IQwJsApiService;
import com.fs.qwApi.param.QwCustomerDetailParam;
import com.fs.system.service.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
/**
* 侧边栏
*/
@RestController
@RequestMapping("/qw/getJsapiTicket")
public class QwGetJsapiTicketController {


    @Autowired
    IQwJsApiService qwGetJsapiTicketService;

    @Autowired
    private ISysDictTypeService dictTypeService;

    //获取企业签名
    @PostMapping("/getConfigSignature")
    public R getConfigSignature(@RequestBody QwConfigSignatureParam qwConfigSignatureParam) throws Exception {

        return   qwGetJsapiTicketService.getQwJsapiTicket(qwConfigSignatureParam);
    }

    //根据userid和外部联系人id获取到客户详情
    @PostMapping("/getCustomerDetailsH5")
    public R getCustomerDetailsH5(@RequestBody QwCustomerDetailParam param){

        return qwGetJsapiTicketService.getCustomerDetailsH5(param);
    }

    /**
     * 根据字典类型查询字典数据信息
     */
    @GetMapping(value = "/dict/data/type/{dictType}")
    public AjaxResult dictType(@PathVariable String dictType)
    {
        List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
        if (StringUtils.isNull(data))
        {
            data = new ArrayList<SysDictData>();
        }
        return AjaxResult.success(data);
    }


}
