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


import cn.wisenergy.common.utils.*;
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;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@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="/upload/1a65a6a40-f158-4b03-929a-454c88935a8b.jpg,/upload/1c9dfb994-9f5b-471a-ac7d-93a323089dd2.jpg,/upload/10c03f8cf-d210-486e-bbd4-813a271be298.jpeg,/upload/15e340d63-157c-4374-bf98-ffd1528f0aae.jpeg,";

        List list =new ArrayList();
           // String str = "打印机*钟表//自行车**雨伞%%收音机??电脑";
            String temp[] = str.split(",");
            for(String word : temp)
            {

                boolean arrayList=Collections.addAll(list,word);

            }
        System.out.println(list.get(1));



        //        String[] split= StringUtils.split(",");
//        List list = new ArrayList();
//        list.add(split);
//        System.out.println(list);

//        String[] dbcodeArray = techCatalog.getDbcodeArray();
//        List<String> dbCode=null;
//        if(dbcodeArray!=null){
//            dbCode = Arrays.asList(dbcodeArray);
//        }

//        /**
//         * 隐藏中间四位的方法
//         */
//        String phone = "18501234234";
//
//        String hidenPhone = phone.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2");


//        /**
//         * 生成当前时间戳
//         */
//        BigInteger zxDate= BigInteger.valueOf(System.currentTimeMillis());

//        /**
//         * 去，的写法
//         */
//        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);


    }

    @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();
    }
}
