package com.hzs.member.base.controller.manage;


import com.hzs.common.core.annotation.Log;
import com.hzs.common.core.enums.EOperationMethod;
import com.hzs.common.core.enums.EOperationModule;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.domain.AjaxResult;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.member.base.param.DeleteDeadLockParam;
import com.hzs.member.base.service.DeleteDeadLockService;
import com.hzs.member.base.vo.DeleteDeadLockVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/manager/deleteDeadLock")
@RestController
public class DeleteDeadLockController extends BaseController {

    @Autowired
    private DeleteDeadLockService deleteDeadLockService;

    /**
     * 删除死点列表
     */
    @Log(module = EOperationModule.DELETE_DEAD_LOCK, method = EOperationMethod.SELECT)
    @GetMapping("list")
    public TableDataInfo list(DeleteDeadLockParam deleteDeadLockParam) {
        startPage();
        deleteDeadLockParam.setPkCountry(SecurityUtils.getPkCountry());
        List<DeleteDeadLockVO> DeleteDeadLockList = deleteDeadLockService.queryDeleteDeadLockList(deleteDeadLockParam.getMemberCode());
        return getDataTable(DeleteDeadLockList);
    }

    /**
     * 删除死点
     */
    @Log(module = EOperationModule.DELETE_DEAD_LOCK, method = EOperationMethod.DELETE)
    @PostMapping("delete")
    public AjaxResult delete(@RequestBody DeleteDeadLockParam deleteDeadLockParam) {
        String check = deleteDeadLockService.deleteDeadLockMember(deleteDeadLockParam);
        if (check == null) {
            return AjaxResult.success();
        }
        return AjaxResult.error(check);
    }
}
