新火炬后端单体项目初始化代码
lixiangyu
6 小时以前 345941d946f5a48d31660a58dfc7911d7639a97d
src/main/java/org/jeecg/modules/cms/controller/CuttingInventoryController.java
@@ -3,15 +3,11 @@
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 org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.cms.entity.CuttingInventory;
import org.jeecg.modules.cms.service.ICuttingInventoryService;
@@ -20,141 +16,133 @@
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;
 /**
/**
 * @Description: 刀具库存
 * @Author: jeecg-boot
 * @Date:   2025-07-28
 * @Date: 2025-07-28
 * @Version: V1.0
 */
@Api(tags="刀具库存")
@Api(tags = "刀具库存")
@RestController
@RequestMapping("/cms/cuttingInventory")
@Slf4j
public class CuttingInventoryController extends JeecgController<CuttingInventory, ICuttingInventoryService> {
   @Autowired
   private ICuttingInventoryService cuttingInventoryService;
   /**
    * 分页列表查询
    *
    * @param cuttingInventory
    * @param pageNo
    * @param pageSize
    * @param req
    * @return
    */
   //@AutoLog(value = "刀具库存-分页列表查询")
   @ApiOperation(value="刀具库存-分页列表查询", notes="刀具库存-分页列表查询")
   @GetMapping(value = "/list")
   public Result<IPage<CuttingInventory>> queryPageList(CuttingInventory cuttingInventory,
                           @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                           @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                           HttpServletRequest req) {
      QueryWrapper<CuttingInventory> queryWrapper = QueryGenerator.initQueryWrapper(cuttingInventory, req.getParameterMap());
      Page<CuttingInventory> page = new Page<CuttingInventory>(pageNo, pageSize);
      IPage<CuttingInventory> pageList = cuttingInventoryService.page(page, queryWrapper);
      return Result.OK(pageList);
   }
   /**
    *   添加
    *
    * @param cuttingInventory
    * @return
    */
   @AutoLog(value = "刀具库存-添加")
   @ApiOperation(value="刀具库存-添加", notes="刀具库存-添加")
   //@RequiresPermissions("org.jeecg.modules:cms_cutting_inventory:add")
   @PostMapping(value = "/add")
   public Result<String> add(@RequestBody CuttingInventory cuttingInventory) {
      cuttingInventoryService.save(cuttingInventory);
      return Result.OK("添加成功!");
   }
   /**
    *  编辑
    *
    * @param cuttingInventory
    * @return
    */
   @AutoLog(value = "刀具库存-编辑")
   @ApiOperation(value="刀具库存-编辑", notes="刀具库存-编辑")
   //@RequiresPermissions("org.jeecg.modules:cms_cutting_inventory:edit")
   @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
   public Result<String> edit(@RequestBody CuttingInventory cuttingInventory) {
      cuttingInventoryService.updateById(cuttingInventory);
      return Result.OK("编辑成功!");
   }
   /**
    *   通过id删除
    *
    * @param id
    * @return
    */
   @AutoLog(value = "刀具库存-通过id删除")
   @ApiOperation(value="刀具库存-通过id删除", notes="刀具库存-通过id删除")
   //@RequiresPermissions("org.jeecg.modules:cms_cutting_inventory:delete")
   @DeleteMapping(value = "/delete")
   public Result<String> delete(@RequestParam(name="id",required=true) String id) {
      cuttingInventoryService.removeById(id);
      return Result.OK("删除成功!");
   }
   /**
    *  批量删除
    *
    * @param ids
    * @return
    */
   @AutoLog(value = "刀具库存-批量删除")
   @ApiOperation(value="刀具库存-批量删除", notes="刀具库存-批量删除")
   //@RequiresPermissions("org.jeecg.modules:cms_cutting_inventory:deleteBatch")
   @DeleteMapping(value = "/deleteBatch")
   public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
      this.cuttingInventoryService.removeByIds(Arrays.asList(ids.split(",")));
      return Result.OK("批量删除成功!");
   }
   /**
    * 通过id查询
    *
    * @param id
    * @return
    */
   //@AutoLog(value = "刀具库存-通过id查询")
   @ApiOperation(value="刀具库存-通过id查询", notes="刀具库存-通过id查询")
   @GetMapping(value = "/queryById")
   public Result<CuttingInventory> queryById(@RequestParam(name="id",required=true) String id) {
      CuttingInventory cuttingInventory = cuttingInventoryService.getById(id);
      if(cuttingInventory==null) {
         return Result.error("未找到对应数据");
      }
      return Result.OK(cuttingInventory);
   }
    @Autowired
    private ICuttingInventoryService cuttingInventoryService;
    /**
    * 导出excel
    *
    * @param request
    * @param cuttingInventory
    */
     * 分页列表查询
     *
     * @param cuttingInventory
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    //@AutoLog(value = "刀具库存-分页列表查询")
    @ApiOperation(value = "刀具库存-分页列表查询", notes = "刀具库存-分页列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<CuttingInventory>> queryPageList(CuttingInventory cuttingInventory,
                                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                         HttpServletRequest req) {
        QueryWrapper<CuttingInventory> queryWrapper = QueryGenerator.initQueryWrapper(cuttingInventory, req.getParameterMap());
        Page<CuttingInventory> page = new Page<CuttingInventory>(pageNo, pageSize);
        IPage<CuttingInventory> pageList = cuttingInventoryService.page(page, queryWrapper);
        return Result.OK(pageList);
    }
    /**
     * 添加
     *
     * @param cuttingInventory
     * @return
     */
    @AutoLog(value = "刀具库存-添加")
    @ApiOperation(value = "刀具库存-添加", notes = "刀具库存-添加")
    //@RequiresPermissions("org.jeecg.modules:cms_cutting_inventory:add")
    @PostMapping(value = "/add")
    public Result<String> add(@RequestBody CuttingInventory cuttingInventory) {
        cuttingInventoryService.save(cuttingInventory);
        return Result.OK("添加成功!");
    }
    /**
     * 编辑
     *
     * @param cuttingInventory
     * @return
     */
    @AutoLog(value = "刀具库存-编辑")
    @ApiOperation(value = "刀具库存-编辑", notes = "刀具库存-编辑")
    //@RequiresPermissions("org.jeecg.modules:cms_cutting_inventory:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
    public Result<String> edit(@RequestBody CuttingInventory cuttingInventory) {
        cuttingInventoryService.updateById(cuttingInventory);
        return Result.OK("编辑成功!");
    }
    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "刀具库存-通过id删除")
    @ApiOperation(value = "刀具库存-通过id删除", notes = "刀具库存-通过id删除")
    //@RequiresPermissions("org.jeecg.modules:cms_cutting_inventory:delete")
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
        cuttingInventoryService.removeById(id);
        return Result.OK("删除成功!");
    }
    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "刀具库存-批量删除")
    @ApiOperation(value = "刀具库存-批量删除", notes = "刀具库存-批量删除")
    //@RequiresPermissions("org.jeecg.modules:cms_cutting_inventory:deleteBatch")
    @DeleteMapping(value = "/deleteBatch")
    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
        this.cuttingInventoryService.removeByIds(Arrays.asList(ids.split(",")));
        return Result.OK("批量删除成功!");
    }
    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    //@AutoLog(value = "刀具库存-通过id查询")
    @ApiOperation(value = "刀具库存-通过id查询", notes = "刀具库存-通过id查询")
    @GetMapping(value = "/queryById")
    public Result<CuttingInventory> queryById(@RequestParam(name = "id", required = true) String id) {
        CuttingInventory cuttingInventory = cuttingInventoryService.getById(id);
        if (cuttingInventory == null) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(cuttingInventory);
    }
    /**
     * 导出excel
     *
     * @param request
     * @param cuttingInventory
     */
    //@RequiresPermissions("org.jeecg.modules:cms_cutting_inventory:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, CuttingInventory cuttingInventory) {
@@ -162,16 +150,30 @@
    }
    /**
      * 通过excel导入数据
    *
    * @param request
    * @param response
    * @return
    */
     * 通过excel导入数据
     *
     * @param request
     * @param response
     * @return
     */
    //@RequiresPermissions("cms_cutting_inventory:importExcel")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, CuttingInventory.class);
    }
    /**
     * 刀具库存统计
     */
    @ApiOperation(value = "刀具库存-统计分页查询", notes = "刀具库存-统计分页查询")
    @GetMapping(value = "/statistics")
    public Result<IPage<Map<String, Object>>> statistics(
            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        Page<Map<String, Object>> page = new Page<>(pageNo, pageSize);
        IPage<Map<String, Object>> pageList = cuttingInventoryService.statisticsByCuttingIdAndStatus(page);
        return Result.OK(pageList);
    }
}