|
|
|
@ -23,16 +23,22 @@ import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.dao.AcitveProductInfoDao; |
|
|
|
import com.elink.esua.epdc.dto.AcitveProductInfoDTO; |
|
|
|
import com.elink.esua.epdc.entity.AcitveProductDeptEntity; |
|
|
|
import com.elink.esua.epdc.entity.AcitveProductInfoEntity; |
|
|
|
import com.elink.esua.epdc.feign.AdminFeignClient; |
|
|
|
import com.elink.esua.epdc.redis.AcitveProductInfoRedis; |
|
|
|
import com.elink.esua.epdc.service.AcitveProductDeptService; |
|
|
|
import com.elink.esua.epdc.service.AcitveProductInfoService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.bind.annotation.PathVariable; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
@ -49,6 +55,13 @@ public class AcitveProductInfoServiceImpl extends BaseServiceImpl<AcitveProductI |
|
|
|
@Autowired |
|
|
|
private AcitveProductInfoRedis acitveProductInfoRedis; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AdminFeignClient adminFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AcitveProductDeptService acitveProductDeptService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<AcitveProductInfoDTO> page(Map<String, Object> params) { |
|
|
|
IPage<AcitveProductInfoEntity> page = baseDao.selectPage( |
|
|
|
@ -102,8 +115,21 @@ public class AcitveProductInfoServiceImpl extends BaseServiceImpl<AcitveProductI |
|
|
|
AcitveProductInfoEntity entity = ConvertUtils.sourceToTarget(dto, AcitveProductInfoEntity.class); |
|
|
|
insert(entity); |
|
|
|
// 添加权限表数据
|
|
|
|
|
|
|
|
|
|
|
|
Result<List<Long>> result = adminFeignClient.getDeptInfoByDeptIdList(dto.getDeptId()); |
|
|
|
List<Long> deptIdList = result.getData(); |
|
|
|
|
|
|
|
List<AcitveProductDeptEntity> apdList = new ArrayList<AcitveProductDeptEntity>(); |
|
|
|
for(Long l : deptIdList){ |
|
|
|
if(l == null){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
AcitveProductDeptEntity acitveProductDeptEntity = new AcitveProductDeptEntity(); |
|
|
|
acitveProductDeptEntity.setDeptId(l.toString()); |
|
|
|
acitveProductDeptEntity.setProductId(entity.getId()); |
|
|
|
apdList.add(acitveProductDeptEntity); |
|
|
|
} |
|
|
|
// 插入权限表
|
|
|
|
acitveProductDeptService.insertBatch(apdList); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -113,7 +139,25 @@ public class AcitveProductInfoServiceImpl extends BaseServiceImpl<AcitveProductI |
|
|
|
public void update(AcitveProductInfoDTO dto) { |
|
|
|
AcitveProductInfoEntity entity = ConvertUtils.sourceToTarget(dto, AcitveProductInfoEntity.class); |
|
|
|
updateById(entity); |
|
|
|
// 逻辑删除权限表该商品数据
|
|
|
|
baseDao.deleteByProductId(dto.getId()); |
|
|
|
|
|
|
|
// 添加权限表数据
|
|
|
|
Result<List<Long>> result = adminFeignClient.getDeptInfoByDeptIdList(dto.getDeptId()); |
|
|
|
List<Long> deptIdList = result.getData(); |
|
|
|
|
|
|
|
List<AcitveProductDeptEntity> apdList = new ArrayList<AcitveProductDeptEntity>(); |
|
|
|
for(Long l : deptIdList){ |
|
|
|
if(l == null){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
AcitveProductDeptEntity acitveProductDeptEntity = new AcitveProductDeptEntity(); |
|
|
|
acitveProductDeptEntity.setDeptId(l.toString()); |
|
|
|
acitveProductDeptEntity.setProductId(entity.getId()); |
|
|
|
apdList.add(acitveProductDeptEntity); |
|
|
|
} |
|
|
|
// 插入权限表
|
|
|
|
acitveProductDeptService.insertBatch(apdList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -125,6 +169,9 @@ public class AcitveProductInfoServiceImpl extends BaseServiceImpl<AcitveProductI |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
|
|
|
|
// 逻辑删除权限表该商品数据(仅限于单条删除时使用)
|
|
|
|
baseDao.deleteByProductId(ids[0]); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|