fix
This commit is contained in:
parent
95cb637e18
commit
2547d9b92c
|
|
@ -8,9 +8,13 @@ import com.ghy.common.enums.BusinessType;
|
|||
import com.ghy.common.utils.ExceptionUtil;
|
||||
import com.ghy.common.utils.ShiroUtils;
|
||||
import com.ghy.common.utils.StringUtils;
|
||||
import com.ghy.common.utils.bean.BeanUtils;
|
||||
import com.ghy.common.utils.poi.ExcelUtil;
|
||||
import com.ghy.goods.domain.*;
|
||||
import com.ghy.goods.service.*;
|
||||
import com.ghy.system.domain.SysArea;
|
||||
import com.ghy.system.service.ISysAreaService;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
|
@ -41,6 +45,8 @@ public class GoodsController extends BaseController {
|
|||
private GoodsAreaService goodsAreaService;
|
||||
@Resource
|
||||
private GoodsStandardService goodsStandardService;
|
||||
@Resource
|
||||
private ISysAreaService sysAreaService;
|
||||
|
||||
@RequiresPermissions("goods:goods:view")
|
||||
@GetMapping()
|
||||
|
|
@ -66,6 +72,83 @@ public class GoodsController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PostMapping("/app/detail")
|
||||
@ResponseBody
|
||||
public AjaxResult appDetail(@RequestBody Goods goods){
|
||||
try {
|
||||
GoodsEditReq goodsEditReq = new GoodsEditReq();
|
||||
List<Goods> list = goodsService.selectGoodsList(goods);
|
||||
if(CollectionUtils.isNotEmpty(list)){
|
||||
BeanUtils.copyProperties(list.get(0), goodsEditReq);
|
||||
}
|
||||
// 补全商品服务区域
|
||||
List<GoodsArea> goodsAreas = goodsAreaService.selectByGoodsId(goodsEditReq.getGoodsId());
|
||||
if(CollectionUtils.isNotEmpty(goodsAreas)){
|
||||
String areaName;
|
||||
GoodsArea goodsArea = goodsAreas.get(0);
|
||||
// 第三级
|
||||
SysArea sysArea3 = sysAreaService.selectById(goodsArea.getCountryAreaId());
|
||||
// 第二级
|
||||
SysArea sysArea2 = sysAreaService.selectByAreaCode(sysArea3.getParentCode());
|
||||
// 第一级
|
||||
SysArea sysArea1 = sysAreaService.selectByAreaCode(sysArea2.getParentCode());
|
||||
areaName = sysArea1.getAreaName() + "-" + sysArea2.getAreaName();
|
||||
goodsEditReq.setAreaConcatName(areaName);
|
||||
goodsEditReq.setParentAreaId(sysArea2.getAreaId());
|
||||
}
|
||||
goodsEditReq.setGoodsAreaList(goodsAreas);
|
||||
|
||||
|
||||
// 补全商品规格
|
||||
List<GoodsStandard> goodsStandards = goodsStandardService.selectByGoodsId(goodsEditReq.getGoodsId());
|
||||
if(CollectionUtils.isNotEmpty(goodsStandards)){
|
||||
String standardConcatName;
|
||||
GoodsStandard goodsStandard = goodsStandards.get(0);
|
||||
DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.get(goodsStandard.getDeptGoodsCategoryId());
|
||||
// 当前层级4
|
||||
GoodsCategory goodsCategory4 = goodsCategoryService.selectById(deptGoodsCategory.getGoodsCategoryId());
|
||||
GoodsCategory goodsCategory3 = goodsCategoryService.selectById(goodsCategory4.getParentCategoryId());
|
||||
GoodsCategory goodsCategory2 = goodsCategoryService.selectById(goodsCategory3.getParentCategoryId());
|
||||
GoodsCategory goodsCategory1 = goodsCategoryService.selectById(goodsCategory2.getParentCategoryId());
|
||||
standardConcatName = goodsCategory1.getGoodsCategoryName() + "-" + goodsCategory2.getGoodsCategoryName() + "-" + goodsCategory3.getGoodsCategoryName();
|
||||
goodsEditReq.setCategoryConcatName(standardConcatName);
|
||||
}
|
||||
//
|
||||
goodsStandards.forEach(goodsStandard -> {
|
||||
DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.get(goodsStandard.getDeptGoodsCategoryId());
|
||||
GoodsCategory category = goodsCategoryService.selectById(deptGoodsCategory.getGoodsCategoryId());
|
||||
goodsStandard.setGoodsCategoryName(category.getGoodsCategoryName());
|
||||
goodsStandard.setChecked(true);
|
||||
});
|
||||
goodsEditReq.setGoodsStandardList(goodsStandards);
|
||||
|
||||
// 补全商品类目及父级类目信息
|
||||
GoodsCategory goodsCategory = goodsCategoryService.selectById(goodsEditReq.getDeptGoodsCategoryId());
|
||||
goodsEditReq.setDeptGoodsCategoryName(goodsCategory.getGoodsCategoryName());
|
||||
if (goodsCategory.getParentCategoryId() != null) {
|
||||
GoodsCategory parGoodsCategory = goodsCategoryService.selectById(goodsCategory.getParentCategoryId());
|
||||
goodsEditReq.setParGoodsCategoryId(parGoodsCategory.getGoodsCategoryId());
|
||||
goodsEditReq.setParGoodsCategoryName(parGoodsCategory.getGoodsCategoryName());
|
||||
}
|
||||
List<String> detailUrl = new ArrayList<>();
|
||||
List<String> lbUrl = new ArrayList<>();
|
||||
List<GoodsImgs> goodsImgs = goodsImgsService.selectByGoodsId(goods.getGoodsId());
|
||||
goodsImgs.forEach(imgs -> {
|
||||
if(imgs.getImgType() == 0){
|
||||
lbUrl.add(imgs.getImgUrl());
|
||||
}else if(imgs.getImgType() == 1){
|
||||
detailUrl.add(imgs.getImgUrl());
|
||||
}
|
||||
});
|
||||
goodsEditReq.setLbUrl(lbUrl);
|
||||
goodsEditReq.setDetailUrl(detailUrl);
|
||||
return AjaxResult.success(goodsEditReq);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/app/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo appList(@RequestBody Goods goods) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.ghy.common.core.domain.BaseEntity;
|
|||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -40,6 +41,8 @@ public class Goods extends BaseEntity {
|
|||
|
||||
private String expectDuration;
|
||||
|
||||
private String areaDesc;
|
||||
|
||||
@Excel(name = "商品排序", cellType = Excel.ColumnType.NUMERIC)
|
||||
private Integer goodsSort;
|
||||
|
||||
|
|
@ -80,4 +83,9 @@ public class Goods extends BaseEntity {
|
|||
private List<GoodsImgs> goodsImgsList;
|
||||
|
||||
private List<GoodsStandard> goodsStandardList;
|
||||
|
||||
private List<String> detailUrl;
|
||||
|
||||
private List<String> lbUrl;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,4 +21,6 @@ public class GoodsArea {
|
|||
|
||||
private String areaName;
|
||||
|
||||
private boolean checked;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.ghy.goods.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author clunt
|
||||
*/
|
||||
@Data
|
||||
public class GoodsEditReq extends Goods{
|
||||
|
||||
private String categoryConcatName;
|
||||
|
||||
private List<GoodsStandard> goodsStandards;
|
||||
|
||||
private String areaConcatName;
|
||||
|
||||
private Long parentAreaId;
|
||||
|
||||
}
|
||||
|
|
@ -43,4 +43,8 @@ public class GoodsStandard extends BaseEntity {
|
|||
|
||||
private BigDecimal finalPrice;
|
||||
|
||||
private boolean checked;
|
||||
|
||||
private String goodsCategoryName;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,16 +24,17 @@
|
|||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="areaDesc" column="area_desc" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectGoods">
|
||||
SELECT goods_id, goods_code, dept_id, goods_name, goods_desc, warranty_period, serv_activity, goods_unit, expect_duration, goods_sort, worker_id,
|
||||
dept_goods_category_id, goods_img_url, goods_video_url, status, create_by, create_time, remark
|
||||
dept_goods_category_id, goods_img_url, goods_video_url, status, create_by, create_time, remark, area_desc
|
||||
FROM goods
|
||||
</sql>
|
||||
<sql id="selectGoodsWithArea">
|
||||
SELECT DISTINCT g.goods_id, goods_code, dept_id, goods_name, goods_desc, goods_sort, worker_id, goods_unit, warranty_period, serv_activity, expect_duration,
|
||||
dept_goods_category_id, goods_img_url, goods_video_url, status, g.create_by, g.create_time, g.remark
|
||||
dept_goods_category_id, goods_img_url, goods_video_url, status, g.create_by, g.create_time, g.remark, g.area_desc
|
||||
FROM goods g
|
||||
LEFT JOIN goods_area ga ON g.goods_id = ga.goods_id
|
||||
</sql>
|
||||
|
|
@ -53,6 +54,7 @@
|
|||
<if test="servActivity != null and servActivity!=''">serv_activity = #{servActivity},</if>
|
||||
<if test="expectDuration != null and expectDuration!=''">expect_duration = #{expectDuration},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="areaDesc != null and areaDesc != ''">area_desc = #{areaDesc},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
WHERE goods_id = #{goodsId}
|
||||
|
|
@ -81,6 +83,7 @@
|
|||
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">goods_video_url,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="areaDesc != null and areaDesc != ''">area_desc,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
|
|
@ -99,6 +102,7 @@
|
|||
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">#{goodsVideoUrl},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="areaDesc != null and areaDesc != ''">#{areaDesc},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
|
|
@ -141,6 +145,9 @@
|
|||
<if test="workerId != null">
|
||||
AND worker_id = #{workerId}
|
||||
</if>
|
||||
<if test="goodsId != null">
|
||||
AND g.goods_id = #{goodsId}
|
||||
</if>
|
||||
</where>
|
||||
/* 默认生成时间排序 */
|
||||
order by create_time
|
||||
|
|
|
|||
Loading…
Reference in New Issue