package com.gree.mall.miniapp.controller.comlist;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gree.mall.miniapp.bean.es.CommonListES;
import com.gree.mall.miniapp.helper.ResponseHelper;
import com.gree.mall.miniapp.logic.common.WorkerComListLogic;
import com.gree.mall.miniapp.plus.entity.WorkerComList;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;


@Slf4j
@RestController
@Api(value = "师傅-文件下发", tags ={"师傅-文件下发"} )
@RequestMapping(value = "/worker/comlist", produces = "application/json; charset=utf-8")
public class WorkerComListController {

    @Autowired
    WorkerComListLogic workerComListLogic;

    @GetMapping("/list")
    @ApiOperation(value = "万能通用附件列表")
    public ResponseHelper<IPage<WorkerComList>> list(
            @ApiParam(required = false, value = "师傅编号") @RequestParam(required = false) String workerNumber,
            @ApiParam(required = false, value = "标题") @RequestParam(required = false) String title,
            @ApiParam(required = false, value = "备注") @RequestParam(required = false) String remark,
            @ApiParam(required = false, value = "状态 true=显示 false=隐藏") @RequestParam(required = false) Boolean status,
            @ApiParam(required = true, value = "页号") @RequestParam(required = true) Integer pageNum,
            @ApiParam(required = true, value = "页大小") @RequestParam(required = true) Integer pageSize

    ){
        IPage<WorkerComList> list = workerComListLogic.list(workerNumber,title, status, remark, pageNum, pageSize);
        return ResponseHelper.success(list);
    }




    @GetMapping("/record")
    @ApiOperation(value = "通用列表-明细")
    public ResponseHelper<List<CommonListES>> record(
            @ApiParam(required = true, value = "列表id") @RequestParam(required = true) String comListId,
            @ApiParam(required = true, value = "师傅编号") @RequestParam(required = true) String workerNumber
    ) throws Exception {
        List<CommonListES> record = workerComListLogic.record(comListId, workerNumber);
        return ResponseHelper.success(record);
    }



}
