package com.gear.admin.controller.swx;; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.gear.common.builder.WhereBuilder; import com.gear.common.vo.Result; import com.gear.common.constant.SwxConstons; import com.gear.swx.biz.MarketBiz; import com.gear.swx.domain.SwxMarket; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.gear.common.annotation.Log; import com.gear.common.core.controller.BaseController; import com.gear.common.enums.BusinessType; import com.gear.swx.domain.SwxMarketAll; import com.gear.swx.service.ISwxMarketAllService; import com.gear.common.utils.poi.ExcelUtil; /** * 添加产品Controller * * @author czx * @date 2023-11-20 */ @RestController @RequestMapping("/swx/marketAll") public class SwxMarketAllController extends BaseController { @Autowired private ISwxMarketAllService swxMarketAllService; @Autowired private MarketBiz marketBiz; /** * 查询添加产品列表 */ @PreAuthorize("@ss.hasPermi('swx:marketAll:list')") @GetMapping("/list") public Result> listAll(SwxMarketAll swxMarketAll, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ QueryWrapper queryWrapper = WhereBuilder.build(swxMarketAll); queryWrapper.lambda().eq(SwxMarketAll::getStatus, SwxConstons.NOMARL_STATUS_NO); Page page = new Page(pageNo, pageSize); IPage pageList = swxMarketAllService.page(page, queryWrapper); return Result.OK(pageList); } /** * 导出添加产品列表 */ @PreAuthorize("@ss.hasPermi('swx:marketAll:export')") @Log(title = "添加产品", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, SwxMarketAll swxMarketAll){ QueryWrapper queryWrapper = WhereBuilder.build(swxMarketAll); List list = swxMarketAllService.list(queryWrapper); ExcelUtil util = new ExcelUtil(SwxMarketAll.class); util.exportExcel(response, list, "添加产品数据"); } /** * 获取添加产品详细信息 */ @PreAuthorize("@ss.hasPermi('swx:marketAll:query')") @GetMapping(value = "/{id}") public Result getInfo(@PathVariable("id") String id){ SwxMarketAll swxMarketAll = swxMarketAllService.getById(id); if(swxMarketAll==null) { return Result.error("未找到对应数据"); } return Result.OK(swxMarketAll); } /** * 新增添加产品 */ @PreAuthorize("@ss.hasPermi('swx:marketAll:add')") @Log(title = "添加产品", businessType = BusinessType.INSERT) @PostMapping public Result add(@RequestBody SwxMarketAll swxMarketAll){ swxMarketAllService.save(swxMarketAll); return Result.ok("添加成功!"); } /** * 修改添加产品 */ @PreAuthorize("@ss.hasPermi('swx:marketAll:edit')") @Log(title = "添加产品", businessType = BusinessType.UPDATE) @PutMapping public Result edit(@RequestBody SwxMarketAll swxMarketAll){ swxMarketAllService.updateById(swxMarketAll); return Result.ok("编辑成功!"); } /** * 删除添加产品 */ @PreAuthorize("@ss.hasPermi('swx:marketAll:remove')") @Log(title = "添加产品", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public Result remove(@PathVariable List ids){ swxMarketAllService.removeBatchByIds(ids); return Result.ok("删除成功!"); } }