Commit 94e2d596 94e2d596aa41c41626ecddb9ec44ee0410d5cee9 by xianghan@topdraw.cn

1.接口优化,删除不必要的接口

1 parent 3c564750
......@@ -2,10 +2,8 @@ package com.topdraw.business.module.coupon.history.service;
import com.topdraw.business.module.coupon.history.domain.CouponHistory;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author XiangHan
......@@ -29,18 +27,6 @@ public interface CouponHistoryService {
/**
*
* @param resources
*/
void update(CouponHistory resources);
/**
*
* @param id
*/
void delete(Long id);
/**
*
* @param userId
* @return
*/
......
......@@ -11,8 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.util.Assert;
import java.time.LocalDateTime;
......@@ -45,24 +43,6 @@ public class CouponHistoryServiceImpl implements CouponHistoryService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CouponHistory resources) {
CouponHistory couponHistory = this.couponHistoryRepository.findById(resources.getId()).orElseGet(CouponHistory::new);
ValidationUtil.isNull(couponHistory.getId(),"CouponHistory","id",resources.getId());
couponHistory.copy(resources);
this.couponHistoryRepository.save(couponHistory);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
CouponHistory couponHistory = this.couponHistoryRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", CouponHistory.class, id), 1));
this.couponHistoryRepository.delete(couponHistory);
}
@Override
public Long countByUserId(Long userId) {
return this.couponHistoryRepository.countByUserId(userId);
}
......
......@@ -16,6 +16,4 @@ public interface CouponRepository extends JpaRepository<Coupon, Long>, JpaSpecif
Optional<Coupon> findFirstByCode(String code);
List<CouponDTO> findByUserId(Long userId);
}
......
......@@ -13,13 +13,6 @@ public interface CouponService {
/**
* 根据ID查询
* @param userId ID
* @return CouponDTO
*/
List<CouponDTO> findByUserId(Long userId);
/**
* 根据ID查询
* @param id ID
* @return CouponDTO
*/
......
......@@ -7,7 +7,6 @@ import com.topdraw.business.module.coupon.repository.CouponRepository;
import com.topdraw.business.module.coupon.service.CouponService;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import com.topdraw.business.module.coupon.service.mapper.CouponMapper;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -15,8 +14,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import com.topdraw.utils.StringUtils;
import java.util.List;
/**
* @author XiangHan
......@@ -33,17 +30,12 @@ public class CouponServiceImpl implements CouponService {
private CouponRepository couponRepository;
@Override
public List<CouponDTO> findByUserId(Long userId) {
List<CouponDTO> couponDTOList = this.couponRepository.findByUserId(userId);
return couponDTOList;
}
@Override
public CouponDTO findById(Long id) {
Assert.notNull(id, GlobeExceptionMsg.COUPON_ID_IS_NULL);
Coupon Coupon = this.couponRepository.findById(id).orElseGet(Coupon::new);
ValidationUtil.isNull(Coupon.getId(),"Coupon","id",id);
return this.couponMapper.toDto(Coupon);
Coupon coupon = this.couponRepository.findById(id).orElseGet(Coupon::new);
ValidationUtil.isNull(coupon.getId(),"Coupon","id",id);
return this.couponMapper.toDto(coupon);
}
@Override
......
package com.topdraw.test.business.basicdata.coupon;
import com.topdraw.BaseTest;
import com.topdraw.business.module.coupon.history.service.CouponHistoryService;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO;
import com.topdraw.business.module.coupon.service.CouponService;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import com.topdraw.business.module.member.rest.MemberController;
import com.topdraw.business.module.member.service.MemberService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class CouponServiceTest extends BaseTest {
@Autowired
private CouponService couponService;
@Autowired
private CouponHistoryService couponHistoryService;
@Test
public void findBy(){
CouponDTO couponDTO = this.couponService.findById(1L);
System.out.println(couponDTO);
CouponDTO testvxv = this.couponService.getByCode("testvxv");
System.out.println(testvxv);
CouponHistoryDTO couponHistoryDTO = this.couponHistoryService.findById(1l);
System.out.println(couponHistoryDTO);
}
@Test
public void findHistoryBy(){
CouponHistoryDTO couponHistoryDTO = this.couponHistoryService.findById(130L);
System.out.println(couponHistoryDTO);
}
}
package com.topdraw.test.business.basicdata.rights.permanentrights;
import com.topdraw.BaseTest;
import com.topdraw.business.module.rights.permanentrights.rest.PermanentRightsController;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
import com.topdraw.common.ResultInfo;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
public class PermanentRightsControllerTest extends BaseTest {
@Autowired
PermanentRightsController permanentRightsController;
@Test
public void pagePermanentRights(){
PermanentRightsQueryCriteria criteria = new PermanentRightsQueryCriteria();
criteria.setLevel(2);
Pageable pageable = PageRequest.of(0,20);
ResultInfo byId = this.permanentRightsController.pagePermanentRights(criteria,pageable);
LOG.info("===>>>"+byId);
}
@Test
public void findById(){
ResultInfo byId = this.permanentRightsController.findById(1L);
LOG.info("===>>>"+byId);
}
/*@Test
......
package com.topdraw.test.business.basicdata.rights.rest;
import com.topdraw.BaseTest;
import com.topdraw.business.module.rights.rest.RightsController;
import com.topdraw.common.ResultInfo;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class RightsControllerTest extends BaseTest {
@Autowired
RightsController rightsController;
@Test
public void findById(){
ResultInfo byId = this.rightsController.findById(1L);
LOG.info("===>>>"+byId);
}
}
......