From 207dc8655711cddac2653e18b51e58a88dba2084 Mon Sep 17 00:00:00 2001 From: yj <Administrator@192> Date: 星期五, 06 三月 2020 18:14:36 +0800 Subject: [PATCH] 发圈处理 --- fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassServiceImpl.java | 49 +++++++++++++++++++++++-------------------------- 1 files changed, 23 insertions(+), 26 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassServiceImpl.java index 6fd3bc5..a70a564 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassServiceImpl.java @@ -13,6 +13,7 @@ import com.yeshi.fanli.entity.bus.clazz.GoodsClass; import com.yeshi.fanli.exception.brand.BrandClassException; import com.yeshi.fanli.service.inter.brand.BrandClassService; +import com.yeshi.fanli.service.inter.brand.BrandClassShopService; import com.yeshi.fanli.service.inter.goods.GoodsClassService; @Service @@ -24,6 +25,16 @@ @Resource private GoodsClassService goodsClassService; + @Resource + private BrandClassShopService brandClassShopService; + + + @Override + public BrandClass selectByPrimaryKey(Long id) { + return brandClassMapper.selectByPrimaryKey(id); + } + + @Override public List<BrandClass> listEffective() { return brandClassMapper.listEffective(); @@ -40,38 +51,30 @@ @Override public void saveObject(BrandClass record) throws BrandClassException, Exception{ Long gcid = record.getGcid(); - if (gcid != null) { - GoodsClass goodsClass = goodsClassService.selectByPrimaryKey(gcid); - if (goodsClass != null) { - record.setName(goodsClass.getName()); - record.setGoodsClass(goodsClass); - } - } + if (gcid != null) + record.setGoodsClass(new GoodsClass(gcid)); String name = record.getName(); - if (name == null || name.trim().length() == 0) { + if (name == null || name.trim().length() == 0) throw new BrandClassException(1, "鍚嶇О鍜屽垎绫讳笉鑳藉悓鏃朵负绌�"); - } Integer state = record.getState(); - if (state == null) { + if (state == null) record.setState(0); - } + + record.setUpdateTime(new Date()); Long id = record.getId(); if (id == null) { record.setOrderBy(brandClassMapper.getMaxOrder() + 1); record.setCreateTime(new Date()); - record.setUpdateTime(new Date()); brandClassMapper.insert(record); } else { BrandClass resultObj = brandClassMapper.selectByPrimaryKey(id); - if (resultObj == null) { + if (resultObj == null) throw new BrandClassException(1, "淇敼鍐呭宸蹭笉瀛樺湪"); - } record.setOrderBy(resultObj.getOrderBy()); record.setCreateTime(resultObj.getCreateTime()); - record.setUpdateTime(new Date()); brandClassMapper.updateByPrimaryKey(record); } } @@ -79,26 +82,22 @@ @Override public void updateOrder(Long id, Integer moveType) throws BrandClassException, Exception{ - - if (moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) { + if (moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) throw new BrandClassException(1, "浼犻�掔殑绫诲瀷涓嶆纭�"); - } - if (id == null) { + if (id == null) throw new BrandClassException(1, "ID涓嶈兘涓虹┖"); - } BrandClass resultObj = brandClassMapper.selectByPrimaryKey(id); - if (resultObj == null) { + if (resultObj == null) throw new BrandClassException(1, "鎿嶄綔鏁版嵁宸蹭笉瀛樺湪"); - } Integer oldOrder = resultObj.getOrderBy(); BrandClass changeObj = brandClassMapper.getByAdjoinOrder(oldOrder, moveType); - if (changeObj == null ) { + if (changeObj == null ) throw new BrandClassException(1, "宸茬粡鍦ㄦ渶杈圭紭锛屾棤鍙氦鎹㈢殑浣嶇疆"); - } + // 浜ゆ崲鎺掑簭搴忓彿 resultObj.setOrderBy(changeObj.getOrderBy()); changeObj.setOrderBy(oldOrder); @@ -116,7 +115,6 @@ @Override public List<BrandClass> listQuery(long start, int count, String key, Integer state) { - List<BrandClass> listQuery = brandClassMapper.listQuery(start, count, key, state); if (listQuery == null || listQuery.size() == 0) { return listQuery; @@ -140,7 +138,6 @@ public long countQuery(String key, Integer state) { return brandClassMapper.countQuery(key, state); } - } -- Gitblit v1.8.0