package com.ghy.web.controller.worker;

import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.core.text.Convert;
import com.ghy.worker.domain.WorkerSpecialSkill;
import com.ghy.worker.service.WorkerSpecialSkillService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 师傅的特殊技能
 *
 * @author HH 2022/6/7
 */
@Controller
@RequestMapping("worker/special/skill")
public class WorkerSpecialSkillController {

    @Resource
    private WorkerSpecialSkillService workerSpecialSkillService;

    @PostMapping("{workerId}")
    @ResponseBody
    public AjaxResult getByWorker(@PathVariable Long workerId) {
        return AjaxResult.success(workerSpecialSkillService.getByWorker(workerId));
    }

    @PostMapping("save")
    @ResponseBody
    public AjaxResult insert(@RequestBody WorkerSpecialSkill workerSpecialSkill) {
        workerSpecialSkillService.insert(workerSpecialSkill);
        return AjaxResult.success("保存成功");
    }

    @DeleteMapping
    @ResponseBody
    public AjaxResult delete(String ids) {
        workerSpecialSkillService.delete(Convert.toLongArray(ids));
        return AjaxResult.success("保存成功");
    }

    @DeleteMapping("{workerId}")
    @ResponseBody
    public AjaxResult deleteByWorker(@PathVariable Long workerId) {
        workerSpecialSkillService.deleteByWorker(workerId);
        return AjaxResult.success("保存成功");
    }
}
