| | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringPool; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xcong.farmer.cms.common.response.Result; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminAddColumnDto; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminColumnDto; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminUpdateColumnDto; |
| | | import com.xcong.farmer.cms.modules.system.entity.ColumnEntity; |
| | | import com.xcong.farmer.cms.modules.system.entity.NavigationBarEntity; |
| | | import com.xcong.farmer.cms.modules.system.entity.UserEntity; |
| | | import com.xcong.farmer.cms.modules.system.mapper.ColumnMapper; |
| | | import com.xcong.farmer.cms.modules.system.service.IColumnService; |
| | | import com.xcong.farmer.cms.modules.system.util.LoginUserUtil; |
| | | import com.xcong.farmer.cms.modules.system.vo.AdminColumnVo; |
| | | import com.xcong.farmer.cms.modules.system.vo.AdminSeeColumnInfoVo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | public class ColumnServiceImpl extends ServiceImpl<ColumnMapper, ColumnEntity> implements IColumnService { |
| | | @Override |
| | | public Result getColumnInPage(AdminColumnDto adminColumnDto) { |
| | | UserEntity userlogin = LoginUserUtil.getLoginUser(); |
| | | long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); |
| | | Page<AdminColumnVo> page = new Page<>(adminColumnDto.getPageNum(), adminColumnDto.getPageSize()); |
| | | ColumnEntity columnEntity = new ColumnEntity(); |
| | | columnEntity.setBelongId(belongId); |
| | | columnEntity.setParentId(ColumnEntity.PARENTID_DEFAULT); |
| | | IPage<AdminColumnVo> list = this.baseMapper.selectAdminColumnVoInPage(page,columnEntity); |
| | | List<AdminColumnVo> records = list.getRecords(); |
| | |
| | | Long id = adminColumnVo.getId(); |
| | | QueryWrapper<ColumnEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("parent_id",id); |
| | | objectQueryWrapper.eq("belong_id",belongId); |
| | | List<ColumnEntity> columnEntities = this.baseMapper.selectList(objectQueryWrapper); |
| | | List<AdminColumnVo> adminColumnVoChilds = new ArrayList<>(); |
| | | if(CollUtil.isNotEmpty(columnEntities)){ |
| | |
| | | child.setId(columnEntityChild.getId()); |
| | | child.setColumnName(columnEntityChild.getColumnName()); |
| | | child.setColumnCode(columnEntityChild.getColumnCode()); |
| | | child.setDescribe(columnEntityChild.getDescribe()); |
| | | child.setRemark(columnEntityChild.getRemark()); |
| | | child.setPic(columnEntityChild.getPic()); |
| | | child.setOrderNum(columnEntityChild.getOrderNum()); |
| | | adminColumnVoChilds.add(child); |
| | |
| | | @Override |
| | | @Transactional |
| | | public Result addColumn(AdminAddColumnDto adminAddColumnDto) { |
| | | UserEntity userlogin = LoginUserUtil.getLoginUser(); |
| | | long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); |
| | | ColumnEntity columnEntity = new ColumnEntity(); |
| | | columnEntity.setBelongId(belongId); |
| | | String columnName = adminAddColumnDto.getColumnName(); |
| | | if(StrUtil.isEmpty(columnName)){ |
| | | return Result.fail("请输入栏目名称"); |
| | |
| | | return Result.fail("栏目编码不能重复"); |
| | | } |
| | | columnEntity.setColumnCode(columnCode); |
| | | String describe = adminAddColumnDto.getDescribe(); |
| | | if(StrUtil.isNotEmpty(describe)){ |
| | | columnEntity.setDescribe(describe); |
| | | String remark = adminAddColumnDto.getRemark(); |
| | | if(StrUtil.isNotEmpty(remark)){ |
| | | columnEntity.setRemark(remark); |
| | | } |
| | | String pic = adminAddColumnDto.getPic(); |
| | | if(StrUtil.isNotEmpty(pic)){ |
| | |
| | | adminSeeColumnInfoVo.setId(columnEntity.getId()); |
| | | adminSeeColumnInfoVo.setColumnName(columnEntity.getColumnName()); |
| | | adminSeeColumnInfoVo.setColumnCode(columnEntity.getColumnCode()); |
| | | adminSeeColumnInfoVo.setDescribe(columnEntity.getDescribe()); |
| | | adminSeeColumnInfoVo.setRemark(columnEntity.getRemark()); |
| | | adminSeeColumnInfoVo.setParentId(columnEntity.getParentId()); |
| | | adminSeeColumnInfoVo.setOrderNum(columnEntity.getOrderNum()); |
| | | adminSeeColumnInfoVo.setPic(columnEntity.getPic()); |
| | |
| | | QueryWrapper<ColumnEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("column_code",columnCode); |
| | | List<ColumnEntity> columnEntities = this.baseMapper.selectList(objectQueryWrapper); |
| | | if(CollUtil.isNotEmpty(columnEntities)){ |
| | | if(CollUtil.isNotEmpty(columnEntities) && columnEntities.size() > 1){ |
| | | return Result.fail("栏目编码不能重复"); |
| | | } |
| | | columnEntity.setColumnCode(columnCode); |
| | | String describe = adminUpdateColumnDto.getDescribe(); |
| | | if(StrUtil.isNotEmpty(describe)){ |
| | | columnEntity.setDescribe(describe); |
| | | String remark = adminUpdateColumnDto.getRemark(); |
| | | if(StrUtil.isNotEmpty(remark)){ |
| | | columnEntity.setRemark(remark); |
| | | } |
| | | String pic = adminUpdateColumnDto.getPic(); |
| | | if(StrUtil.isNotEmpty(pic)){ |
| | |
| | | |
| | | @Override |
| | | public Result getColumnInList() { |
| | | List<AdminColumnVo> records = this.baseMapper.selectColumnInListByParentId(ColumnEntity.PARENTID_DEFAULT); |
| | | UserEntity userlogin = LoginUserUtil.getLoginUser(); |
| | | long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); |
| | | List<AdminColumnVo> records = this.baseMapper.selectColumnInListByParentId(ColumnEntity.PARENTID_DEFAULT,belongId); |
| | | if(CollUtil.isNotEmpty(records)){ |
| | | for(AdminColumnVo adminColumnVo : records){ |
| | | Long id = adminColumnVo.getId(); |
| | | QueryWrapper<ColumnEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("parent_id",id); |
| | | objectQueryWrapper.eq("belong_id",belongId); |
| | | List<ColumnEntity> columnEntities = this.baseMapper.selectList(objectQueryWrapper); |
| | | List<AdminColumnVo> adminColumnVoChilds = new ArrayList<>(); |
| | | if(CollUtil.isNotEmpty(columnEntities)){ |
| | |
| | | child.setId(columnEntityChild.getId()); |
| | | child.setColumnName(columnEntityChild.getColumnName()); |
| | | child.setColumnCode(columnEntityChild.getColumnCode()); |
| | | child.setDescribe(columnEntityChild.getDescribe()); |
| | | child.setRemark(columnEntityChild.getRemark()); |
| | | child.setPic(columnEntityChild.getPic()); |
| | | child.setOrderNum(columnEntityChild.getOrderNum()); |
| | | adminColumnVoChilds.add(child); |
| | |
| | | } |
| | | return Result.ok(records); |
| | | } |
| | | |
| | | @Override |
| | | public Result delObjs(AdminDeleteDto adminDeleteDto) { |
| | | String ids = adminDeleteDto.getIds(); |
| | | if(StrUtil.isNotEmpty(ids)){ |
| | | String[] columnIds = ids.split(StringPool.COMMA); |
| | | for(String columnIdStr : columnIds){ |
| | | Long columnId = Long.valueOf(columnIdStr); |
| | | QueryWrapper<ColumnEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("parent_id",columnId); |
| | | this.baseMapper.delete(objectQueryWrapper); |
| | | |
| | | this.baseMapper.deleteById(columnId); |
| | | } |
| | | } |
| | | return Result.ok("删除成功"); |
| | | } |
| | | } |