| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.vos.BcDictionaryItemVO; |
| | |
| | | import com.panzhihua.service_community.model.dos.BcDictionaryDO; |
| | | import com.panzhihua.service_community.model.dos.BcDictionaryItemDO; |
| | | import com.panzhihua.service_community.service.BcDictionaryService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author xyh |
| | | * @date 2021/6/11 16:06 |
| | | */ |
| | | @Service |
| | | public class BcDictionaryServiceImpl extends ServiceImpl<BcDictionaryItemDAO, BcDictionaryItemDO> implements BcDictionaryService { |
| | | |
| | | public class BcDictionaryServiceImpl extends ServiceImpl<BcDictionaryItemDAO, BcDictionaryItemDO> |
| | | implements BcDictionaryService { |
| | | |
| | | @Resource |
| | | private BcDictionaryDAO dictionaryDAO; |
| | |
| | | |
| | | @Override |
| | | public BcDictionaryItemVO getByCode(String dictId, String code) { |
| | | BcDictionaryItemDO dictionaryItemDO = baseMapper.selectOne( |
| | | new QueryWrapper<BcDictionaryItemDO>() |
| | | .eq("dict_id", dictId) |
| | | .eq("dict_value", code) |
| | | ); |
| | | BcDictionaryItemDO dictionaryItemDO = |
| | | baseMapper.selectOne(new QueryWrapper<BcDictionaryItemDO>().eq("dict_id", dictId).eq("dict_value", code)); |
| | | if (dictionaryItemDO != null) { |
| | | return CopyUtil.copyProperties(dictionaryItemDO, BcDictionaryItemVO.class); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public BcDictionaryDO getDictionaryByCode(String dictName, String dictKey, Long parentId) { |
| | | return dictionaryDAO.selectOne( |
| | | new QueryWrapper<BcDictionaryDO>() |
| | | .eq("dict_name", dictName) |
| | | .eq("dict_key", dictKey) |
| | | .eq("parent_id", parentId) |
| | | ); |
| | | return dictionaryDAO.selectOne(new QueryWrapper<BcDictionaryDO>().eq("dict_name", dictName) |
| | | .eq("dict_key", dictKey).eq("parent_id", parentId)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R insertDiction(DictionaryVO dictionaryVO) { |
| | | if (getDictionaryByCode(dictionaryVO.getDictName(), dictionaryVO.getDictKey(), dictionaryVO.getParentId()) != null) { |
| | | if (getDictionaryByCode(dictionaryVO.getDictName(), dictionaryVO.getDictKey(), |
| | | dictionaryVO.getParentId()) != null) { |
| | | return R.fail("数据已经存在!"); |
| | | } |
| | | BcDictionaryDO dictionaryDO = new BcDictionaryDO(); |
| | |
| | | dictionaryDO.setDictName(dictionaryVO.getDictName()); |
| | | dictionaryDO.setDictKey(dictionaryVO.getDictKey()); |
| | | dictionaryDO.setParentId(dictionaryVO.getParentId()); |
| | | dictionaryDO.setPathId(dictionaryVO.getParentId().toString().concat(",").concat(dictionaryVO.getId().toString())); |
| | | dictionaryDO |
| | | .setPathId(dictionaryVO.getParentId().toString().concat(",").concat(dictionaryVO.getId().toString())); |
| | | dictionaryDO.setLevelIndex(dictionaryVO.getLevelIndex()); |
| | | dictionaryDO.setEnabled(true); |
| | | dictionaryDO.setSort(0); |