package cn.wisenergy.web.admin.controller.app;


import cn.wisenergy.common.utils.Result;
import cn.wisenergy.common.utils.ResultUtils;
import cn.wisenergy.common.utils.ShareCodeUtil;
import cn.wisenergy.common.utils.SmsUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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;

@Api(tags = "短信服务测试，邀请码测试")
@RestController
@RequestMapping("/ZX")
@Slf4j
public class TestController {

//    @Autowired
//    private BrandService brandService;

    @Autowired
    private SmsUtils smsUtils;
//
//    @Autowired
//    private UserConfig useronfig;

    @ApiOperation(value = "测试Hello Wolrd", notes = "测试", httpMethod = "POST", produces = "application/json; charset=UTF-8")
    @RequestMapping("/index")
    @ResponseBody
    public String index() {
        return "Hello Wolrd";
    }

//    @RequestMapping("/query")
//    @ResponseBody
//    public List<Brand> queryBrandList(){
//        Map<String,Object> param=new HashMap<String, Object>();
//        return brandService.getBrandListByMap(param);
//    }

//    @RequestMapping("/testResult")
//    @ResponseBody
//    public Result testResult(){
//        Map<String,Object> map= StringUtil.createSimpleMap("name","zzshang");
//        Result result1= ResultUtils.returnSuccess("成功",map);
//        Result result2=ResultUtils.returnFail(ResultEnum.FAIL_HAVE_DELETED.getCode(),ResultEnum.FAIL_HAVE_DELETED.getMsg());
//        return result2;
//    }

    public static void main(String [] args){

        String str = "1,2,3,4,5,6,7,8,9";
        String repStr = str.replaceAll(",","");

        String b = ShareCodeUtil.idToCode(1);
       String a= ShareCodeUtil.idToCode(1,0+1);

        System.out.println(repStr);
    }

    @ApiOperation(value = "测试短信服务，发送手机号", notes = "测试短信服务，发送手机号", httpMethod = "POST", produces = "application/json; charset=UTF-8")
    @RequestMapping("/testSms")
    @ResponseBody
    public Result testException()throws Exception{
//       System.out.println(useronfig.getUserName()+"---"+useronfig.getSex());
       return smsUtils.sendMessage("19919990669","SMS_212170059","2111")? ResultUtils.returnSuccess():ResultUtils.returnFail();
    }
}
