package org.jeecg.modules.gongdandetail.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.gongdandetail.dto.ItdmGongdanDetailEditDTO;
import org.jeecg.modules.gongdandetail.service.IItdmGongdanQuerenService;
import org.jeecg.modules.itdmGongdanDetail.entity.ItdmGongdanDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;

/**
 * @Description: 工单detail
 * @Author: jeecg-boot
 * @Date: 2023-05-21
 * @Version: V1.0
 */
@Api(tags = "工单detail")
@RestController
@RequestMapping("/gongdandetail/itdmGongdanDetail")
@Slf4j
public class ItdmGongdanQuerenController extends JeecgController<ItdmGongdanDetail, IItdmGongdanQuerenService> {
    @Autowired
    private IItdmGongdanQuerenService itdmGongdanDetailService;

    /**
     * 分页列表查询
     *
     * @param itdmGongdanDetail
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    //@AutoLog(value = "工单detail-分页列表查询")
    @ApiOperation(value = "工单detail-分页列表查询", notes = "工单detail-分页列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<ItdmGongdanDetail>> queryPageList(ItdmGongdanDetail itdmGongdanDetail,
                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                          HttpServletRequest req) {
        QueryWrapper<ItdmGongdanDetail> queryWrapper = QueryGenerator.initQueryWrapper(itdmGongdanDetail, req.getParameterMap());
        Page<ItdmGongdanDetail> page = new Page<ItdmGongdanDetail>(pageNo, pageSize);
        IPage<ItdmGongdanDetail> pageList = itdmGongdanDetailService.page(page, queryWrapper);
        return Result.OK(pageList);
    }


    /**
     * 编辑
     *
     * @param itdmGongdanDetail
     * @return
     */
    @AutoLog(value = "工单detail-编辑")
    @ApiOperation(value = "工单detail-编辑", notes = "工单detail-编辑")
    //@RequiresPermissions("org.jeecg.modules:itdm_gongdan_detail:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
    public Result<String> edit(@RequestBody ItdmGongdanDetailEditDTO itdmGongdanDetail) throws ParseException {
        itdmGongdanDetailService.queren(itdmGongdanDetail);
        return Result.OK("编辑成功!");
    }


}
