package com.bonus.core.customer.controller;

import cn.hutool.core.text.CharSequenceUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.core.common.base.BaseController;
import com.bonus.core.common.utils.AesEncryptUtil;
import com.bonus.core.common.utils.HeaderFetchUtil;
import com.bonus.core.customer.dto.CustInfoModel;
import com.bonus.core.customer.service.CustCasualRelationService;
import com.bonus.core.customer.service.CustInfoBusiness;
import com.bonus.encrypt.RequiresGuest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.lang.invoke.SerializedLambda;
import java.util.List;
import java.util.Map;
import java.util.Objects;

@RestController
@RequestMapping({"/custCasual"})
@Api(tags = {"customer-临时人员控制器"})
public class CustCasualController extends BaseController {


   @Resource
   private CustInfoBusiness custInfoBusiness;
   @Resource
   private AesEncryptUtil aesEncryptUtil;

   @ApiOperation("临时人员,修改详细人员资料")
   @PostMapping({"/updateDetailInfoCasualForApp"})
   @RequiresGuest
   public AjaxResult updateDetailInfoCasualForApp(@RequestHeader Map<String, String> headers, @RequestBody CustInfoModel infoModel) {
      infoModel.setOpenid(this.getOpenidByHeaders(headers));
     // infoModel.setCustId(HeaderFetchUtil.getCustId(headers));
     // infoModel.setSourceType(this.getSourceTypeByHeaders(headers));
//      infoModel.setMobile(this.aesEncryptUtil.aesEncrypt(infoModel.getMobile()));
//      infoModel.setIdCard(this.aesEncryptUtil.aesEncrypt(infoModel.getIdCard()));
      infoModel.setPwd(this.aesEncryptUtil.aesDecode(infoModel.getPwd()));

      this.custInfoBusiness.updateDetailInfoCasual(infoModel);
      return AjaxResult.success();
   }



}
