1.接口优化,删除不必要的接口
Showing
8 changed files
with
42 additions
and
88 deletions
... | @@ -2,10 +2,8 @@ package com.topdraw.business.module.coupon.history.service; | ... | @@ -2,10 +2,8 @@ package com.topdraw.business.module.coupon.history.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; | 3 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; |
4 | import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO; | 4 | import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO; |
5 | import com.topdraw.business.module.coupon.service.dto.CouponDTO; | ||
6 | 5 | ||
7 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
8 | import java.util.List; | ||
9 | 7 | ||
10 | /** | 8 | /** |
11 | * @author XiangHan | 9 | * @author XiangHan |
... | @@ -29,18 +27,6 @@ public interface CouponHistoryService { | ... | @@ -29,18 +27,6 @@ public interface CouponHistoryService { |
29 | 27 | ||
30 | /** | 28 | /** |
31 | * | 29 | * |
32 | * @param resources | ||
33 | */ | ||
34 | void update(CouponHistory resources); | ||
35 | |||
36 | /** | ||
37 | * | ||
38 | * @param id | ||
39 | */ | ||
40 | void delete(Long id); | ||
41 | |||
42 | /** | ||
43 | * | ||
44 | * @param userId | 30 | * @param userId |
45 | * @return | 31 | * @return |
46 | */ | 32 | */ | ... | ... |
... | @@ -11,8 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired; | ... | @@ -11,8 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
12 | import org.springframework.transaction.annotation.Propagation; | 12 | import org.springframework.transaction.annotation.Propagation; |
13 | import org.springframework.transaction.annotation.Transactional; | 13 | import org.springframework.transaction.annotation.Transactional; |
14 | import org.springframework.dao.EmptyResultDataAccessException; | ||
15 | import org.springframework.util.Assert; | ||
16 | 14 | ||
17 | import java.time.LocalDateTime; | 15 | import java.time.LocalDateTime; |
18 | 16 | ||
... | @@ -45,24 +43,6 @@ public class CouponHistoryServiceImpl implements CouponHistoryService { | ... | @@ -45,24 +43,6 @@ public class CouponHistoryServiceImpl implements CouponHistoryService { |
45 | } | 43 | } |
46 | 44 | ||
47 | @Override | 45 | @Override |
48 | @Transactional(rollbackFor = Exception.class) | ||
49 | public void update(CouponHistory resources) { | ||
50 | CouponHistory couponHistory = this.couponHistoryRepository.findById(resources.getId()).orElseGet(CouponHistory::new); | ||
51 | ValidationUtil.isNull(couponHistory.getId(),"CouponHistory","id",resources.getId()); | ||
52 | couponHistory.copy(resources); | ||
53 | this.couponHistoryRepository.save(couponHistory); | ||
54 | } | ||
55 | |||
56 | @Override | ||
57 | @Transactional(rollbackFor = Exception.class) | ||
58 | public void delete(Long id) { | ||
59 | Assert.notNull(id, "The given id must not be null!"); | ||
60 | CouponHistory couponHistory = this.couponHistoryRepository.findById(id).orElseThrow( | ||
61 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", CouponHistory.class, id), 1)); | ||
62 | this.couponHistoryRepository.delete(couponHistory); | ||
63 | } | ||
64 | |||
65 | @Override | ||
66 | public Long countByUserId(Long userId) { | 46 | public Long countByUserId(Long userId) { |
67 | return this.couponHistoryRepository.countByUserId(userId); | 47 | return this.couponHistoryRepository.countByUserId(userId); |
68 | } | 48 | } | ... | ... |
... | @@ -16,6 +16,4 @@ public interface CouponRepository extends JpaRepository<Coupon, Long>, JpaSpecif | ... | @@ -16,6 +16,4 @@ public interface CouponRepository extends JpaRepository<Coupon, Long>, JpaSpecif |
16 | 16 | ||
17 | Optional<Coupon> findFirstByCode(String code); | 17 | Optional<Coupon> findFirstByCode(String code); |
18 | 18 | ||
19 | List<CouponDTO> findByUserId(Long userId); | ||
20 | |||
21 | } | 19 | } | ... | ... |
... | @@ -13,13 +13,6 @@ public interface CouponService { | ... | @@ -13,13 +13,6 @@ public interface CouponService { |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * 根据ID查询 | 15 | * 根据ID查询 |
16 | * @param userId ID | ||
17 | * @return CouponDTO | ||
18 | */ | ||
19 | List<CouponDTO> findByUserId(Long userId); | ||
20 | |||
21 | /** | ||
22 | * 根据ID查询 | ||
23 | * @param id ID | 16 | * @param id ID |
24 | * @return CouponDTO | 17 | * @return CouponDTO |
25 | */ | 18 | */ | ... | ... |
... | @@ -7,7 +7,6 @@ import com.topdraw.business.module.coupon.repository.CouponRepository; | ... | @@ -7,7 +7,6 @@ import com.topdraw.business.module.coupon.repository.CouponRepository; |
7 | import com.topdraw.business.module.coupon.service.CouponService; | 7 | import com.topdraw.business.module.coupon.service.CouponService; |
8 | import com.topdraw.business.module.coupon.service.dto.CouponDTO; | 8 | import com.topdraw.business.module.coupon.service.dto.CouponDTO; |
9 | import com.topdraw.business.module.coupon.service.mapper.CouponMapper; | 9 | import com.topdraw.business.module.coupon.service.mapper.CouponMapper; |
10 | import org.redisson.api.RedissonClient; | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
12 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
13 | import org.springframework.transaction.annotation.Propagation; | 12 | import org.springframework.transaction.annotation.Propagation; |
... | @@ -15,8 +14,6 @@ import org.springframework.transaction.annotation.Transactional; | ... | @@ -15,8 +14,6 @@ import org.springframework.transaction.annotation.Transactional; |
15 | import org.springframework.util.Assert; | 14 | import org.springframework.util.Assert; |
16 | import com.topdraw.utils.StringUtils; | 15 | import com.topdraw.utils.StringUtils; |
17 | 16 | ||
18 | import java.util.List; | ||
19 | |||
20 | 17 | ||
21 | /** | 18 | /** |
22 | * @author XiangHan | 19 | * @author XiangHan |
... | @@ -33,17 +30,12 @@ public class CouponServiceImpl implements CouponService { | ... | @@ -33,17 +30,12 @@ public class CouponServiceImpl implements CouponService { |
33 | private CouponRepository couponRepository; | 30 | private CouponRepository couponRepository; |
34 | 31 | ||
35 | @Override | 32 | @Override |
36 | public List<CouponDTO> findByUserId(Long userId) { | ||
37 | List<CouponDTO> couponDTOList = this.couponRepository.findByUserId(userId); | ||
38 | return couponDTOList; | ||
39 | } | ||
40 | |||
41 | @Override | ||
42 | public CouponDTO findById(Long id) { | 33 | public CouponDTO findById(Long id) { |
43 | Assert.notNull(id, GlobeExceptionMsg.COUPON_ID_IS_NULL); | 34 | Assert.notNull(id, GlobeExceptionMsg.COUPON_ID_IS_NULL); |
44 | Coupon Coupon = this.couponRepository.findById(id).orElseGet(Coupon::new); | 35 | |
45 | ValidationUtil.isNull(Coupon.getId(),"Coupon","id",id); | 36 | Coupon coupon = this.couponRepository.findById(id).orElseGet(Coupon::new); |
46 | return this.couponMapper.toDto(Coupon); | 37 | ValidationUtil.isNull(coupon.getId(),"Coupon","id",id); |
38 | return this.couponMapper.toDto(coupon); | ||
47 | } | 39 | } |
48 | 40 | ||
49 | @Override | 41 | @Override | ... | ... |
member-service-impl/src/test/java/com/topdraw/test/business/basicdata/coupon/CouponServiceTest.java
0 → 100644
1 | package com.topdraw.test.business.basicdata.coupon; | ||
2 | |||
3 | import com.topdraw.BaseTest; | ||
4 | import com.topdraw.business.module.coupon.history.service.CouponHistoryService; | ||
5 | import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO; | ||
6 | import com.topdraw.business.module.coupon.service.CouponService; | ||
7 | import com.topdraw.business.module.coupon.service.dto.CouponDTO; | ||
8 | import com.topdraw.business.module.member.rest.MemberController; | ||
9 | import com.topdraw.business.module.member.service.MemberService; | ||
10 | import org.junit.Test; | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | ||
12 | |||
13 | public class CouponServiceTest extends BaseTest { | ||
14 | |||
15 | @Autowired | ||
16 | private CouponService couponService; | ||
17 | @Autowired | ||
18 | private CouponHistoryService couponHistoryService; | ||
19 | |||
20 | @Test | ||
21 | public void findBy(){ | ||
22 | CouponDTO couponDTO = this.couponService.findById(1L); | ||
23 | System.out.println(couponDTO); | ||
24 | CouponDTO testvxv = this.couponService.getByCode("testvxv"); | ||
25 | System.out.println(testvxv); | ||
26 | |||
27 | CouponHistoryDTO couponHistoryDTO = this.couponHistoryService.findById(1l); | ||
28 | System.out.println(couponHistoryDTO); | ||
29 | } | ||
30 | |||
31 | @Test | ||
32 | public void findHistoryBy(){ | ||
33 | CouponHistoryDTO couponHistoryDTO = this.couponHistoryService.findById(130L); | ||
34 | System.out.println(couponHistoryDTO); | ||
35 | } | ||
36 | |||
37 | } |
1 | package com.topdraw.test.business.basicdata.rights.permanentrights; | 1 | package com.topdraw.test.business.basicdata.rights.permanentrights; |
2 | 2 | ||
3 | import com.topdraw.BaseTest; | 3 | import com.topdraw.BaseTest; |
4 | import com.topdraw.business.module.rights.permanentrights.rest.PermanentRightsController; | ||
5 | import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria; | ||
6 | import com.topdraw.common.ResultInfo; | ||
7 | import org.junit.Test; | 4 | import org.junit.Test; |
8 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.data.domain.PageRequest; | ||
10 | import org.springframework.data.domain.Pageable; | ||
11 | 5 | ||
12 | public class PermanentRightsControllerTest extends BaseTest { | 6 | public class PermanentRightsControllerTest extends BaseTest { |
13 | 7 | ||
14 | 8 | ||
15 | @Autowired | ||
16 | PermanentRightsController permanentRightsController; | ||
17 | |||
18 | @Test | ||
19 | public void pagePermanentRights(){ | ||
20 | PermanentRightsQueryCriteria criteria = new PermanentRightsQueryCriteria(); | ||
21 | criteria.setLevel(2); | ||
22 | Pageable pageable = PageRequest.of(0,20); | ||
23 | ResultInfo byId = this.permanentRightsController.pagePermanentRights(criteria,pageable); | ||
24 | LOG.info("===>>>"+byId); | ||
25 | } | ||
26 | |||
27 | @Test | 9 | @Test |
28 | public void findById(){ | 10 | public void findById(){ |
29 | ResultInfo byId = this.permanentRightsController.findById(1L); | 11 | |
30 | LOG.info("===>>>"+byId); | ||
31 | } | 12 | } |
32 | 13 | ||
33 | /*@Test | 14 | /*@Test | ... | ... |
1 | package com.topdraw.test.business.basicdata.rights.rest; | 1 | package com.topdraw.test.business.basicdata.rights.rest; |
2 | 2 | ||
3 | import com.topdraw.BaseTest; | 3 | import com.topdraw.BaseTest; |
4 | import com.topdraw.business.module.rights.rest.RightsController; | ||
5 | import com.topdraw.common.ResultInfo; | ||
6 | import org.junit.Test; | ||
7 | import org.springframework.beans.factory.annotation.Autowired; | ||
8 | 4 | ||
9 | public class RightsControllerTest extends BaseTest { | 5 | public class RightsControllerTest extends BaseTest { |
10 | 6 | ||
11 | 7 | ||
12 | @Autowired | ||
13 | RightsController rightsController; | ||
14 | |||
15 | @Test | ||
16 | public void findById(){ | ||
17 | ResultInfo byId = this.rightsController.findById(1L); | ||
18 | LOG.info("===>>>"+byId); | ||
19 | } | ||
20 | |||
21 | } | 8 | } | ... | ... |
-
Please register or sign in to post a comment