|
|
@ -1,5 +1,6 @@
|
|
|
|
package com.xit.biz.ctgy.service.impl;
|
|
|
|
package com.xit.biz.ctgy.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.google.common.base.Objects;
|
|
|
|
import com.xit.biz.ctgy.dto.BoardDto;
|
|
|
|
import com.xit.biz.ctgy.dto.BoardDto;
|
|
|
|
import com.xit.biz.ctgy.dto.struct.MinCivBoard680Mapstruct;
|
|
|
|
import com.xit.biz.ctgy.dto.struct.MinCivBoard680Mapstruct;
|
|
|
|
import com.xit.biz.ctgy.entity.MinCivBoard680;
|
|
|
|
import com.xit.biz.ctgy.entity.MinCivBoard680;
|
|
|
@ -7,6 +8,7 @@ import com.xit.biz.ctgy.repository.IBoardRepository;
|
|
|
|
import com.xit.biz.ctgy.service.IBoardService;
|
|
|
|
import com.xit.biz.ctgy.service.IBoardService;
|
|
|
|
import com.xit.core.constant.ErrorCode;
|
|
|
|
import com.xit.core.constant.ErrorCode;
|
|
|
|
import com.xit.core.exception.CustomBaseException;
|
|
|
|
import com.xit.core.exception.CustomBaseException;
|
|
|
|
|
|
|
|
import com.xit.core.oauth2.utils.HeaderUtil;
|
|
|
|
import com.xit.core.support.jpa.JpaUtil;
|
|
|
|
import com.xit.core.support.jpa.JpaUtil;
|
|
|
|
import com.xit.core.util.Checks;
|
|
|
|
import com.xit.core.util.Checks;
|
|
|
|
import com.xit.core.util.CommUtil;
|
|
|
|
import com.xit.core.util.CommUtil;
|
|
|
@ -20,6 +22,8 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
|
|
|
|
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
@ -79,4 +83,17 @@ public class BoardService implements IBoardService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
repository.save(entity);
|
|
|
|
repository.save(entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
|
|
|
public void removeBoard(Long ciCode) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MinCivBoard680 savedEntity = repository.findById(ciCode).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND));
|
|
|
|
|
|
|
|
if(!Objects.equal(HeaderUtil.getUserId(), savedEntity.getCiId())) throw new CustomBaseException("삭제 권한(게시글 소유자)이 없는 사용자 입니다");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 댓글 존재 여부 조회
|
|
|
|
|
|
|
|
List<MinCivBoard680> list = repository.findByCiRef(ciCode);
|
|
|
|
|
|
|
|
if(list.size() > 1) throw new CustomBaseException("삭제 할 수 없는 게시글 입니다[댓글 존재]");
|
|
|
|
|
|
|
|
repository.deleteById(ciCode);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|