package com.sunxung.factoring.web.customerinformation;


import com.sunxung.factoring.component.annotation.OperationLog;
import com.sunxung.factoring.component.enums.OperationTypeEnum;
import com.sunxung.factoring.entity.GridPage;
import com.sunxung.factoring.entity.ResponseJson;
import com.sunxung.factoring.entity.customerinformation.ElectronicSignaturePersonal;
import com.sunxung.factoring.service.customerinformation.IElectronicSignaturePersonalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 * --电子签个人信息表 前端控制器
 * </p>
 *
 * @author liutao
 * @since 2023-05-13
 */
@Controller
@RequestMapping("/electronic/signature/personal")
public class ElectronicSignaturePersonalController {

    @Autowired
    private IElectronicSignaturePersonalService electronicSignaturePersonalService;

    /**
     * 列表接口
     * @param name
     * @return
     */
    @ResponseBody
    @RequestMapping("findByName")
    public GridPage findByName(String name,Integer status,Integer page,Integer rows){
        GridPage list = electronicSignaturePersonalService.findByName(name,status,page,rows);
        return list;
    }

    /**
     * 企业列表接口
     * @param name
     * @return
     */
    @ResponseBody
    @RequestMapping("findByComName")
    public GridPage findByComName(String name,Integer status,Integer page,Integer rows){
        GridPage list = electronicSignaturePersonalService.findByComName(name,status,page,rows);
        return list;
    }


    /**
     * 列表接口
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("findByIdForC")
    public ResponseJson findByIdForC(@RequestParam Long id){
        List<ElectronicSignaturePersonal> list = electronicSignaturePersonalService.findByIdForC(id);
        return new ResponseJson(list);
    }


    /**
     * 查询详细信息
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("get")
    public ResponseJson get(Long id){
        ElectronicSignaturePersonal electronicSignaturePersonal = electronicSignaturePersonalService.getDetail(id);
        return new ResponseJson(electronicSignaturePersonal);
    }

    /**
     * 修改信息
     * @param electronicSignaturePersonal
     * @return
     */
    @ResponseBody
    @RequestMapping("update")
    @OperationLog(operationModule = "电子签个人信息",operationType = OperationTypeEnum.UPDATE,description = "修改信息")
    public ResponseJson update(ElectronicSignaturePersonal electronicSignaturePersonal){
        electronicSignaturePersonalService.updateInfo(electronicSignaturePersonal);
        return new ResponseJson("修改成功！");
    }

    /**
     * 重新生成认证链接
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("flushUrl")
    @OperationLog(operationModule = "电子签个人信息",operationType = OperationTypeEnum.OTHER,description = "重新生成认证链接")
    public ResponseJson flushUrl(Long id){
        electronicSignaturePersonalService.flushUrl(id);
        return new ResponseJson("刷新成功！");
    }

    /**
     * 删除数据
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("delete")
    @OperationLog(operationModule = "电子签个人信息",operationType = OperationTypeEnum.DELETE,description = "删除数据")
    public ResponseJson delete(Long id){
        electronicSignaturePersonalService.delete(id);
        return new ResponseJson("删除成功！");
    }



    /**
     * 刷新认证状态
     * @return
     */
    @RequestMapping("flush")
    @ResponseBody
    @OperationLog(operationModule = "电子签个人",operationType = OperationTypeEnum.UPDATE,description = "刷新认证")
    public ResponseJson flush(Long id) {
        electronicSignaturePersonalService.flush(id);
        return new ResponseJson("刷新成功");
    }

}
