package com.zzsmart.qomo.kn.cost.manage.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zzsmart.qomo.kn.cost.manage.entity.C7525cost;
import com.zzsmart.qomo.kn.cost.manage.service.IC7525costService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;

import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;

 /**
 * @Description: c7525cost
 * @Author: jeecg-boot
 * @Date:   2024-06-06
 * @Version: V1.0
 */
@Api(tags="7525单价")
@RestController
@RequestMapping("//c7525cost")
@Slf4j
public class C7525costController extends JeecgController<C7525cost, IC7525costService> {
	@Autowired
	private IC7525costService c7525costService;
	
	/**
	 * 分页列表查询
	 *
	 * @param c7525cost
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "c7525cost-分页列表查询")
	@ApiOperation(value="c7525cost-分页列表查询", notes="c7525cost-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<C7525cost>> queryPageList(C7525cost c7525cost,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<C7525cost> queryWrapper = QueryGenerator.initQueryWrapper(c7525cost, req.getParameterMap());
		Page<C7525cost> page = new Page<C7525cost>(pageNo, pageSize);
		IPage<C7525cost> pageList = c7525costService.page(page, queryWrapper);
		return Result.OK(pageList);
	}
	
	/**
	 *   添加
	 *
	 * @param c7525cost
	 * @return
	 */
	@AutoLog(value = "c7525cost-添加")
	@ApiOperation(value="c7525cost-添加", notes="c7525cost-添加")
//	@RequiresPermissions(":c7525cost:add")
	@PostMapping(value = "/add")
	public Result<String> add(@RequestBody C7525cost c7525cost) {
		c7525costService.save(c7525cost);
		return Result.OK("添加成功！");
	}
	
	/**
	 *  编辑
	 *
	 * @param c7525cost
	 * @return
	 */
	@AutoLog(value = "c7525cost-编辑")
	@ApiOperation(value="c7525cost-编辑", notes="c7525cost-编辑")
//	@RequiresPermissions(":c7525cost:edit")
	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> edit(@RequestBody C7525cost c7525cost) {
		c7525costService.updateById(c7525cost);
		return Result.OK("编辑成功!");
	}
	
	/**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "c7525cost-通过id删除")
	@ApiOperation(value="c7525cost-通过id删除", notes="c7525cost-通过id删除")
//	@RequiresPermissions(":c7525cost:delete")
	@DeleteMapping(value = "/delete")
	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
		c7525costService.removeById(id);
		return Result.OK("删除成功!");
	}
	
	/**
	 *  批量删除
	 *
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "c7525cost-批量删除")
	@ApiOperation(value="c7525cost-批量删除", notes="c7525cost-批量删除")
//	@RequiresPermissions(":c7525cost:deleteBatch")
	@DeleteMapping(value = "/deleteBatch")
	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		this.c7525costService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}
	
	/**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 */
	//@AutoLog(value = "c7525cost-通过id查询")
	@ApiOperation(value="c7525cost-通过id查询", notes="c7525cost-通过id查询")
	@GetMapping(value = "/queryById")
	public Result<C7525cost> queryById(@RequestParam(name="id",required=true) String id) {
		C7525cost c7525cost = c7525costService.getById(id);
		if(c7525cost==null) {
			return Result.error("未找到对应数据");
		}
		return Result.OK(c7525cost);
	}

    /**
    * 导出excel
    *
    * @param request
    * @param c7525cost
    */
//    @RequiresPermissions(":c7525cost:exportXls")
	@ApiOperation(value="c7525cost-导出excel", notes="c7525cost-导出excel")
    @RequestMapping(value = "/exportXls", method = RequestMethod.GET)
    public ModelAndView exportXls(HttpServletRequest request, C7525cost c7525cost) {
        return super.exportXls(request, c7525cost, C7525cost.class, "c7525cost");
    }

    /**
      * 通过excel导入数据
    *
    * @param request
    * @param response
    * @return
    */
//    @RequiresPermissions(":c7525cost:importExcel")
	@ApiOperation(value="c7525cost-通过excel导入数据", notes="c7525cost-通过excel导入数据")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, C7525cost.class);
    }

}
