| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.vos.BcDictionaryItemVO; |
| | | import com.panzhihua.common.model.vos.BcDictionaryVO; |
| | | import com.panzhihua.common.model.vos.DictionaryVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.utlis.CopyUtil; |
| | | import com.panzhihua.service_community.dao.BcDictionaryDAO; |
| | | import com.panzhihua.service_community.dao.BcDictionaryItemDAO; |
| | | 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; |
| | | |
| | | /** |
| | |
| | | @Service |
| | | public class BcDictionaryServiceImpl extends ServiceImpl<BcDictionaryItemDAO, BcDictionaryItemDO> implements BcDictionaryService { |
| | | |
| | | |
| | | @Resource |
| | | private BcDictionaryDAO dictionaryDAO; |
| | | |
| | | @Override |
| | | public R<List<BcDictionaryVO>> getDictionaryByKey(String key) { |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @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) |
| | | ); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R insertDiction(DictionaryVO dictionaryVO) { |
| | | if (getDictionaryByCode(dictionaryVO.getDictName(), dictionaryVO.getDictKey(), dictionaryVO.getParentId()) != null) { |
| | | return R.fail("数据已经存在!"); |
| | | } |
| | | BcDictionaryDO dictionaryDO = new BcDictionaryDO(); |
| | | dictionaryDO.setId(dictionaryVO.getId()); |
| | | dictionaryDO.setDictName(dictionaryVO.getDictName()); |
| | | dictionaryDO.setDictKey(dictionaryVO.getDictKey()); |
| | | dictionaryDO.setParentId(dictionaryVO.getParentId()); |
| | | dictionaryDO.setPathId(dictionaryVO.getParentId().toString().concat(",").concat(dictionaryVO.getId().toString())); |
| | | dictionaryDO.setLevelIndex(dictionaryVO.getLevelIndex()); |
| | | dictionaryDO.setEnabled(true); |
| | | dictionaryDO.setSort(0); |
| | | dictionaryDO.setRemarks(""); |
| | | dictionaryDO.setDeleteFlag(false); |
| | | dictionaryDO.setCreateUser(1L); |
| | | dictionaryDO.setModifyUser(1L); |
| | | int flag = dictionaryDAO.insert(dictionaryDO); |
| | | return flag > 1 ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R insertDictionItem(BcDictionaryVO dictionaryVO) { |
| | | if (getByCode(dictionaryVO.getDictId().toString(), dictionaryVO.getDictValue()) != null) { |
| | | return R.fail("数据已经存在!"); |
| | | } |
| | | BcDictionaryItemDO dictionaryItemDO = new BcDictionaryItemDO(); |
| | | dictionaryItemDO.setDictItemName(dictionaryVO.getDictName()); |
| | | dictionaryItemDO.setDictValue(dictionaryVO.getDictValue()); |
| | | dictionaryItemDO.setMnemonicCode(dictionaryVO.getCode()); |
| | | dictionaryItemDO.setDictId(dictionaryVO.getDictId()); |
| | | dictionaryItemDO.setEnabled(true); |
| | | dictionaryItemDO.setOrgPathId(0L); |
| | | dictionaryItemDO.setSort(0); |
| | | dictionaryItemDO.setRemarks(""); |
| | | dictionaryItemDO.setCreateUser(1L); |
| | | dictionaryItemDO.setCreateDate(new Date()); |
| | | dictionaryItemDO.setModifyUser(1L); |
| | | dictionaryItemDO.setModifyDate(new Date()); |
| | | dictionaryItemDO.setDeleteFlag(false); |
| | | int flag = baseMapper.insert(dictionaryItemDO); |
| | | return flag > 1 ? R.ok() : R.fail(); |
| | | } |
| | | } |