Commit 446b6ce6 446b6ce62aba9c3e999b0df738f3b7db5eafa966 by xianghan

1.添加中奖人联系地址接口

1 parent 3f9ccd44
...@@ -4,6 +4,7 @@ import com.topdraw.business.module.contact.vis.domain.ActivityAddress; ...@@ -4,6 +4,7 @@ import com.topdraw.business.module.contact.vis.domain.ActivityAddress;
4 import org.springframework.data.jpa.repository.JpaRepository; 4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 6
7 import java.util.List;
7 import java.util.Optional; 8 import java.util.Optional;
8 9
9 /** 10 /**
...@@ -12,5 +13,7 @@ import java.util.Optional; ...@@ -12,5 +13,7 @@ import java.util.Optional;
12 */ 13 */
13 public interface ActivityAddressRepository extends JpaRepository<ActivityAddress, Long>, JpaSpecificationExecutor<ActivityAddress> { 14 public interface ActivityAddressRepository extends JpaRepository<ActivityAddress, Long>, JpaSpecificationExecutor<ActivityAddress> {
14 15
15 Optional<ActivityAddress> findByPlatformAccount(String platformAccount); 16 List<ActivityAddress> findByPlatformAccount(String platformAccount);
17
18 Optional<ActivityAddress> findByPlatformAccountAndActivityId(String platformAccount, Long activityId);
16 } 19 }
......
...@@ -6,11 +6,17 @@ import com.topdraw.business.module.contact.vis.service.dto.ActivityAddressDTO; ...@@ -6,11 +6,17 @@ import com.topdraw.business.module.contact.vis.service.dto.ActivityAddressDTO;
6 import com.topdraw.common.ResultInfo; 6 import com.topdraw.common.ResultInfo;
7 import com.topdraw.business.module.contact.vis.domain.ActivityAddress; 7 import com.topdraw.business.module.contact.vis.domain.ActivityAddress;
8 import com.topdraw.business.module.contact.vis.service.ActivityAddressService; 8 import com.topdraw.business.module.contact.vis.service.ActivityAddressService;
9 import lombok.extern.slf4j.Slf4j;
9 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.util.Assert;
12 import org.springframework.util.StringUtils;
10 import org.springframework.validation.annotation.Validated; 13 import org.springframework.validation.annotation.Validated;
11 import org.springframework.web.bind.annotation.*; 14 import org.springframework.web.bind.annotation.*;
12 import io.swagger.annotations.*; 15 import io.swagger.annotations.*;
13 16
17 import java.util.List;
18 import java.util.Objects;
19
14 /** 20 /**
15 * @author XiangHan 21 * @author XiangHan
16 * @date 2022-04-24 22 * @date 2022-04-24
...@@ -18,16 +24,35 @@ import io.swagger.annotations.*; ...@@ -18,16 +24,35 @@ import io.swagger.annotations.*;
18 @Api(tags = "中奖人联系方式管理") 24 @Api(tags = "中奖人联系方式管理")
19 @RestController 25 @RestController
20 @RequestMapping("/uce/activityAddress") 26 @RequestMapping("/uce/activityAddress")
27 @Slf4j
21 public class ActivityAddressController { 28 public class ActivityAddressController {
22 29
23 @Autowired 30 @Autowired
24 private ActivityAddressService activityAddressService; 31 private ActivityAddressService activityAddressService;
25 32
33 @GetMapping(value = "/findByPlatformAccountAndActivityId")
34 @ApiOperation("查询指定活动事件的中奖人联系方式")
35 @AnonymousAccess
36 public ResultInfo findByPlatformAccountAndActivityId(@Validated @RequestBody ActivityAddress resources) {
37 log.info("activityAddress ==>> findByPlatformAccountAndActivityId ==>> resources ==>> {}", resources);
38 String platformAccount = resources.getPlatformAccount();
39 if (!StringUtils.hasText(platformAccount)) {
40 Assert.notNull(platformAccount, "platformAccount is null");
41 }
42 Long activityId = resources.getActivityId();
43 if (Objects.isNull(activityId)) {
44 Assert.notNull(activityId, "activityId is null");
45 }
46 ActivityAddressDTO activityAddressDTO = this.activityAddressService.findByPlatformAccountAndActivityId(resources);
47 return ResultInfo.success(activityAddressDTO);
48 }
49
26 @GetMapping(value = "/findByPlatformAccount") 50 @GetMapping(value = "/findByPlatformAccount")
27 @ApiOperation("查询所有ActivityAddress") 51 @ApiOperation("查询所有ActivityAddress")
28 @AnonymousAccess 52 @AnonymousAccess
29 public ResultInfo findByPlatformAccount(@RequestParam(value = "platformAccount") String platformAccount) { 53 public ResultInfo findByPlatformAccount(@RequestParam(value = "platformAccount") String platformAccount) {
30 ActivityAddressDTO activityAddressDTO = this.activityAddressService.findByPlatformAccount(platformAccount); 54 log.info("activityAddress ==>> findByPlatformAccount ==>> platformAccount ==>> {}", platformAccount);
55 List<ActivityAddressDTO> activityAddressDTO = this.activityAddressService.findByPlatformAccount(platformAccount);
31 return ResultInfo.success(activityAddressDTO); 56 return ResultInfo.success(activityAddressDTO);
32 } 57 }
33 58
...@@ -36,6 +61,23 @@ public class ActivityAddressController { ...@@ -36,6 +61,23 @@ public class ActivityAddressController {
36 @ApiOperation("新增ActivityAddress") 61 @ApiOperation("新增ActivityAddress")
37 @AnonymousAccess 62 @AnonymousAccess
38 public ResultInfo createOrUpdateActivityAddress(@Validated @RequestBody ActivityAddress resources) { 63 public ResultInfo createOrUpdateActivityAddress(@Validated @RequestBody ActivityAddress resources) {
64 log.info("activityAddress ==>> createOrUpdateActivityAddress ==>> params ==>> {}", resources);
65 String platformAccount = resources.getPlatformAccount();
66 if (!StringUtils.hasText(platformAccount)) {
67 Assert.notNull(platformAccount, "platformAccount is null");
68 }
69 Long appId = resources.getAppId();
70 if (Objects.isNull(appId)) {
71 Assert.notNull(appId, "appId is null");
72 }
73 Long activityId = resources.getActivityId();
74 if (Objects.isNull(activityId)) {
75 Assert.notNull(activityId, "activityId is null");
76 }
77 Long userId = resources.getUserId();
78 if (Objects.isNull(userId)) {
79 Assert.notNull(userId, "visUserId is null");
80 }
39 ActivityAddressDTO activityAddressDTO = this.activityAddressService.createOrUpdateActivityAddress(resources); 81 ActivityAddressDTO activityAddressDTO = this.activityAddressService.createOrUpdateActivityAddress(resources);
40 return ResultInfo.success(activityAddressDTO); 82 return ResultInfo.success(activityAddressDTO);
41 } 83 }
......
...@@ -3,6 +3,8 @@ package com.topdraw.business.module.contact.vis.service; ...@@ -3,6 +3,8 @@ package com.topdraw.business.module.contact.vis.service;
3 import com.topdraw.business.module.contact.vis.domain.ActivityAddress; 3 import com.topdraw.business.module.contact.vis.domain.ActivityAddress;
4 import com.topdraw.business.module.contact.vis.service.dto.ActivityAddressDTO; 4 import com.topdraw.business.module.contact.vis.service.dto.ActivityAddressDTO;
5 5
6 import java.util.List;
7
6 /** 8 /**
7 * @author XiangHan 9 * @author XiangHan
8 * @date 2022-04-24 10 * @date 2022-04-24
...@@ -38,7 +40,7 @@ public interface ActivityAddressService { ...@@ -38,7 +40,7 @@ public interface ActivityAddressService {
38 * @param platformAccount 40 * @param platformAccount
39 * @return 41 * @return
40 */ 42 */
41 ActivityAddressDTO findByPlatformAccount(String platformAccount); 43 List<ActivityAddressDTO> findByPlatformAccount(String platformAccount);
42 44
43 /** 45 /**
44 * 46 *
...@@ -46,4 +48,11 @@ public interface ActivityAddressService { ...@@ -46,4 +48,11 @@ public interface ActivityAddressService {
46 * @return 48 * @return
47 */ 49 */
48 ActivityAddressDTO createOrUpdateActivityAddress(ActivityAddress resources); 50 ActivityAddressDTO createOrUpdateActivityAddress(ActivityAddress resources);
51
52 /**
53 *
54 * @param resources
55 * @return
56 */
57 ActivityAddressDTO findByPlatformAccountAndActivityId(ActivityAddress resources);
49 } 58 }
......
...@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
16 import org.springframework.dao.EmptyResultDataAccessException; 16 import org.springframework.dao.EmptyResultDataAccessException;
17 import org.springframework.util.Assert; 17 import org.springframework.util.Assert;
18 18
19 import java.util.List;
19 import java.util.Objects; 20 import java.util.Objects;
20 21
21 /** 22 /**
...@@ -34,15 +35,14 @@ public class ActivityAddressServiceImpl implements ActivityAddressService { ...@@ -34,15 +35,14 @@ public class ActivityAddressServiceImpl implements ActivityAddressService {
34 35
35 @Override 36 @Override
36 // @Cacheable(cacheNames = "uce::activityAddress::platformAccount", key = "#platformAccount") 37 // @Cacheable(cacheNames = "uce::activityAddress::platformAccount", key = "#platformAccount")
37 public ActivityAddressDTO findByPlatformAccount(String platformAccount) { 38 public List<ActivityAddressDTO> findByPlatformAccount(String platformAccount) {
38 ActivityAddress activityAddress = activityAddressRepository.findByPlatformAccount(platformAccount).orElseGet(ActivityAddress::new); 39 List<ActivityAddress> activityAddress = activityAddressRepository.findByPlatformAccount(platformAccount);
39 return this.activityAddressMapper.toDto(activityAddress); 40 return this.activityAddressMapper.toDto(activityAddress);
40 } 41 }
41 42
42 @Override 43 @Override
43 public ActivityAddressDTO createOrUpdateActivityAddress(ActivityAddress resources) { 44 public ActivityAddressDTO createOrUpdateActivityAddress(ActivityAddress resources) {
44 String platformAccount = resources.getPlatformAccount(); 45 ActivityAddressDTO activityAddressDTO = this.findByPlatformAccountAndActivityId(resources);
45 ActivityAddressDTO activityAddressDTO = this.findByPlatformAccount(platformAccount);
46 if (Objects.isNull(activityAddressDTO.getId())) { 46 if (Objects.isNull(activityAddressDTO.getId())) {
47 activityAddressDTO = this.create(resources); 47 activityAddressDTO = this.create(resources);
48 } else { 48 } else {
...@@ -54,6 +54,14 @@ public class ActivityAddressServiceImpl implements ActivityAddressService { ...@@ -54,6 +54,14 @@ public class ActivityAddressServiceImpl implements ActivityAddressService {
54 } 54 }
55 55
56 @Override 56 @Override
57 public ActivityAddressDTO findByPlatformAccountAndActivityId(ActivityAddress resources) {
58 String platformAccount = resources.getPlatformAccount();
59 Long activityId = resources.getActivityId();
60 ActivityAddress activityAddress = activityAddressRepository.findByPlatformAccountAndActivityId(platformAccount, activityId).orElseGet(ActivityAddress::new);
61 return this.activityAddressMapper.toDto(activityAddress);
62 }
63
64 @Override
57 public ActivityAddressDTO findById(Long id) { 65 public ActivityAddressDTO findById(Long id) {
58 ActivityAddress ActivityAddress = activityAddressRepository.findById(id).orElseGet(ActivityAddress::new); 66 ActivityAddress ActivityAddress = activityAddressRepository.findById(id).orElseGet(ActivityAddress::new);
59 ValidationUtil.isNull(ActivityAddress.getId(),"ActivityAddress","id",id); 67 ValidationUtil.isNull(ActivityAddress.getId(),"ActivityAddress","id",id);
......
1 package com.topdraw.business.module.task.domain;
2
3 import com.topdraw.util.DateUtil;
4 import com.topdraw.util.IdWorker;
5 import com.topdraw.util.RandomUtil;
6 import com.topdraw.util.TimestampUtil;
7 import org.apache.commons.lang3.StringUtils;
8
9 import java.util.Objects;
10
11 /**
12 * @author :
13 * @description:
14 * @function :
15 * @date :Created in 2022/4/25 16:33
16 * @version: :
17 * @modified By:
18 * @since : modified in 2022/4/25 16:33
19 */
20 public class TaskBuilder {
21
22
23 public static Task build(Task task) {
24
25 Task task_ = new Task();
26 task_.setTaskTemplateId(task.getTaskTemplateId());
27
28 //task_.setName(task.getName());
29 //task_.setCode(StringUtils.isEmpty(task.getCode()) ? IdWorker.generatorCode("task_") : task.getCode());
30 task_.setStatus(Objects.isNull(task.getStatus()) ? 1 : task.getStatus());
31 task_.setSequence(task.getSequence());
32 task_.setValidTime(Objects.isNull(task.getValidTime()) ? TimestampUtil.now() : task.getValidTime());
33 task_.setExpireTime(task.getExpireTime());
34 //task_.setDescription(task.getDescription());
35 task_.setActionAmount(task.getActionAmount());
36 task_.setTaskDailyReset(Objects.isNull(task.getTaskDailyReset()) ? 1 : task.getTaskDailyReset());
37 task_.setTaskRepeatType(Objects.isNull(task.getTaskRepeatType()) ? 1 : task.getTaskRepeatType());
38 task_.setRightsSendStrategy(Objects.isNull(task.getRightsSendStrategy()) ? 1 : task.getRightsSendStrategy());
39
40 task_.setGroups(task.getGroups());
41 task_.setMemberLevel(task.getMemberLevel());
42 task_.setMemberVip(task.getMemberVip());
43 //task_.setMemberExclusive(task.getMemberExclusive());
44
45 task_.setPointsType(Objects.isNull(task.getPointsType()) ? 1 : task.getPointsType());
46 task_.setRewardPoints(Objects.isNull(task.getRewardPoints()) ? null : task.getRewardPoints());
47 //task_.setRewardPointsExpireTime(Objects.isNull(task.getRewardPointsExpireTime()) ?
48 // DateUtil.getLastDateTimeSecondYearLong() : task.getRewardPointsExpireTime());
49 //task_.setRewardMaxPoints(Objects.isNull(task.getRewardMaxPoints()) ?
50 //RandomUtil.getRandomPoints(1, 10).intValue() : task.getRewardMaxPoints());
51
52 task_.setRewardExp(Objects.isNull(task.getRewardExp()) ? 0L : task.getRewardExp());
53
54 task_.setRightsId(task.getRightsId());
55 task_.setRightsAmount(task.getRightsAmount());
56 task_.setRights2Id(task.getRights2Id());
57 task_.setRights2Amount(task.getRights2Amount());
58 task_.setRights3Id(task.getRights3Id());
59 task_.setRights3Amount(task.getRights3Amount());
60
61 return task;
62 }
63
64 }
1 package com.topdraw.business.module.task.template.domain;
2
3 import com.topdraw.util.IdWorker;
4 import org.apache.commons.lang3.StringUtils;
5
6 import java.util.Objects;
7
8 /**
9 * @author :
10 * @description:
11 * @function :
12 * @date :Created in 2022/4/25 17:22
13 * @version: :
14 * @modified By:
15 * @since : modified in 2022/4/25 17:22
16 */
17 public class TaskTemplateBuilder {
18
19 public static TaskTemplate build(TaskTemplate taskTemplate){
20
21 TaskTemplate taskTemplate_ = new TaskTemplate();
22
23 taskTemplate_.setCode(StringUtils.isEmpty(taskTemplate.getCode()) ? IdWorker.generatorCode("taskTemplate_") : taskTemplate.getCode());
24 taskTemplate_.setName(taskTemplate.getName());
25 taskTemplate_.setType(taskTemplate.getType());
26 taskTemplate_.setStatus(Objects.isNull(taskTemplate.getStatus()) ? 1:taskTemplate.getStatus());
27 taskTemplate_.setEvent(taskTemplate.getEvent());
28 taskTemplate_.setParams(taskTemplate.getParams());
29 taskTemplate_.setDescription(taskTemplate.getDescription());
30 // taskTemplate_.setDeleteMark(Objects.isNull(taskTemplate.getDeleteMark()) ? 0 : taskTemplate.getDeleteMark());
31
32 return taskTemplate_;
33 }
34
35 }
1 package com.topdraw.business.process.rest;
2
3 import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.business.module.task.template.domain.TaskTemplate;
5 import com.topdraw.business.process.service.TaskTemplateOperationService;
6 import io.swagger.annotations.Api;
7 import io.swagger.annotations.ApiOperation;
8 import lombok.extern.slf4j.Slf4j;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.validation.annotation.Validated;
11 import org.springframework.web.bind.annotation.*;
12
13 @Api("任务模板处理")
14 @RestController
15 @RequestMapping(value = "/uce/taskTemplateOperation")
16 @Slf4j
17 public class TaskTemplateOperationController {
18
19 @Autowired
20 private TaskTemplateOperationService taskTemplateOperationService;
21
22 /**
23 * 新增任务
24 *
25 * @param taskTemplate 消息
26 */
27 @PostMapping(value = "/create")
28 @ApiOperation("新增任务")
29 @AnonymousAccess
30 public void create(@RequestBody @Validated TaskTemplate taskTemplate) {
31 log.info("taskTemplateOperation ==>> create ==>> param ==>> {}", taskTemplate);
32 // 新增任务
33 this.taskTemplateOperationService.create(taskTemplate);
34 }
35
36 /**
37 * 修改任务
38 *
39 * @param taskTemplate 消息
40 */
41 @PostMapping(value = "/update")
42 @ApiOperation("修改任务模板")
43 @AnonymousAccess
44 public void update(@RequestBody @Validated TaskTemplate taskTemplate) {
45 log.info("taskTemplateOperation ==>> update ==>> param ==>> {}", taskTemplate);
46 // 修改任务
47 this.taskTemplateOperationService.update(taskTemplate);
48 }
49
50 /**
51 * 删除任务
52 *
53 * @param id 消息
54 */
55 @PostMapping(value = "/delete")
56 @ApiOperation("删除任务模板")
57 @AnonymousAccess
58 public void delete(@RequestParam(value = "id") Long id) {
59 log.info("taskTemplateOperation ==>> delete ==>> param ==>> {}", id);
60 // 删除任务
61 this.taskTemplateOperationService.delete(id);
62 }
63
64 }
65
66
1 package com.topdraw.business.process.service;
2
3 import com.topdraw.business.module.task.template.domain.TaskTemplate;
4
5 /**
6 * @description 权益操作接口
7 * @author XiangHan
8 * @date 2021.10.22
9 */
10 public interface TaskTemplateOperationService {
11
12 /**
13 *
14 * @param task
15 */
16 void create(TaskTemplate task);
17
18 /**
19 *
20 * @param task
21 */
22 void update(TaskTemplate task);
23
24 /**
25 *
26 * @param task
27 */
28 void delete(TaskTemplate task);
29
30 /**
31 *
32 * @param id
33 */
34 void delete(Long id);
35
36 }
1 package com.topdraw.business.process.service.impl;
2
3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.module.task.template.domain.TaskTemplate;
5 import com.topdraw.business.module.task.template.domain.TaskTemplateBuilder;
6 import com.topdraw.business.module.task.template.service.TaskTemplateService;
7 import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO;
8 import com.topdraw.business.process.service.TaskTemplateOperationService;
9 import lombok.extern.slf4j.Slf4j;
10 import org.springframework.aop.framework.AopContext;
11 import org.springframework.beans.BeanUtils;
12 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.stereotype.Service;
14
15 import java.util.Objects;
16
17
18 /**
19 * @author :
20 * @description:
21 * @function :
22 * @date :Created in 2022/4/25 22:27
23 * @version: :
24 * @modified By:
25 * @since : modified in 2022/4/25 22:27
26 */
27 @Service
28 @Slf4j
29 public class TaskTemplateOperationServiceImpl implements TaskTemplateOperationService {
30
31 @Autowired
32 private TaskTemplateService taskTemplateService;
33
34 @AsyncMqSend
35 public void asyncTaskTemplate(TaskTemplate resources) {}
36
37 @Override
38 public void create(TaskTemplate resources) {
39 TaskTemplate taskTemplate = TaskTemplateBuilder.build(resources);
40 //TaskTemplateDTO taskTemplate_ = this.taskTemplateService.create(taskTemplate);
41
42 TaskTemplate taskTemplate1 = new TaskTemplate();
43 //BeanUtils.copyProperties(taskTemplate_, taskTemplate1);
44 //((TaskTemplateOperationServiceImpl) AopContext.currentProxy()).asyncTaskTemplate(taskTemplate1);
45 }
46
47 @Override
48 public void update(TaskTemplate resources) {
49 //TaskTemplateDTO taskTemplate_ = this.taskTemplateService.update(resources);
50
51 TaskTemplate taskTemplate1 = new TaskTemplate();
52 //BeanUtils.copyProperties(taskTemplate_, taskTemplate1);
53 ((TaskTemplateOperationServiceImpl) AopContext.currentProxy()).asyncTaskTemplate(taskTemplate1);
54 }
55
56 @Override
57 public void delete(TaskTemplate resources) {
58 //this.taskTemplateService.delete(resources);
59 //((TaskTemplateOperationServiceImpl) AopContext.currentProxy()).asyncTaskTemplate(resources);
60 }
61
62 @Override
63 public void delete(Long id) {
64 TaskTemplateDTO taskTemplateDTO = this.findById(id);
65 //this.taskTemplateService.delete(id);
66
67 TaskTemplate taskTemplate = new TaskTemplate();
68 BeanUtils.copyProperties(taskTemplateDTO, taskTemplate);
69 //taskTemplate.setDeleteMark(1);
70 //((TaskTemplateOperationServiceImpl) AopContext.currentProxy()).asyncTaskTemplate(taskTemplate);
71 }
72
73 public TaskTemplateDTO findByCode(String code) {
74 return null;//this.taskTemplateService.findByCode(code);
75 }
76
77 public TaskTemplateDTO findById(Long id) {
78 return this.taskTemplateService.findById(id);
79 }
80
81 }