package com.sqx.modules.resumes.controller.app;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sqx.common.utils.DateUtils;
import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.resumes.entity.ShieldCompany;
import com.sqx.modules.resumes.service.ShieldCompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@Api(value = "屏蔽公司", tags = {"屏蔽公司"})
@RequestMapping(value = "/app/shieldCompany")
public class AppShieldCompanyController {

    @Autowired
    private ShieldCompanyService shieldCompanyService;

    @PostMapping("/insertShieldCompany")
    @ApiOperation("添加屏蔽")
    public Result insertShieldCompany(@RequestBody ShieldCompany shieldCompany){

       return shieldCompanyService.insertShieldCompany(shieldCompany);
    }

    @Login
    @PostMapping("/deleteShieldCompany")
    @ApiOperation("解除屏蔽")
    public Result deleteShieldCompany(ShieldCompany shieldCompany){
        if(shieldCompany.getShieldCompanyId()!=null){
            shieldCompanyService.removeById(shieldCompany.getShieldCompanyId());
        }else {
            shieldCompanyService.remove(new QueryWrapper<ShieldCompany>().eq("shield_type", shieldCompany.getShieldType()).eq("user_id", shieldCompany.getUserId()).eq("company_id", shieldCompany.getCompanyId()));
        }

        return Result.success();
    }

    @GetMapping("/selectShieldList")
    @ApiOperation("查询屏蔽列表")
    public Result selectShieldList(Integer page,Integer limit, Long userId,Long companyId){
        return shieldCompanyService.selectShieldList(page, limit, userId,companyId);
    }
}
