1.添加中奖人联系方式接口
Showing
9 changed files
with
370 additions
and
4 deletions
1 | package com.topdraw.business.module.contact.vis.domain; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import lombok.experimental.Accessors; | ||
5 | import cn.hutool.core.bean.BeanUtil; | ||
6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
7 | import javax.persistence.*; | ||
8 | import org.springframework.data.annotation.CreatedDate; | ||
9 | import org.springframework.data.annotation.LastModifiedDate; | ||
10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
11 | import java.sql.Timestamp; | ||
12 | |||
13 | import java.io.Serializable; | ||
14 | |||
15 | /** | ||
16 | * @author XiangHan | ||
17 | * @date 2022-04-24 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="x_activity_address") | ||
24 | public class ActivityAddress implements Serializable { | ||
25 | |||
26 | // id | ||
27 | @Id | ||
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
29 | @Column(name = "id") | ||
30 | private Long id; | ||
31 | |||
32 | // vis的用户id | ||
33 | @Column(name = "user_id", nullable = false) | ||
34 | private Long userId; | ||
35 | |||
36 | // 大屏账号 | ||
37 | @Column(name = "platform_account") | ||
38 | private String platformAccount; | ||
39 | |||
40 | // 活动id | ||
41 | @Column(name = "activity_id", nullable = false) | ||
42 | private Long activityId; | ||
43 | |||
44 | // 应用id | ||
45 | @Column(name = "app_id") | ||
46 | private Long appId; | ||
47 | |||
48 | // 收货人名称 | ||
49 | @Column(name = "name") | ||
50 | private String name; | ||
51 | |||
52 | // 收货人地址 | ||
53 | @Column(name = "address") | ||
54 | private String address; | ||
55 | |||
56 | // 收获人手机号 | ||
57 | @Column(name = "cellphone") | ||
58 | private String cellphone; | ||
59 | |||
60 | // 创建时间 | ||
61 | @CreatedDate | ||
62 | @Column(name = "create_time") | ||
63 | private Timestamp createTime; | ||
64 | |||
65 | // 更新时间 | ||
66 | @LastModifiedDate | ||
67 | @Column(name = "update_time") | ||
68 | private Timestamp updateTime; | ||
69 | |||
70 | public void copy(ActivityAddress source){ | ||
71 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
72 | } | ||
73 | } |
1 | package com.topdraw.business.module.contact.vis.repository; | ||
2 | |||
3 | import com.topdraw.business.module.contact.vis.domain.ActivityAddress; | ||
4 | import org.springframework.data.jpa.repository.JpaRepository; | ||
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
6 | |||
7 | import java.util.Optional; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2022-04-24 | ||
12 | */ | ||
13 | public interface ActivityAddressRepository extends JpaRepository<ActivityAddress, Long>, JpaSpecificationExecutor<ActivityAddress> { | ||
14 | |||
15 | Optional<ActivityAddress> findByPlatformAccount(String platformAccount); | ||
16 | } |
1 | package com.topdraw.business.module.contact.vis.rest; | ||
2 | |||
3 | import com.topdraw.annotation.AnonymousAccess; | ||
4 | import com.topdraw.aop.log.Log; | ||
5 | import com.topdraw.business.module.contact.vis.service.dto.ActivityAddressDTO; | ||
6 | import com.topdraw.common.ResultInfo; | ||
7 | import com.topdraw.business.module.contact.vis.domain.ActivityAddress; | ||
8 | import com.topdraw.business.module.contact.vis.service.ActivityAddressService; | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | ||
10 | import org.springframework.validation.annotation.Validated; | ||
11 | import org.springframework.web.bind.annotation.*; | ||
12 | import io.swagger.annotations.*; | ||
13 | |||
14 | /** | ||
15 | * @author XiangHan | ||
16 | * @date 2022-04-24 | ||
17 | */ | ||
18 | @Api(tags = "中奖人联系方式管理") | ||
19 | @RestController | ||
20 | @RequestMapping("/uce/activityAddress") | ||
21 | public class ActivityAddressController { | ||
22 | |||
23 | @Autowired | ||
24 | private ActivityAddressService activityAddressService; | ||
25 | |||
26 | @GetMapping(value = "/findByPlatformAccount") | ||
27 | @ApiOperation("查询所有ActivityAddress") | ||
28 | @AnonymousAccess | ||
29 | public ResultInfo findByPlatformAccount(@RequestParam(value = "platformAccount") String platformAccount) { | ||
30 | ActivityAddressDTO activityAddressDTO = this.activityAddressService.findByPlatformAccount(platformAccount); | ||
31 | return ResultInfo.success(activityAddressDTO); | ||
32 | } | ||
33 | |||
34 | @Log | ||
35 | @PostMapping(value = "/createOrUpdateActivityAddress") | ||
36 | @ApiOperation("新增ActivityAddress") | ||
37 | @AnonymousAccess | ||
38 | public ResultInfo createOrUpdateActivityAddress(@Validated @RequestBody ActivityAddress resources) { | ||
39 | ActivityAddressDTO activityAddressDTO = this.activityAddressService.createOrUpdateActivityAddress(resources); | ||
40 | return ResultInfo.success(activityAddressDTO); | ||
41 | } | ||
42 | |||
43 | @Log | ||
44 | @PostMapping(value = "/create") | ||
45 | @ApiOperation("新增ActivityAddress") | ||
46 | @AnonymousAccess | ||
47 | public ResultInfo create(@Validated @RequestBody ActivityAddress resources) { | ||
48 | this.activityAddressService.create(resources); | ||
49 | return ResultInfo.success(); | ||
50 | } | ||
51 | |||
52 | @Log | ||
53 | @PutMapping(value = "/update") | ||
54 | @ApiOperation("修改ActivityAddress") | ||
55 | @AnonymousAccess | ||
56 | public ResultInfo update(@Validated @RequestBody ActivityAddress resources) { | ||
57 | this.activityAddressService.update(resources); | ||
58 | return ResultInfo.success(); | ||
59 | } | ||
60 | |||
61 | |||
62 | @Log | ||
63 | @DeleteMapping(value = "/{id}") | ||
64 | @ApiOperation("删除ActivityAddress") | ||
65 | public ResultInfo delete(@PathVariable Long id) { | ||
66 | this.activityAddressService.delete(id); | ||
67 | return ResultInfo.success(); | ||
68 | } | ||
69 | |||
70 | } |
1 | package com.topdraw.business.module.contact.vis.service; | ||
2 | |||
3 | import com.topdraw.business.module.contact.vis.domain.ActivityAddress; | ||
4 | import com.topdraw.business.module.contact.vis.service.dto.ActivityAddressDTO; | ||
5 | |||
6 | /** | ||
7 | * @author XiangHan | ||
8 | * @date 2022-04-24 | ||
9 | */ | ||
10 | public interface ActivityAddressService { | ||
11 | /** | ||
12 | * 根据ID查询 | ||
13 | * @param id ID | ||
14 | * @return ActivityAddressDTO | ||
15 | */ | ||
16 | ActivityAddressDTO findById(Long id); | ||
17 | |||
18 | /** | ||
19 | * | ||
20 | * @param resources | ||
21 | */ | ||
22 | ActivityAddressDTO create(ActivityAddress resources); | ||
23 | |||
24 | /** | ||
25 | * | ||
26 | * @param resources | ||
27 | */ | ||
28 | ActivityAddressDTO update(ActivityAddress resources); | ||
29 | |||
30 | /** | ||
31 | * | ||
32 | * @param id | ||
33 | */ | ||
34 | void delete(Long id); | ||
35 | |||
36 | /** | ||
37 | * | ||
38 | * @param platformAccount | ||
39 | * @return | ||
40 | */ | ||
41 | ActivityAddressDTO findByPlatformAccount(String platformAccount); | ||
42 | |||
43 | /** | ||
44 | * | ||
45 | * @param resources | ||
46 | * @return | ||
47 | */ | ||
48 | ActivityAddressDTO createOrUpdateActivityAddress(ActivityAddress resources); | ||
49 | } |
1 | package com.topdraw.business.module.contact.vis.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import java.sql.Timestamp; | ||
5 | import java.io.Serializable; | ||
6 | |||
7 | |||
8 | /** | ||
9 | * @author XiangHan | ||
10 | * @date 2022-04-24 | ||
11 | */ | ||
12 | @Data | ||
13 | public class ActivityAddressDTO implements Serializable { | ||
14 | |||
15 | // id | ||
16 | private Long id; | ||
17 | |||
18 | // vis的用户id | ||
19 | private Long userId; | ||
20 | |||
21 | // 大屏账号 | ||
22 | private String platformAccount; | ||
23 | |||
24 | // 活动id | ||
25 | private Long activityId; | ||
26 | |||
27 | // 应用id | ||
28 | private Long appId; | ||
29 | |||
30 | // 收货人名称 | ||
31 | private String name; | ||
32 | |||
33 | // 收货人地址 | ||
34 | private String address; | ||
35 | |||
36 | // 收获人手机号 | ||
37 | private String cellphone; | ||
38 | |||
39 | // 创建时间 | ||
40 | private Timestamp createTime; | ||
41 | |||
42 | // 更新时间 | ||
43 | private Timestamp updateTime; | ||
44 | } |
1 | package com.topdraw.business.module.contact.vis.service.impl; | ||
2 | |||
3 | import com.topdraw.business.module.contact.vis.domain.ActivityAddress; | ||
4 | import com.topdraw.util.TimestampUtil; | ||
5 | import com.topdraw.utils.ValidationUtil; | ||
6 | import com.topdraw.business.module.contact.vis.repository.ActivityAddressRepository; | ||
7 | import com.topdraw.business.module.contact.vis.service.ActivityAddressService; | ||
8 | import com.topdraw.business.module.contact.vis.service.dto.ActivityAddressDTO; | ||
9 | import com.topdraw.business.module.contact.vis.service.mapper.ActivityAddressMapper; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | ||
11 | import org.springframework.cache.annotation.CachePut; | ||
12 | import org.springframework.cache.annotation.Cacheable; | ||
13 | import org.springframework.stereotype.Service; | ||
14 | import org.springframework.transaction.annotation.Propagation; | ||
15 | import org.springframework.transaction.annotation.Transactional; | ||
16 | import org.springframework.dao.EmptyResultDataAccessException; | ||
17 | import org.springframework.util.Assert; | ||
18 | |||
19 | import java.util.Objects; | ||
20 | |||
21 | /** | ||
22 | * @author XiangHan | ||
23 | * @date 2022-04-24 | ||
24 | */ | ||
25 | @Service | ||
26 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
27 | public class ActivityAddressServiceImpl implements ActivityAddressService { | ||
28 | |||
29 | @Autowired | ||
30 | private ActivityAddressRepository activityAddressRepository; | ||
31 | |||
32 | @Autowired | ||
33 | private ActivityAddressMapper activityAddressMapper; | ||
34 | |||
35 | @Override | ||
36 | // @Cacheable(cacheNames = "uce::activityAddress::platformAccount", key = "#platformAccount") | ||
37 | public ActivityAddressDTO findByPlatformAccount(String platformAccount) { | ||
38 | ActivityAddress activityAddress = activityAddressRepository.findByPlatformAccount(platformAccount).orElseGet(ActivityAddress::new); | ||
39 | return this.activityAddressMapper.toDto(activityAddress); | ||
40 | } | ||
41 | |||
42 | @Override | ||
43 | public ActivityAddressDTO createOrUpdateActivityAddress(ActivityAddress resources) { | ||
44 | String platformAccount = resources.getPlatformAccount(); | ||
45 | ActivityAddressDTO activityAddressDTO = this.findByPlatformAccount(platformAccount); | ||
46 | if (Objects.isNull(activityAddressDTO.getId())) { | ||
47 | activityAddressDTO = this.create(resources); | ||
48 | } else { | ||
49 | resources.setId(activityAddressDTO.getId()); | ||
50 | resources.setUpdateTime(TimestampUtil.now()); | ||
51 | activityAddressDTO = this.update(resources); | ||
52 | } | ||
53 | return activityAddressDTO; | ||
54 | } | ||
55 | |||
56 | @Override | ||
57 | public ActivityAddressDTO findById(Long id) { | ||
58 | ActivityAddress ActivityAddress = activityAddressRepository.findById(id).orElseGet(ActivityAddress::new); | ||
59 | ValidationUtil.isNull(ActivityAddress.getId(),"ActivityAddress","id",id); | ||
60 | return this.activityAddressMapper.toDto(ActivityAddress); | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | @Transactional(rollbackFor = Exception.class) | ||
65 | // @CachePut(cacheNames = "uce::activityAddress::platformAccount", key = "#resources.platformAccount") | ||
66 | public ActivityAddressDTO create(ActivityAddress resources) { | ||
67 | ActivityAddress activityAddress = activityAddressRepository.save(resources); | ||
68 | return this.activityAddressMapper.toDto(activityAddress); | ||
69 | } | ||
70 | |||
71 | @Override | ||
72 | @Transactional(rollbackFor = Exception.class) | ||
73 | // @CachePut(cacheNames = "uce::activityAddress::platformAccount", key = "#resources.platformAccount") | ||
74 | public ActivityAddressDTO update(ActivityAddress resources) { | ||
75 | ActivityAddress activityAddress = activityAddressRepository.findById(resources.getId()).orElseGet(ActivityAddress::new); | ||
76 | ValidationUtil.isNull( activityAddress.getId(),"ActivityAddress","id",resources.getId()); | ||
77 | activityAddress.copy(resources); | ||
78 | ActivityAddress save = activityAddressRepository.save(activityAddress); | ||
79 | return this.activityAddressMapper.toDto(save); | ||
80 | } | ||
81 | |||
82 | @Override | ||
83 | @Transactional(rollbackFor = Exception.class) | ||
84 | public void delete(Long id) { | ||
85 | Assert.notNull(id, "The given id must not be null!"); | ||
86 | ActivityAddress ActivityAddress = activityAddressRepository.findById(id).orElseThrow( | ||
87 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", ActivityAddress.class, id), 1)); | ||
88 | activityAddressRepository.delete(ActivityAddress); | ||
89 | } | ||
90 | |||
91 | |||
92 | |||
93 | |||
94 | } |
1 | package com.topdraw.business.module.contact.vis.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.module.contact.vis.domain.ActivityAddress; | ||
5 | import com.topdraw.business.module.contact.vis.service.dto.ActivityAddressDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2022-04-24 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface ActivityAddressMapper extends BaseMapper<ActivityAddressDTO, ActivityAddress> { | ||
15 | |||
16 | } |
... | @@ -374,10 +374,14 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -374,10 +374,14 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
374 | * @param currentPoints | 374 | * @param currentPoints |
375 | */ | 375 | */ |
376 | private void doUpdateMemberPoints(Long memberId, long currentPoints, long soonExpirePoints) { | 376 | private void doUpdateMemberPoints(Long memberId, long currentPoints, long soonExpirePoints) { |
377 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
378 | |||
377 | Member member = new Member(); | 379 | Member member = new Member(); |
378 | member.setId(memberId); | 380 | BeanUtils.copyProperties(memberDTO, member); |
381 | |||
379 | member.setPoints(currentPoints); | 382 | member.setPoints(currentPoints); |
380 | member.setDuePoints(soonExpirePoints); | 383 | member.setDuePoints(soonExpirePoints); |
384 | // this.memberOperationService.update(member); | ||
381 | this.memberOperationService.doUpdateMemberPoints(member); | 385 | this.memberOperationService.doUpdateMemberPoints(member); |
382 | } | 386 | } |
383 | 387 | ... | ... |
... | @@ -39,16 +39,16 @@ public class GeneratorCode extends BaseTest { | ... | @@ -39,16 +39,16 @@ public class GeneratorCode extends BaseTest { |
39 | @Rollback(value = false) | 39 | @Rollback(value = false) |
40 | @Transactional(rollbackFor = Exception.class) | 40 | @Transactional(rollbackFor = Exception.class) |
41 | public void generator() { | 41 | public void generator() { |
42 | var dbName = "tr_task_attr"; | 42 | var dbName = "x_activity_address"; |
43 | // 表名称,支持多表 | 43 | // 表名称,支持多表 |
44 | var tableNames = Arrays.asList(dbName); | 44 | var tableNames = Arrays.asList(dbName); |
45 | String[] s = dbName.split("_"); | 45 | String[] s = dbName.split("_"); |
46 | 46 | ||
47 | var pre = s[0]; | 47 | var pre = s[0]; |
48 | var target1 = s[s.length-1]; | 48 | var target1 = s[s.length-1]; |
49 | var preRoute = "com.topdraw.business.module.task."; | 49 | var preRoute = "com.topdraw.business.module.contact."; |
50 | StringBuilder builder = new StringBuilder(preRoute); | 50 | StringBuilder builder = new StringBuilder(preRoute); |
51 | builder.append("attribute"); | 51 | builder.append("vis"); |
52 | // builder.append(target); | 52 | // builder.append(target); |
53 | 53 | ||
54 | tableNames.forEach(tableName -> { | 54 | tableNames.forEach(tableName -> { | ... | ... |
-
Please register or sign in to post a comment