package com.corewing.app.modules.admin.biz;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.corewing.app.common.Result;
import com.corewing.app.dto.biz.privacyPolicy.PrivacyPolicyBatchDeleteRequest;
import com.corewing.app.entity.PrivacyPolicy;
import com.corewing.app.service.PrivacyPolicyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.env.PropertyResolver;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 隐私政策
 */
@Controller
@RequestMapping("/biz/privacy_policy")
public class BizPrivacyPolicyController {

    @Resource
    private PrivacyPolicyService privacyPolicyService;

    @GetMapping("/index")
    public String index() {
        return "admin/biz/privacyPolicy/index";
    }

    @GetMapping("/page")
    @ResponseBody
    public Result<Page<PrivacyPolicy>> page(PrivacyPolicy privacyPolicy) {
        return Result.success(privacyPolicyService.page(privacyPolicy));
    }

    @PostMapping("/save")
    @ResponseBody
    public Result<String> save(@RequestBody PrivacyPolicy privacyPolicy) {
        return Result.isBool(privacyPolicyService.save(privacyPolicy));
    }

    @PostMapping("/update")
    @ResponseBody
    public Result<String> update(@RequestBody PrivacyPolicy privacyPolicy) {
        return Result.isBool(privacyPolicyService.updateById(privacyPolicy));
    }

    @DeleteMapping("/delete")
    @ResponseBody
    public Result<String> delete(Long id) {
        return Result.isBool(privacyPolicyService.removeById(id));
    }

    @PostMapping("/batchDelete")
    @ResponseBody
    public Result<String> batchDelete(@RequestBody PrivacyPolicyBatchDeleteRequest privacyPolicyBatchDeleteRequest) {
        return Result.isBool(privacyPolicyService.removeBatchByIds(privacyPolicyBatchDeleteRequest.getIds()));
    }




}
