From 67f329cb14b034d29a720ed98b7cb34cc2343b75 Mon Sep 17 00:00:00 2001 From: Richie <280645618@qq.com> Date: Mon, 21 Apr 2025 09:52:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=9B=B4=E6=96=B0=E6=96=B0?= =?UTF-8?q?=E6=9E=B6=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- microservices/goods-api/pom.xml | 28 ++ .../api/goods/AutoConfiguration.java | 23 ++ .../config/GoodsApiMybatisPlusConfig.java | 19 ++ .../controller/GoodsBrandController.java | 72 +++++ .../controller/GoodsCategoryController.java | 142 ++++++++++ .../api/goods/controller/GoodsController.java | 247 ++++++++++++++++++ .../controller/GoodsInventoryController.java | 47 ++++ .../controller/GoodsSupplierController.java | 67 +++++ .../main/resources/META-INF/spring.factories | 1 + .../src/main/resources/application.yml | 89 +++++++ .../goods-api/src/main/resources/banner.txt | 24 ++ microservices/pom.xml | 30 +++ 12 files changed, 789 insertions(+) create mode 100644 microservices/goods-api/pom.xml create mode 100644 microservices/goods-api/src/main/java/cn/qihangerp/api/goods/AutoConfiguration.java create mode 100644 microservices/goods-api/src/main/java/cn/qihangerp/api/goods/config/GoodsApiMybatisPlusConfig.java create mode 100644 microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsBrandController.java create mode 100644 microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsCategoryController.java create mode 100644 microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsController.java create mode 100644 microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsInventoryController.java create mode 100644 microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsSupplierController.java create mode 100644 microservices/goods-api/src/main/resources/META-INF/spring.factories create mode 100644 microservices/goods-api/src/main/resources/application.yml create mode 100644 microservices/goods-api/src/main/resources/banner.txt create mode 100644 microservices/pom.xml diff --git a/microservices/goods-api/pom.xml b/microservices/goods-api/pom.xml new file mode 100644 index 00000000..fb4b7d04 --- /dev/null +++ b/microservices/goods-api/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + + cn.qihangerp.services + microservices + 1.0.6 + + + goods-api + jar + + goods-api + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/AutoConfiguration.java b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/AutoConfiguration.java new file mode 100644 index 00000000..6d286ad1 --- /dev/null +++ b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/AutoConfiguration.java @@ -0,0 +1,23 @@ +package com.zhijian; + +//import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.context.annotation.FilterType; + + +//@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class ,MybatisAutoConfiguration.class}) +//@ComponentScan +//@Configuration +//@EnableAutoConfiguration +@Configuration +//@EnableAutoConfiguration(exclude = MybatisAutoConfiguration.class) +@ComponentScan(basePackages = "com.zhijian", + excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = FrameworkAutoConfiguration.class)) +public class FrameworkAutoConfiguration { +} diff --git a/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/config/GoodsApiMybatisPlusConfig.java b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/config/GoodsApiMybatisPlusConfig.java new file mode 100644 index 00000000..af6a2d83 --- /dev/null +++ b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/config/GoodsApiMybatisPlusConfig.java @@ -0,0 +1,19 @@ +package cn.qihangerp.api.goods.config; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@MapperScan({"cn.qihangerp.module.*.mapper"}) +public class MybatisPlusConfig { + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); //注意使用哪种数据库 + return interceptor; + } +} diff --git a/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsBrandController.java b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsBrandController.java new file mode 100644 index 00000000..c6ef9e15 --- /dev/null +++ b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsBrandController.java @@ -0,0 +1,72 @@ +package cn.qihangerp.oms.controller; + + + +import cn.qihangerp.common.AjaxResult; +import cn.qihangerp.common.PageQuery; + + +import cn.qihangerp.common.TableDataInfo; +import cn.qihangerp.module.goods.domain.OGoodsBrand; +import cn.qihangerp.module.goods.service.OGoodsBrandService; + +import cn.qihangerp.security.common.BaseController; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.Arrays; +import java.util.Date; + +@AllArgsConstructor +@RestController +@RequestMapping("/goods_brand") +public class GoodsBrandController extends BaseController { + private final OGoodsBrandService brandService; + @GetMapping("/list") + public TableDataInfo skuList(OGoodsBrand bo, PageQuery pageQuery) + { + var pageList = brandService.queryPageList(bo,pageQuery); + return getDataTable(pageList); + } + + /** + * 获取商品品牌详细信息 + */ + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(brandService.getById(id)); + } + + /** + * 新增商品品牌 + */ + @PostMapping + public AjaxResult add(@RequestBody OGoodsBrand erpGoodsBrand) + { + erpGoodsBrand.setStatus(1); + erpGoodsBrand.setCreateBy(getUsername()); + erpGoodsBrand.setCreateTime(new Date()); + return toAjax(brandService.save(erpGoodsBrand)); + } + + /** + * 修改商品品牌 + */ + @PutMapping + public AjaxResult edit(@RequestBody OGoodsBrand erpGoodsBrand) + { + erpGoodsBrand.setUpdateBy(getUsername()); + erpGoodsBrand.setUpdateTime(new Date()); + return toAjax(brandService.updateById(erpGoodsBrand)); + } + + /** + * 删除商品品牌 + */ + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(brandService.removeByIds(Arrays.stream(ids).toList())); + } +} diff --git a/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsCategoryController.java b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsCategoryController.java new file mode 100644 index 00000000..7166a198 --- /dev/null +++ b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsCategoryController.java @@ -0,0 +1,142 @@ +package cn.qihangerp.oms.controller; + + + +import cn.qihangerp.common.AjaxResult; +import cn.qihangerp.common.TableDataInfo; +import cn.qihangerp.module.goods.domain.OGoodsCategory; +import cn.qihangerp.module.goods.domain.OGoodsCategoryAttribute; +import cn.qihangerp.module.goods.domain.OGoodsCategoryAttributeValue; +import cn.qihangerp.module.goods.service.OGoodsCategoryAttributeService; +import cn.qihangerp.module.goods.service.OGoodsCategoryAttributeValueService; +import cn.qihangerp.module.goods.service.OGoodsCategoryService; +import cn.qihangerp.security.common.BaseController; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.Arrays; +import java.util.Date; + +@AllArgsConstructor +@RestController +@RequestMapping("/goods_category") +public class GoodsCategoryController extends BaseController { + private final OGoodsCategoryService categoryService; + private final OGoodsCategoryAttributeService categoryAttributeService; + private final OGoodsCategoryAttributeValueService categoryAttributeValueService; + + @GetMapping("/list") + public TableDataInfo categoryList() + { + var pageList = categoryService.list(); + return getDataTable(pageList); + } + + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(categoryService.getById(id)); + } + + @PostMapping + public AjaxResult add(@RequestBody OGoodsCategory category) + { + category.setCreateBy(getUsername()); + categoryService.addCategory(category); + return toAjax(1); + } + + @PutMapping + public AjaxResult edit(@RequestBody OGoodsCategory category) + { + category.setUpdateBy(getUsername()); + category.setUpdateTime(new Date()); + return toAjax(categoryService.updateById(category)); + } + /** + * 删除分类 + * @param ids + * @return + */ + @DeleteMapping("/del/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(categoryService.removeByIds(Arrays.stream(ids).toList())); + } + + /** + * 分类属性列表 + * @param categoryId + * @return + */ + @GetMapping("/attribute_list") + public TableDataInfo attributeList(Integer categoryId) + { + var pageList = categoryAttributeService.list(new LambdaQueryWrapper().eq(OGoodsCategoryAttribute::getCategoryId,categoryId)); + return getDataTable(pageList); + } + + /** + * 分类属性添加 + * @param attribute + * @return + */ + @PostMapping("/attribute_add") + public AjaxResult attributeAdd(@RequestBody OGoodsCategoryAttribute attribute) + { + return toAjax(categoryAttributeService.save(attribute)); + } + + @GetMapping(value = "/attribute/{id}") + public AjaxResult getAttributeInfo(@PathVariable("id") Long id) + { + return success(categoryAttributeService.getById(id)); + } + + @PutMapping("/attribute") + public AjaxResult attributeEdit(@RequestBody OGoodsCategoryAttribute attribute) + { + return toAjax(categoryAttributeService.updateById(attribute)); + } + @DeleteMapping("/attribute/{ids}") + public AjaxResult attributeRemove(@PathVariable Long[] ids) + { + return toAjax(categoryAttributeService.removeByIds(Arrays.stream(ids).toList())); + } + + @GetMapping("/attribute_value_list") + public TableDataInfo attributeValueList(Integer categoryAttributeId) + { + var pageList = categoryAttributeValueService.list( + new LambdaQueryWrapper().eq(OGoodsCategoryAttributeValue::getCategoryAttributeId,categoryAttributeId)); + return getDataTable(pageList); + + } + + @PostMapping("/attribute_value") + public AjaxResult add(@RequestBody OGoodsCategoryAttributeValue attributeValue) + { + return toAjax(categoryAttributeValueService.save(attributeValue)); + } + @GetMapping(value = "/attribute_value/{id}") + public AjaxResult getAttributeValueInfo(@PathVariable("id") Long id) + { + return success(categoryAttributeValueService.getById(id)); + } + + @PutMapping("/attribute_value") + public AjaxResult attributeValueEdit(@RequestBody OGoodsCategoryAttributeValue attributeValue) + { + return toAjax(categoryAttributeValueService.updateById(attributeValue)); + } + + /** + * 删除商品分类属性值 + */ + @DeleteMapping("/attribute_value/{ids}") + public AjaxResult removeAttributeValue(@PathVariable Long[] ids) + { + return toAjax(categoryAttributeValueService.removeByIds(Arrays.stream(ids).toList())); + } +} diff --git a/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsController.java b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsController.java new file mode 100644 index 00000000..793522cd --- /dev/null +++ b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsController.java @@ -0,0 +1,247 @@ +package cn.qihangerp.oms.controller; + + + +import cn.qihangerp.common.PageQuery; +import cn.qihangerp.common.PageResult; +import cn.qihangerp.common.ResultVo; +import cn.qihangerp.common.AjaxResult; +import cn.qihangerp.common.TableDataInfo; + + +import cn.qihangerp.module.goods.domain.OGoods; +import cn.qihangerp.module.goods.domain.OGoodsSku; +import cn.qihangerp.module.goods.domain.bo.GoodsAddBo; +import cn.qihangerp.module.goods.domain.vo.GoodsSpecListVo; +import cn.qihangerp.module.goods.service.OGoodsService; + + +import cn.qihangerp.module.goods.service.OGoodsSkuService; +import cn.qihangerp.security.common.BaseController; +import com.fasterxml.jackson.databind.exc.InvalidFormatException; +import lombok.AllArgsConstructor; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.NumberToTextConverter; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 商品管理Controller + * + * @author qihang + * @date 2023-12-29 + */ +@AllArgsConstructor +@RestController +@RequestMapping("/goods") +public class GoodsController extends BaseController +{ + private final OGoodsService goodsService; + private final OGoodsSkuService skuService; + + /** + * 搜索商品SKU + * 条件:商品编码、SKU、商品名称 + */ + @GetMapping("/searchSku") + public TableDataInfo searchSkuBy(String keyword) + { + List list = goodsService.searchGoodsSpec(keyword); + return getDataTable(list); + } + + @GetMapping("/sku_list") + public TableDataInfo skuList(OGoodsSku bo, PageQuery pageQuery) + { + var pageList = goodsService.querySkuPageList(bo,pageQuery); + return getDataTable(pageList); + } + + /** + * 查询商品管理列表 + */ + @PreAuthorize("@ss.hasPermi('goods:goods:list')") + @GetMapping("/list") + public TableDataInfo list(OGoods goods, PageQuery pageQuery) + { + PageResult pageList = goodsService.queryPageList(goods, pageQuery); + return getDataTable(pageList); + } + + /** + * 获取商品管理详细信息 + */ + @PreAuthorize("@ss.hasPermi('goods:goods:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(goodsService.selectGoodsById(id)); + } + /** + * 获取商品管理详细信息 + */ + @PreAuthorize("@ss.hasPermi('goods:goods:query')") + @GetMapping(value = "/sku/{id}") + public AjaxResult getSkuInfo(@PathVariable("id") Long id) + { + return success(skuService.getById(id)); + } + /** + * 新增商品管理 + */ + @PreAuthorize("@ss.hasPermi('goods:goods:add')") + @PostMapping("/add") + public AjaxResult add(@RequestBody GoodsAddBo goods) + { + ResultVo resultVo = goodsService.insertGoods(getUsername(), goods); + if(resultVo.getCode()!=0) return AjaxResult.error(resultVo.getMsg()); + else return AjaxResult.success(resultVo.getData()); +// goods.setCreateBy(getUsername()); +// int result = goodsService.insertGoods(goods); +// if(result == -1) new AjaxResult(501,"商品编码已存在"); +// return toAjax(1); + } + + @PreAuthorize("@ss.hasPermi('goods:goods:add')") + @PostMapping("/goodsSku") + public AjaxResult addSku(@RequestBody OGoodsSku goodsSku) + { + + int result = goodsService.insertGoodsSku(goodsSku); + if(result == -1) new AjaxResult(501,"商品编码已存在"); + return toAjax(1); + } + + /** + * 修改商品管理 + */ + @PreAuthorize("@ss.hasPermi('goods:goods:edit')") + @PutMapping + public AjaxResult edit(@RequestBody OGoods goods) + { + return toAjax(goodsService.updateGoods(goods)); + } + + /** + * 修改商品基本资料 + * @param sku + * @return + */ + @PutMapping("/sku") + public AjaxResult editSku(@RequestBody OGoodsSku sku) + { + return toAjax(skuService.updateById(sku)); + } + + /** + * 删除商品管理 + */ + @PreAuthorize("@ss.hasPermi('goods:goods:remove')") + @DeleteMapping("/del/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + int result = goodsService.deleteGoodsByIds(ids); + if(result==0) return AjaxResult.success(); + else if (result==-100) return AjaxResult.error("有关联的订单,不能删除!"); + else return AjaxResult.error(); + } + + @RequestMapping(value = "/goods_sku_import", method = RequestMethod.POST) + public AjaxResult orderSendExcel(@RequestPart("file") MultipartFile file) throws IOException, InvalidFormatException { + + String fileName = file.getOriginalFilename(); + String dir = System.getProperty("user.dir"); + String destFileName = dir + File.separator + "/import/uploadedfiles_" + fileName; + System.out.println(destFileName); + File destFile = new File(destFileName); + file.transferTo(destFile); + InputStream fis = null; + fis = new FileInputStream(destFileName); + if (fis == null) return AjaxResult.error("没有文件"); + + Workbook workbook = null; + + try { + if (fileName.toLowerCase().endsWith("xlsx")) { + workbook = new XSSFWorkbook(fis); + } else if (fileName.toLowerCase().endsWith("xls")) { + workbook = new HSSFWorkbook(fis); + } + // workbook = new HSSFWorkbook(fis); + } catch (Exception ex) { + return AjaxResult.error(ex.getMessage()); + } + + if (workbook == null) return AjaxResult.error(502, "未读取到Excel文件"); + + /****************开始处理excel****************/ + int success = 0; + int fail = 0; + Sheet sheet = null; + try { + sheet = workbook.getSheetAt(0); + int lastRowNum = sheet.getLastRowNum();//最后一行索引 + Row row = null; + + for (int i = 1; i <= lastRowNum; i++) { + row = sheet.getRow(i); + //数据 + OGoodsSku sku = new OGoodsSku(); + for(int c=0;c<6;c++){ + Cell cell = row.getCell(c); + String cellValue = ""; + if (cell != null) { + if (cell.getCellType() == CellType.STRING) { + cellValue = cell.getStringCellValue().replace("\t", ""); + } else if (cell.getCellType() == CellType.NUMERIC) { + cellValue = NumberToTextConverter.toText(cell.getNumericCellValue()).replace("\t", ""); + } + } + if(c == 1) { + if(StringUtils.hasText(cellValue) ){ + sku.setOuterErpGoodsId(cellValue); + }else { + sku.setOuterErpGoodsId("0"); + } + } + if(StringUtils.hasText(cellValue)) { + if (c == 0) { + sku.setOuterErpSkuId(cellValue); + } else if (c == 2) { + sku.setSkuCode(cellValue); + } else if (c == 3) { + sku.setSkuName(cellValue); + } else if (c == 4) { + sku.setColorImage(cellValue); + } else if (c == 5) { + sku.setRemark(cellValue); + } + } + } + goodsService.insertGoodsSku(sku); + success++; + } + + + } catch (Exception ex) { + fail++; + ex.printStackTrace(); + } + Map result = new HashMap<>(); + result.put("success",success); + result.put("fail",fail); + return AjaxResult.success(result); + } +} diff --git a/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsInventoryController.java b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsInventoryController.java new file mode 100644 index 00000000..ca8b98eb --- /dev/null +++ b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsInventoryController.java @@ -0,0 +1,47 @@ +package cn.qihangerp.oms.controller; + + +import cn.qihangerp.common.PageQuery; +import cn.qihangerp.common.PageResult; + +import cn.qihangerp.common.AjaxResult; +import cn.qihangerp.common.TableDataInfo; +import cn.qihangerp.module.goods.domain.OGoodsInventory; +import cn.qihangerp.module.goods.domain.OGoodsInventoryBatch; +import cn.qihangerp.module.goods.service.OGoodsInventoryBatchService; +import cn.qihangerp.module.goods.service.OGoodsInventoryService; +import cn.qihangerp.security.common.BaseController; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@AllArgsConstructor +@RestController +@RequestMapping("/goodsInventory") +public class GoodsInventoryController extends BaseController { + private final OGoodsInventoryService goodsInventoryService; + private final OGoodsInventoryBatchService inventoryBatchService; + + @GetMapping("/list") + public TableDataInfo list(OGoodsInventory bo, PageQuery pageQuery) + { + PageResult pageResult = goodsInventoryService.queryPageList(bo, pageQuery); + return getDataTable(pageResult); + } + + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + OGoodsInventory goodsInventory = goodsInventoryService.getById(id); + if(goodsInventory!=null) { + List list = inventoryBatchService.list(new LambdaQueryWrapper().eq(OGoodsInventoryBatch::getSkuId, goodsInventory.getSkuId())); + return AjaxResult.success(list); + } + return success(); + } +} diff --git a/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsSupplierController.java b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsSupplierController.java new file mode 100644 index 00000000..71451fda --- /dev/null +++ b/microservices/goods-api/src/main/java/cn/qihangerp/api/goods/controller/GoodsSupplierController.java @@ -0,0 +1,67 @@ +package cn.qihangerp.oms.controller; + + +import cn.qihangerp.common.PageQuery; + +import cn.qihangerp.common.AjaxResult; +import cn.qihangerp.common.TableDataInfo; +import cn.qihangerp.module.goods.domain.OGoodsSupplier; +import cn.qihangerp.module.goods.service.OGoodsSupplierService; +import cn.qihangerp.security.common.BaseController; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.Arrays; +import java.util.Date; + +@AllArgsConstructor +@RestController +@RequestMapping("/supplier") +public class GoodsSupplierController extends BaseController { + private final OGoodsSupplierService supplierService; + + @GetMapping("/list") + public TableDataInfo list(OGoodsSupplier bo, PageQuery pageQuery) + { + var pageList = supplierService.queryPageList(bo,pageQuery); + return getDataTable(pageList); + } + + /** + * 获取【请填写功能名称】详细信息 + */ + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(supplierService.getById(id)); + } + + /** + * 新增【请填写功能名称】 + */ + @PostMapping + public AjaxResult add(@RequestBody OGoodsSupplier scmSupplier) + { + scmSupplier.setCreatetime(new Date()); + scmSupplier.setIsdelete(0); + return toAjax(supplierService.save(scmSupplier)); + } + + /** + * 修改【请填写功能名称】 + */ + @PutMapping + public AjaxResult edit(@RequestBody OGoodsSupplier scmSupplier) + { + return toAjax(supplierService.updateById(scmSupplier)); + } + + /** + * 删除【请填写功能名称】 + */ + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(supplierService.removeByIds(Arrays.stream(ids).toList())); + } +} diff --git a/microservices/goods-api/src/main/resources/META-INF/spring.factories b/microservices/goods-api/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..c52354d8 --- /dev/null +++ b/microservices/goods-api/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.zhijian.FrameworkAutoConfiguration \ No newline at end of file diff --git a/microservices/goods-api/src/main/resources/application.yml b/microservices/goods-api/src/main/resources/application.yml new file mode 100644 index 00000000..5f368c1d --- /dev/null +++ b/microservices/goods-api/src/main/resources/application.yml @@ -0,0 +1,89 @@ +server: + port: 8083 +spring: + application: + name: oms-api + cloud: + loadbalancer: + nacos: + enabled: true + nacos: + # serverAddr: 127.0.0.1:8848 + discovery: + server-addr: 127.0.0.1:8848 +# username: nacos +# password: nacos + + data: + # redis 配置 + redis: + # 地址 + # host: 8.130.98.215 + host: 127.0.0.1 + # 端口,默认为6379 + port: 6379 + # 数据库索引 + database: 0 + # 密码 + # password: 123321 + # 连接超时时间 + timeout: 10s + lettuce: + pool: + # 连接池中的最小空闲连接 + min-idle: 0 + # 连接池中的最大空闲连接 + max-idle: 8 + # 连接池的最大数据库连接数 + max-active: 8 + # #连接池最大阻塞等待时间(使用负值表示没有限制) + max-wait: -1ms + datasource: + driverClassName: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/qihang-oms?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: Andy_123 +# kafka: +# bootstrap-servers: localhost:9092 +# producer: +# batch-size: 16384 #批量大小 +# acks: -1 #应答级别:多少个分区副本备份完成时向生产者发送ack确认(可选0、1、all/-1) +# retries: 10 # 消息发送重试次数 +# # transaction-id-prefix: tx_1 #事务id前缀 +# buffer-memory: 33554432 +# key-serializer: org.apache.kafka.common.serialization.StringSerializer +# value-serializer: org.apache.kafka.common.serialization.StringSerializer +# properties: +# linger: +# ms: 2000 #提交延迟 +# # partitioner: #指定分区器 +# # class: com.example.kafkademo.config.CustomizePartitioner +# consumer: +# group-id: testGroup #默认的消费组ID +# enable-auto-commit: true #是否自动提交offset +# auto-commit-interval: 2000 #提交offset延时 +# # 当kafka中没有初始offset或offset超出范围时将自动重置offset +# # earliest:重置为分区中最小的offset; +# # latest:重置为分区中最新的offset(消费分区中新产生的数据); +# # none:只要有一个分区不存在已提交的offset,就抛出异常; +# auto-offset-reset: latest +# max-poll-records: 500 #单次拉取消息的最大条数 +# key-deserializer: org.apache.kafka.common.serialization.StringDeserializer +# value-deserializer: org.apache.kafka.common.serialization.StringDeserializer +# properties: +# session: +# timeout: +# ms: 120000 # 消费会话超时时间(超过这个时间 consumer 没有发送心跳,就会触发 rebalance 操作) +# request: +# timeout: +# ms: 18000 # 消费请求的超时时间 + + + + + +mybatis-plus: + mapper-locations: classpath*:mapper/**/*Mapper.xml + type-aliases-package: cn.qihangerp.oms.domain;cn.qihangerp.module.domain;cn.qihangerp.security.entity; + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 开启sql日志 \ No newline at end of file diff --git a/microservices/goods-api/src/main/resources/banner.txt b/microservices/goods-api/src/main/resources/banner.txt new file mode 100644 index 00000000..bda2abc7 --- /dev/null +++ b/microservices/goods-api/src/main/resources/banner.txt @@ -0,0 +1,24 @@ +Application Version: ${zhijian.version} +Spring Boot Version: ${spring-boot.version} +//////////////////////////////////////////////////////////////////// +// _ooOoo_ // +// o8888888o // +// 88" . "88 // +// (| ^_^ |) // +// O\ = /O // +// ____/`---'\____ // +// .' \\| |// `. // +// / \\||| : |||// \ // +// / _||||| -:- |||||- \ // +// | | \\\ - /// | | // +// | \_| ''\---/'' | | // +// \ .-\__ `-` ___/-. / // +// ___`. .' /--.--\ `. . ___ // +// ."" '< `.___\_<|>_/___.' >'"". // +// | | : `- \`.;`\ _ /`;.`/ - ` : | | // +// \ \ `-. \_ __\ /__ _/ .-` / / // +// ========`-.____`-.___\_____/___.-`____.-'======== // +// `=---=' // +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // +// 佛祖保佑 永不宕机 永无BUG // +//////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/microservices/pom.xml b/microservices/pom.xml new file mode 100644 index 00000000..420c597e --- /dev/null +++ b/microservices/pom.xml @@ -0,0 +1,30 @@ + + 4.0.0 + + cn.qihangerp + qihangerp-cloud + 2.0.6 + + + cn.qihangerp.services + microservices + 3.0.6 + jar + + microservices + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + +