package com.crm.manager.controller;

import com.crm.manager.service.ib.MamSettingFeignService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
import com.crm.rely.backend.core.dto.mam.MamLeverageApplyDto;
import com.crm.rely.backend.core.dto.mam.MamPwdResetDto;
import com.crm.rely.backend.core.dto.mam.MamRepwdDto;
import com.crm.rely.backend.core.entity.custom.info.InfoEntity;
import com.crm.rely.backend.core.entity.mam.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * Created by max on 2020/8/24.
 */
@RestController
@RequestMapping("/mam")
public class MamSettingController {

    @Autowired
    private MamSettingFeignService mamSettingFeignService;


    @PostMapping("/repwd/list")
    public BaseResultWithPagerDto<List<MamRepwdDto>> mamRepwdList(@RequestBody MamRepwdListEntity entity, InfoEntity infoEntity) throws Exception{
        return mamSettingFeignService.mamRepwdList(entity);
    }
    @PostMapping("/repwd/approve")
    public BaseResultDto<Object> mamRepwdApprove(@RequestBody MamRepwdApproveEntity entity, InfoEntity infoEntity) throws Exception{
        return BaseResultDto.success();
    }


    @PostMapping("/pwd/reset/list")
    public BaseResultWithPagerDto<List<MamPwdResetDto>> mamPwdResetList(@RequestBody MamPwdResetListEntity entity, InfoEntity infoEntity) throws Exception{
        return mamSettingFeignService.mamPwdResetList(entity);
    }

    @PostMapping("/pwd/reset/approve")
    public BaseResultDto<Object> mamPwdResetApprove(@RequestBody MamPwdResetApproveEntity entity, InfoEntity infoEntity) throws Exception{
        entity.setApproveTime(new Date());
        entity.setApproveUser(infoEntity.getIbInfo().getId());
        return mamSettingFeignService.mamPwdResetApprove(entity);
    }

    @PostMapping("/leverage/apply/list")
    public BaseResultWithPagerDto<List<MamLeverageApplyDto>> mamLeverageApplyList(@RequestBody MamLeverageApplyListEntity entity, InfoEntity infoEntity) throws Exception{
        return mamSettingFeignService.mamLeverageApplyList(entity);
    }

    @PostMapping("/leverage/apply/approve")
    public BaseResultDto<Object> mamLeverageApplyApprove(@RequestBody MamLeverageApplyApproveEntity entity, InfoEntity infoEntity) throws Exception{
        entity.setApproveTime(new Date());
        entity.setApproveUser(infoEntity.getIbInfo().getId());
        return mamSettingFeignService.mamLeverageApplyApprove(entity);
    }


}
