From 1d53ad5a5119a2b1cd6593e2d349e67a0b8bb21a Mon Sep 17 00:00:00 2001 From: "kuang.yife" Date: Sat, 11 Feb 2023 10:38:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=83=AD=E9=97=A8=E7=B1=BB=E7=9B=AE/=E7=B1=BB?= =?UTF-8?q?=E7=9B=AE=E5=88=AB=E5=90=8D/=E7=B1=BB=E7=9B=AE=E5=9B=BE?= =?UTF-8?q?=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/GoodsDeptCategoryController.java | 9 +++- .../web/controller/tool/QiniuController.java | 28 +++++++++++ .../goods/deptcategory/deptcategory.html | 3 +- .../templates/goods/deptcategory/edit.html | 48 +++++++++++++++++++ .../ghy/goods/domain/DeptGoodsCategory.java | 7 +++ .../impl/DeptGoodsCategoryServiceImpl.java | 17 +++++++ .../mapper/goods/DeptGoodsCategoryMapper.xml | 6 ++- 7 files changed, 113 insertions(+), 5 deletions(-) diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java index 4b52fc47..2bd0f406 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java @@ -9,6 +9,7 @@ import com.ghy.common.enums.BusinessType; import com.ghy.common.enums.ImgType; import com.ghy.common.utils.ExceptionUtil; import com.ghy.common.utils.ShiroUtils; +import com.ghy.common.utils.StringUtils; import com.ghy.goods.domain.DeptGoodsCategory; import com.ghy.goods.domain.GoodsImgs; import com.ghy.goods.service.DeptGoodsCategoryService; @@ -116,14 +117,18 @@ public class GoodsDeptCategoryController extends BaseController { GoodsImgs qryImgsObj = new GoodsImgs(); qryImgsObj.setRemark(hotCategory.getDeptGoodsCategoryId().toString()); qryImgsObj.setImgType(ImgType.HOT_CATEGORY_IMG.getId()); - qryImgsObj.setGoodsId(0l); + qryImgsObj.setGoodsId(0L); List goodsImgs = goodsImgsService.qryGoodsImgs(qryImgsObj); hotCategory.setHotCategoryImgs(goodsImgs.stream().map(GoodsImgs::getImgUrl).collect(Collectors.toList())); HotCategoryResponse hotCategoryResponse = new HotCategoryResponse(); BeanUtils.copyProperties(hotCategory, hotCategoryResponse); hotCategoryResponse.setId(hotCategory.getDeptGoodsCategoryId()); - hotCategoryResponse.setName(hotCategory.getGoodsCategoryName()); + if(StringUtils.isNotEmpty(hotCategory.getHotName())){ + hotCategoryResponse.setName(hotCategory.getHotName()); + }else { + hotCategoryResponse.setName(hotCategory.getGoodsCategoryName()); + } hotCategoryResponse.setDesc(hotCategory.getRemark()); hotCategoryResponse.setImgs(hotCategory.getHotCategoryImgs()); responses.add(hotCategoryResponse); diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/tool/QiniuController.java b/ghy-admin/src/main/java/com/ghy/web/controller/tool/QiniuController.java index 9e6b4bf9..ba145adc 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/tool/QiniuController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/tool/QiniuController.java @@ -11,6 +11,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; /** * 七牛云 @@ -42,4 +46,28 @@ public class QiniuController { } } + /** + * 七牛云上传(单个) + */ + @PostMapping(value = "/dept/upload") + @ResponseBody + @ApiOperation("七牛云上传接口") + public AjaxResult uploadFile(HttpServletRequest request, HttpServletResponse response) { + try { + String name = request.getParameter("name"); + // 转型为MultipartHttpRequest: + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + // 获得实际: + MultipartFile file= multipartRequest.getFile(name); + // 上传后返回的文件路径 + String fileUrl = QiniuUtils.upload(file.getBytes()); + logger.info("upload return url is : " + fileUrl); + AjaxResult ajax = AjaxResult.success(); + ajax.put("url", fileUrl); + return ajax; + } catch (Exception e) { + return AjaxResult.error(e.getMessage()); + } + } + } diff --git a/ghy-admin/src/main/resources/templates/goods/deptcategory/deptcategory.html b/ghy-admin/src/main/resources/templates/goods/deptcategory/deptcategory.html index 63129401..d6b0e155 100644 --- a/ghy-admin/src/main/resources/templates/goods/deptcategory/deptcategory.html +++ b/ghy-admin/src/main/resources/templates/goods/deptcategory/deptcategory.html @@ -2,6 +2,7 @@ +
@@ -144,7 +145,7 @@ formatter: function (value, row, index) { if (row.parentId !== 0) { var actions = []; - actions.push('编辑 '); + actions.push('编辑 '); // actions.push('新增 '); // actions.push('删除'); return actions.join(''); diff --git a/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html b/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html index 69d4c715..f3b0cdb5 100644 --- a/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html +++ b/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html @@ -126,11 +126,31 @@
+
+
+
+ +
+ +
+
+
+
+
+ +
+ + +
+
+ + \ No newline at end of file diff --git a/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java b/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java index 6e9f82ed..682b4ae5 100644 --- a/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java +++ b/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java @@ -27,6 +27,8 @@ public class DeptGoodsCategory extends GoodsCategory { @Excel(name = "是否热门类目 0.不是,1.是", cellType = Excel.ColumnType.NUMERIC) private Integer isHot; + private String hotName; + @Excel(name = "一级分销扣点比例", cellType = Excel.ColumnType.STRING) private String oneRate; @@ -64,4 +66,9 @@ public class DeptGoodsCategory extends GoodsCategory { private Boolean isAllNode; private List hotCategoryImgs; + + private String categoryUrl; + + private String hotCategoryName; + } diff --git a/ghy-goods/src/main/java/com/ghy/goods/service/impl/DeptGoodsCategoryServiceImpl.java b/ghy-goods/src/main/java/com/ghy/goods/service/impl/DeptGoodsCategoryServiceImpl.java index 61398106..9f60ea01 100644 --- a/ghy-goods/src/main/java/com/ghy/goods/service/impl/DeptGoodsCategoryServiceImpl.java +++ b/ghy-goods/src/main/java/com/ghy/goods/service/impl/DeptGoodsCategoryServiceImpl.java @@ -7,9 +7,11 @@ import com.ghy.common.core.text.Convert; import com.ghy.common.utils.StringUtils; import com.ghy.goods.domain.DeptGoodsCategory; import com.ghy.goods.domain.GoodsCategory; +import com.ghy.goods.domain.GoodsImgs; import com.ghy.goods.mapper.DeptGoodsCategoryMapper; import com.ghy.goods.service.DeptGoodsCategoryService; import com.ghy.goods.service.GoodsCategoryService; +import com.ghy.goods.service.GoodsImgsService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -31,6 +33,8 @@ public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService { private GoodsCategoryService goodsCategoryService; @Resource private DeptGoodsCategoryMapper deptGoodsCategoryMapper; + @Resource + private GoodsImgsService goodsImgsService; @Override public List list(DeptGoodsCategory category) { @@ -44,6 +48,19 @@ public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService { @Override public int edit(DeptGoodsCategory deptGoodsCategory) { + if(StringUtils.isNotEmpty(deptGoodsCategory.getCategoryUrl())){ + String[] split = deptGoodsCategory.getCategoryUrl().split(","); + List list = new ArrayList<>(); + for (String url : split){ + GoodsImgs goodsImgs = new GoodsImgs(); + goodsImgs.setGoodsId(0L); + goodsImgs.setImgUrl(url); + goodsImgs.setImgType(3); + goodsImgs.setRemark(String.valueOf(deptGoodsCategory.getDeptGoodsCategoryId())); + list.add(goodsImgs); + } + goodsImgsService.batchInsert(list); + } return deptGoodsCategoryMapper.updateDeptGoodsCategory(deptGoodsCategory); } diff --git a/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml b/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml index b453c64a..09fd1b41 100644 --- a/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml +++ b/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml @@ -16,6 +16,7 @@ + @@ -31,7 +32,7 @@ - SELECT dept_goods_category_id, dept_id, goods_category_id, category_sort, is_hot, + SELECT dept_goods_category_id, dept_id, goods_category_id, category_sort, is_hot, hot_name, one_rate, two_rate, three_rate, dept_rate, dept_money, retain_rate, retain_money, create_by, create_time, remark FROM dept_goods_category @@ -39,7 +40,7 @@ SELECT dgc.dept_goods_category_id, dgc.dept_id, dgc.goods_category_id, dgc.category_sort, dgc.one_rate, dgc.two_rate, dgc.three_rate, dgc.create_by, dgc.create_time, dgc.remark, - dgc.is_hot, dgc.dept_rate, dgc.dept_money, dgc.retain_rate, dgc.retain_money, + dgc.is_hot, dgc.hot_name, dgc.dept_rate, dgc.dept_money, dgc.retain_rate, dgc.retain_money, dgc.dept_category_name, gc.goods_category_name, gc.level, gc.parent_category_id, gc.type, gc.status, gc.cover, gc.simple_goods_category_name FROM dept_goods_category dgc LEFT JOIN goods_category gc ON dgc.goods_category_id = gc.goods_category_id @@ -67,6 +68,7 @@ dept_category_name = #{deptCategoryName}, is_hot = #{isHot}, + hot_name = #{hotName}, dept_rate = #{deptRate}, dept_money = #{deptMoney}, retain_rate = #{retainRate},