package com.huimv.management.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.huimv.management.entity.SensitiveWordEntity;
import com.huimv.management.service.SensitiveWordService;
import com.huimv.common.utils.PageUtils;
import com.huimv.common.utils.R;


/**
 * @author yinhao
 * @email yinhao@163.com
 * @date 2021-06-01 13:46:33
 */
@RestController
@RequestMapping("management/sensitive")
public class SensitiveWordController {

    @Autowired
    private SensitiveWordService sensitiveWordService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = sensitiveWordService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id) {
        SensitiveWordEntity sensitiveWord = sensitiveWordService.getById(id);
        return R.ok().put("sensitiveWord", sensitiveWord);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody SensitiveWordEntity sensitiveWord) {
        sensitiveWordService.save(sensitiveWord);
        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody SensitiveWordEntity sensitiveWord) {
        sensitiveWordService.updateById(sensitiveWord);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody Integer[] ids) {
        sensitiveWordService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

//    @GetMapping("/check")
//    public R check(@RequestParam("word") String word) {
//        sensitiveWordService.check(word);
//        return null;
//    }

}
