1.优化
Showing
3 changed files
with
11 additions
and
169 deletions
| 1 | package com.topdraw.business.process.service.impl.user; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | ||
| 4 | import com.topdraw.business.module.user.weixin.domain.UserWeixinBuilder; | ||
| 5 | import com.topdraw.business.module.user.weixin.repository.UserWeixinRepository; | ||
| 6 | import com.topdraw.business.module.user.weixin.service.UserWeixinService; | ||
| 7 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | ||
| 8 | import com.topdraw.business.module.user.weixin.service.mapper.UserWeixinMapper; | ||
| 9 | import com.topdraw.business.process.service.user.UserWeixinOperationService; | ||
| 10 | import com.topdraw.utils.ValidationUtil; | ||
| 11 | import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | import org.springframework.dao.EmptyResultDataAccessException; | ||
| 13 | import org.springframework.stereotype.Service; | ||
| 14 | import org.springframework.transaction.annotation.Propagation; | ||
| 15 | import org.springframework.transaction.annotation.Transactional; | ||
| 16 | import org.springframework.util.Assert; | ||
| 17 | |||
| 18 | /** | ||
| 19 | * @author XiangHan | ||
| 20 | * @date 2021-12-16 | ||
| 21 | */ | ||
| 22 | @Service | ||
| 23 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
| 24 | public class UserWeixinOperationServiceImpl implements UserWeixinOperationService { | ||
| 25 | |||
| 26 | @Autowired | ||
| 27 | private UserWeixinService userWeixinService; | ||
| 28 | |||
| 29 | @Override | ||
| 30 | public UserWeixinDTO findById(Long id) { | ||
| 31 | return this.userWeixinService.findById(id); | ||
| 32 | } | ||
| 33 | |||
| 34 | @Override | ||
| 35 | @Transactional(rollbackFor = Exception.class) | ||
| 36 | public UserWeixin create(UserWeixin resources) { | ||
| 37 | return this.userWeixinService.create(resources); | ||
| 38 | } | ||
| 39 | |||
| 40 | @Override | ||
| 41 | @Transactional(rollbackFor = Exception.class) | ||
| 42 | public void update(UserWeixin resources) { | ||
| 43 | this.userWeixinService.update(resources); | ||
| 44 | } | ||
| 45 | |||
| 46 | @Override | ||
| 47 | public void updateTime(UserWeixin resources) { | ||
| 48 | this.userWeixinService.updateTime(resources); | ||
| 49 | } | ||
| 50 | |||
| 51 | @Override | ||
| 52 | @Transactional(rollbackFor = Exception.class) | ||
| 53 | public void delete(Long id) { | ||
| 54 | this.userWeixinService.delete(id); | ||
| 55 | } | ||
| 56 | |||
| 57 | @Override | ||
| 58 | public UserWeixinDTO findFirstByMemberIdAndAppid(Long memberId, String appid) { | ||
| 59 | return this.userWeixinService.findFirstByMemberIdAndAppid(memberId,appid); | ||
| 60 | } | ||
| 61 | |||
| 62 | @Override | ||
| 63 | public UserWeixinDTO findFirstByUnionIdAndAppIdAndOpenId(String unionId, String appId, String openId) { | ||
| 64 | return this.userWeixinService.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId,openId); | ||
| 65 | } | ||
| 66 | |||
| 67 | @Override | ||
| 68 | public UserWeixinDTO findFirstByAppIdAndOpenId(String appId, String openId) { | ||
| 69 | return this.userWeixinService.findFirstByAppIdAndOpenId(appId,openId); | ||
| 70 | } | ||
| 71 | |||
| 72 | @Override | ||
| 73 | public UserWeixinDTO findFirstByUnionId(String unionid) { | ||
| 74 | return this.userWeixinService.findFirstByUnionId(unionid); | ||
| 75 | } | ||
| 76 | |||
| 77 | @Override | ||
| 78 | public UserWeixinDTO findFirstByUnionidAndAppid(String unionid, String appId) { | ||
| 79 | return this.userWeixinService.findFirstByUnionidAndAppid(unionid,appId); | ||
| 80 | } | ||
| 81 | |||
| 82 | } |
| 1 | package com.topdraw.business.process.service.user; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | ||
| 4 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | ||
| 5 | |||
| 6 | /** | ||
| 7 | * @author XiangHan | ||
| 8 | * @date 2021-12-16 | ||
| 9 | */ | ||
| 10 | public interface UserWeixinOperationService { | ||
| 11 | |||
| 12 | /** | ||
| 13 | * 根据ID查询 | ||
| 14 | * @param id ID | ||
| 15 | * @return UserWeixinDTO | ||
| 16 | */ | ||
| 17 | UserWeixinDTO findById(Long id); | ||
| 18 | |||
| 19 | /** | ||
| 20 | * | ||
| 21 | * @param resources | ||
| 22 | * @return | ||
| 23 | */ | ||
| 24 | UserWeixin create(UserWeixin resources); | ||
| 25 | |||
| 26 | /** | ||
| 27 | * | ||
| 28 | * @param resources | ||
| 29 | */ | ||
| 30 | void update(UserWeixin resources); | ||
| 31 | |||
| 32 | /** | ||
| 33 | * | ||
| 34 | * @param resources | ||
| 35 | */ | ||
| 36 | void updateTime(UserWeixin resources); | ||
| 37 | |||
| 38 | /** | ||
| 39 | * | ||
| 40 | * @param id | ||
| 41 | */ | ||
| 42 | void delete(Long id); | ||
| 43 | |||
| 44 | /** | ||
| 45 | * | ||
| 46 | * @param memberId | ||
| 47 | * @param appid | ||
| 48 | * @return | ||
| 49 | */ | ||
| 50 | UserWeixinDTO findFirstByMemberIdAndAppid(Long memberId, String appid); | ||
| 51 | |||
| 52 | /** | ||
| 53 | * | ||
| 54 | * @param unionId | ||
| 55 | * @param appId | ||
| 56 | * @param openId | ||
| 57 | * @return | ||
| 58 | */ | ||
| 59 | UserWeixinDTO findFirstByUnionIdAndAppIdAndOpenId(String unionId, String appId, String openId); | ||
| 60 | |||
| 61 | /** | ||
| 62 | * | ||
| 63 | * @param appId | ||
| 64 | * @param openId | ||
| 65 | * @return | ||
| 66 | */ | ||
| 67 | UserWeixinDTO findFirstByAppIdAndOpenId(String appId, String openId); | ||
| 68 | |||
| 69 | /** | ||
| 70 | * | ||
| 71 | * @param unionid | ||
| 72 | * @return | ||
| 73 | */ | ||
| 74 | UserWeixinDTO findFirstByUnionId(String unionid); | ||
| 75 | |||
| 76 | /** | ||
| 77 | * | ||
| 78 | * @param unionid | ||
| 79 | * @param appId | ||
| 80 | * @return | ||
| 81 | */ | ||
| 82 | UserWeixinDTO findFirstByUnionidAndAppid(String unionid, String appId); | ||
| 83 | } |
| 1 | package com.topdraw.test.business.process.rest; | 1 | package com.topdraw.test.business.process.rest; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | import com.alibaba.fastjson.JSONObject; | ||
| 4 | import com.topdraw.BaseTest; | 5 | import com.topdraw.BaseTest; |
| 5 | import com.topdraw.business.process.domian.TempCoupon; | 6 | import com.topdraw.business.process.domian.TempCoupon; |
| 6 | import com.topdraw.business.process.rest.CouponOperationController; | 7 | import com.topdraw.business.process.rest.CouponOperationController; |
| ... | @@ -12,6 +13,7 @@ import java.sql.Timestamp; | ... | @@ -12,6 +13,7 @@ import java.sql.Timestamp; |
| 12 | import java.time.LocalDateTime; | 13 | import java.time.LocalDateTime; |
| 13 | import java.util.ArrayList; | 14 | import java.util.ArrayList; |
| 14 | import java.util.List; | 15 | import java.util.List; |
| 16 | import java.util.Map; | ||
| 15 | 17 | ||
| 16 | public class CouponOperationControllerTest extends BaseTest { | 18 | public class CouponOperationControllerTest extends BaseTest { |
| 17 | 19 | ||
| ... | @@ -20,7 +22,7 @@ public class CouponOperationControllerTest extends BaseTest { | ... | @@ -20,7 +22,7 @@ public class CouponOperationControllerTest extends BaseTest { |
| 20 | 22 | ||
| 21 | @Test | 23 | @Test |
| 22 | public void grantCouponByManual(){ | 24 | public void grantCouponByManual(){ |
| 23 | Long memberId = 2L; | 25 | /*Long memberId = 2L; |
| 24 | Long userId = 2L; | 26 | Long userId = 2L; |
| 25 | TempCoupon tempCoupon = new TempCoupon(); | 27 | TempCoupon tempCoupon = new TempCoupon(); |
| 26 | tempCoupon.setId(1L); | 28 | tempCoupon.setId(1L); |
| ... | @@ -44,12 +46,17 @@ public class CouponOperationControllerTest extends BaseTest { | ... | @@ -44,12 +46,17 @@ public class CouponOperationControllerTest extends BaseTest { |
| 44 | List<TempCoupon> tempCouponList = new ArrayList<>(); | 46 | List<TempCoupon> tempCouponList = new ArrayList<>(); |
| 45 | tempCouponList.add(tempCoupon); | 47 | tempCouponList.add(tempCoupon); |
| 46 | 48 | ||
| 47 | String s = JSON.toJSONString(tempCouponList); | 49 | String s = JSON.toJSONString(tempCouponList);*/ |
| 48 | // tempCouponList.add(tempCoupon1); | 50 | // tempCouponList.add(tempCoupon1); |
| 49 | ResultInfo byId = this.couponOperationController.grantCouponByManual(tempCouponList); | 51 | |
| 50 | LOG.info("===>>>"+byId); | 52 | String a = "{\"IPTVappid\":\"kids3\",\"platformAccount\":\"topdraw\",\"dyAppid\":\"wx5d88c7fe99f89f32\",\"unionid\":\"oqDha5lxMuXYMGgT6gyLIFL7VumM\",\"nickname\":\"%E5%90%89%E8%B4%9D\",\"headimgurl\":\"https%3A%2F%2Fthirdwx.qlogo.cn%2Fmmopen%2Fvi_32%2FDYAIOgq83erGuDK9HlicY2iasIB5VHXTNWtuqfIZxIpzicQKWg9ogSRKRO1DeYtWicDHMMibpibHOEZRfp1Fvd4EQgrg%2F132\"}"; |
| 53 | Map parse = JSONObject.parseObject(a, Map.class); | ||
| 54 | // ResultInfo byId = this.couponOperationController.grantCouponByManual(tempCouponList); | ||
| 55 | LOG.info("===>>>"+parse); | ||
| 51 | } | 56 | } |
| 52 | 57 | ||
| 53 | 58 | ||
| 54 | 59 | ||
| 60 | |||
| 61 | |||
| 55 | } | 62 | } | ... | ... |
-
Please register or sign in to post a comment