From 3b7250f1bcaeb5663e75ddf0cc14bbac6930a334 Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期一, 11 九月 2023 14:50:12 +0800 Subject: [PATCH] a --- server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-) diff --git a/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java index cd8eea3..0e5c1ad 100644 --- a/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java +++ b/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java @@ -17,6 +17,7 @@ import com.doumee.dao.business.*; import com.doumee.dao.business.join.GoodsJoinMapper; import com.doumee.dao.business.model.*; +import com.doumee.dao.business.model.dto.GoodCreatePlatRequest; import com.doumee.dao.business.model.dto.GoodsRequest; import com.doumee.service.business.GoodsService; import com.github.yulichang.wrapper.MPJLambdaWrapper; @@ -120,6 +121,65 @@ return goods.getId(); } + @Override + public Integer createPlat(GoodCreatePlatRequest param){ + LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); + if(Constants.equalsInteger(user.getType(), Constants.UserType.COMPANY.getKey())){ + //闈炰紒涓氱敤鎴蜂笉鑳芥搷浣� + throw new BusinessException(ResponseStatus.NOT_ALLOWED); + } + if(param.getCategoryId() == null + || param.getType() == null + || param.getRate() == null + || (Constants.equalsInteger(param.getType(), Constants.ONE) + && (param.getGoodsParamList() == null + || param.getGoodsParamList().size()==0))){ + throw new BusinessException(ResponseStatus.BAD_REQUEST); + } + Goods goods = new Goods(); + + if(goodsMapper.selectCount(new QueryWrapper<Goods>().eq("ISDELETED",Constants.ZERO).eq("name",goods.getName()))>0){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"銆�"+goods.getName()+"銆戝凡瀛樺湪"); + } + goods.setStatus(Constants.ZERO); + goods.setCreateDate(new Date()); + goods.setCreator(user.getId()); + goods.setIsdeleted(Constants.ZERO); + //澶勭悊鎷奸煶闂 + goods.setPinyin(PinYinUtil.getFullSpell(goods.getName())); + goods.setShortPinyin(PinYinUtil.getFirstSpell(goods.getName())); + goodsMapper.insert(goods); + + List<Multifile> multifileList = goods.getMultifileList(); + if(!Objects.isNull(multifileList)&&multifileList.size()>Constants.ZERO){ + for (int i = 0; i < multifileList.size(); i++) { + Multifile multifile = multifileList.get(i); + multifile.setCreator(user.getId()); + multifile.setCreateDate(new Date()); + multifile.setIsdeleted(Constants.ZERO); + multifile.setSortnum(i+Constants.ONE); + multifile.setObjId(goods.getId()); + multifile.setType(Constants.ZERO); + multifile.setObjType(Constants.ZERO); + multifileMapper.insert(multifile); + } + } + List<GoodsParam> goodsParamList = goods.getGoodsParamList(); + if(!Objects.isNull(goodsParamList)&&goodsParamList.size()>0){ + for (int i = 0; i < goodsParamList.size(); i++) { + GoodsParam goodsParam = goodsParamList.get(i); + goodsParam.setCreator(user.getId()); + goodsParam.setCreateDate(new Date()); + goodsParam.setIsdeleted(Constants.ZERO); + goodsParam.setSortnum(i+Constants.ONE); + goodsParam.setStatus(Constants.ZERO); + goodsParam.setGoodsId(goods.getId()); + goodsParamMapper.insert(goodsParam); + } + } + + return goods.getId(); + } @Override public void deleteById(Integer id) { -- Gitblit v1.9.3