package com.sqx.modules.firstLogin.control;

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

@RestController
@RequestMapping("app/postPreference")
public class PostPreferenceController {
    @Autowired
    private PostPreferenceService postPreferenceServer;
    @Login
    @GetMapping("getPostPreference")
    @ApiOperation("获取岗位偏向")
    public Result getPostPreference(Long ruleClassifyId){
        return Result.success().put("data",postPreferenceServer.getBaseMapper().selectList(new QueryWrapper<PostPreference>().eq("rule_classify_id",ruleClassifyId).eq("is_use",1)));
    }
    @PostMapping("addPostPreference")
    @ApiOperation("增加岗位偏向")
    public Result addPostPreference(@RequestBody PostPreference postPreference){
        postPreference.setIsUse(1);
        postPreferenceServer.saveOrUpdate(postPreference);
        return Result.success("修改完成");
    }
    @PostMapping("deletePostPreference")
    @ApiOperation("增加岗位偏向")
    public Result deletePostPreference(Long postPreferenceId){
        PostPreference postPreference =postPreferenceServer.getById(postPreferenceId);
        postPreference.setIsUse(0);
        postPreferenceServer.updateById(postPreference);
        return Result.success("修改完成");
    }

}
