package com.ghy.web.controller.worker;

import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.page.TableDataInfo;
import com.ghy.worker.domain.Worker;
import com.ghy.worker.service.WorkerService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author clunt
 * 师傅端Controller
 */
@Controller
@RequestMapping("/worker")
public class WorkerController extends BaseController {

    private String prefix = "worker";

    @Autowired
    private WorkerService workerService;

    @RequiresPermissions("worker:worker:view")
    @GetMapping()
    public String worker(){
        return prefix + "/worker";
    }

    @RequiresPermissions("worker:worker:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Worker worker)
    {
        startPage();
        List<Worker> list = workerService.getWorkList(worker);
        return getDataTable(list);
    }

}
