package com.sifang.modules.smallprogram.stategrid.controller;


import com.jfinal.plugin.activerecord.Record;
import com.sifang.modules.customer.dao.CustomerEntryDao;
import com.sifang.modules.smallprogram.stategrid.service.StateGridService;
import com.sifang.modules.sunshine.SystemSetting.utils.Result;
import com.sifang.modules.supply.warehouse.service.CrmSupplyBarcodeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 小程序端国网授权
 */
@RestController
@RequestMapping(value = "${adminPath}/main/stategrid")
public class StateGridAuthorizationController {

    Logger logger = LoggerFactory.getLogger(StateGridAuthorizationController.class);

    @Resource
    private StateGridService stateGridService;

    @Resource
    private CustomerEntryDao customerEntryDao;

    /**
     * 添加客户信息到国网
     * @param powerGenerationNo
     * @return
     */

    @ResponseBody
    @RequestMapping("addUserInfo")
    public Result addUserInfoArriveStateGrid(String  powerGenerationNo){
        try {
            return stateGridService.addUserInfoArriveStateGrid(powerGenerationNo,null);
        }catch (Exception e){
            return Result.fail("授权失败:"+e.getMessage());
        }

    }


    /**
     * 判断是否签约
     * @param powerGenerationNo
     * @return
     */
    @ResponseBody
    @RequestMapping("isAgency")
    public boolean isAgency(String  powerGenerationNo){
        return stateGridService.isAgency(powerGenerationNo);
    }


    /**
     * 判断是否签约
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping("getInfo")
    public Object getInfo(String areaCode,String  powerGenerationNo){
        return stateGridService.findUserInfo(areaCode,powerGenerationNo);
    }






}
