Commit 8c7571ef 8c7571ef5b30c10c02c36fb3d13f65f52e594c91 by xianghan

1.update

1 parent 932b0c98
...@@ -33,6 +33,9 @@ public class Task implements Serializable { ...@@ -33,6 +33,9 @@ public class Task implements Serializable {
33 @Column(name = "task_template_id", nullable = false) 33 @Column(name = "task_template_id", nullable = false)
34 private Long taskTemplateId; 34 private Long taskTemplateId;
35 35
36 @Transient
37 private String taskTemplateCode;
38
36 /** 任务重复类型,-1:不限次;1:单次;>1:多次 */ 39 /** 任务重复类型,-1:不限次;1:单次;>1:多次 */
37 @Column(name = "task_repeat_type", nullable = false) 40 @Column(name = "task_repeat_type", nullable = false)
38 private Integer taskRepeatType; 41 private Integer taskRepeatType;
...@@ -117,10 +120,29 @@ public class Task implements Serializable { ...@@ -117,10 +120,29 @@ public class Task implements Serializable {
117 @Column(name = "rights3_amount") 120 @Column(name = "rights3_amount")
118 private Integer rights3Amount; 121 private Integer rights3Amount;
119 122
123 /** 会员专享 0:会员专享 1:非会员专享 */
124 @Column(name = "member_exclusive")
125 private Integer memberExclusive;
126
120 /** 状态 0:失效;1:生效 */ 127 /** 状态 0:失效;1:生效 */
121 @Column(name = "status", nullable = false) 128 @Column(name = "status", nullable = false)
122 private Integer status; 129 private Integer status;
123 130
131 /** 任务名称 */
132 @Column(name = "name", nullable = false)
133 private String name;
134
135 /** 编号 */
136 @Column(name = "code", nullable = false)
137 private String code;
138
139 /** 任务描述 */
140 @Column(name = "description", nullable = false)
141 private String description;
142
143 @Transient
144 private String attr;
145
124 /** 创建时间 */ 146 /** 创建时间 */
125 @CreatedDate 147 @CreatedDate
126 @Column(name = "create_time") 148 @Column(name = "create_time")
......
...@@ -3,8 +3,12 @@ package com.topdraw.business.module.task.repository; ...@@ -3,8 +3,12 @@ package com.topdraw.business.module.task.repository;
3 import com.topdraw.business.module.task.domain.Task; 3 import com.topdraw.business.module.task.domain.Task;
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 import org.springframework.data.jpa.repository.Modifying;
7 import org.springframework.data.jpa.repository.Query;
8 import org.springframework.transaction.annotation.Transactional;
6 9
7 import java.util.List; 10 import java.util.List;
11 import java.util.Optional;
8 12
9 /** 13 /**
10 * @author XiangHan 14 * @author XiangHan
...@@ -14,4 +18,10 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat ...@@ -14,4 +18,10 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat
14 18
15 List<Task> findByTaskTemplateId(Long taskTemplateId); 19 List<Task> findByTaskTemplateId(Long taskTemplateId);
16 20
21 Optional<Task> findByCode(String code);
22
23 @Modifying
24 @Transactional
25 @Query(value = "UPDATE `tr_task` SET `delete_mark` = 1 , `update_time` = now() WHERE `id` = ?1", nativeQuery = true)
26 void updateDeleteMark(Long id);
17 } 27 }
......
...@@ -24,4 +24,35 @@ public interface TaskService { ...@@ -24,4 +24,35 @@ public interface TaskService {
24 * @return 24 * @return
25 */ 25 */
26 List<Task> findByTemplateId(Long taskTemplateId); 26 List<Task> findByTemplateId(Long taskTemplateId);
27
28 /**
29 *
30 * @param code
31 * @return
32 */
33 TaskDTO findByCode(String code);
34
35 /**
36 *
37 * @param task
38 */
39 TaskDTO create(Task task);
40
41 /**
42 *
43 * @param task
44 */
45 TaskDTO update(Task task);
46
47 /**
48 *
49 * @param task
50 */
51 void delete(Task task);
52
53 /**
54 *
55 * @param id
56 */
57 void delete(Long id);
27 } 58 }
......
...@@ -73,9 +73,24 @@ public class TaskDTO implements Serializable { ...@@ -73,9 +73,24 @@ public class TaskDTO implements Serializable {
73 /** 权益3数量 */ 73 /** 权益3数量 */
74 private Integer rights3Amount; 74 private Integer rights3Amount;
75 75
76 /** 会员专享 0:会员专享 1:非会员专享 */
77 private Integer memberExclusive;
78
76 /** 状态 0:失效;1:生效 */ 79 /** 状态 0:失效;1:生效 */
77 private Integer status; 80 private Integer status;
78 81
82 /** 任务名称 */
83 private String name;
84
85 /** 编号 */
86 private String code;
87
88 /** 任务描述 */
89 private String description;
90
91 /** 属性 */
92 private String attr;
93
79 /** 创建时间 */ 94 /** 创建时间 */
80 private Timestamp createTime; 95 private Timestamp createTime;
81 96
......
...@@ -40,5 +40,33 @@ public class TaskServiceImpl implements TaskService { ...@@ -40,5 +40,33 @@ public class TaskServiceImpl implements TaskService {
40 return Objects.nonNull(taskTemplateId) ? this.taskRepository.findByTaskTemplateId(taskTemplateId) : null; 40 return Objects.nonNull(taskTemplateId) ? this.taskRepository.findByTaskTemplateId(taskTemplateId) : null;
41 } 41 }
42 42
43 @Override
44 public TaskDTO findByCode(String code) {
45 Task task = this.taskRepository.findByCode(code).orElseGet(Task::new);
46 return this.taskMapper.toDto(task);
47 }
48
49 @Override
50 public TaskDTO create(Task task) {
51 Task save = this.taskRepository.save(task);
52 return this.taskMapper.toDto(save);
53 }
54
55 @Override
56 public TaskDTO update(Task task) {
57 Task save = this.taskRepository.save(task);
58 return this.taskMapper.toDto(save);
59 }
60
61 @Override
62 public void delete(Task task) {
63 Long id = task.getId();
64 this.delete(id);
65 }
66
67 @Override
68 public void delete(Long id) {
69 this.taskRepository.updateDeleteMark(id);
70 }
43 71
44 } 72 }
......
...@@ -28,34 +28,38 @@ public class TaskTemplate implements Serializable { ...@@ -28,34 +28,38 @@ public class TaskTemplate implements Serializable {
28 @Column(name = "id") 28 @Column(name = "id")
29 private Long id; 29 private Long id;
30 30
31 // 标识 31 /** 标识 */
32 @Column(name = "code") 32 @Column(name = "code")
33 private String code; 33 private String code;
34 34
35 // 名称 35 /** 名称 */
36 @Column(name = "name") 36 @Column(name = "name")
37 private String name; 37 private String name;
38 38
39 // 关注事件(和MQ topic相关) 39 /** 关注事件(和MQ topic相关) */
40 @Column(name = "event") 40 @Column(name = "event")
41 private String event; 41 private String event;
42 42
43 // 描述 43 /** 描述 */
44 @Column(name = "description") 44 @Column(name = "description")
45 private String description; 45 private String description;
46 46
47 // 状态 0:失效;1:生效 47 /** 状态 0:失效;1:生效 */
48 @Column(name = "status") 48 @Column(name = "status")
49 private Integer status; 49 private Integer status;
50 50
51 // 类型 0:活动任务模板 51 /** 类型 0:活动任务模板 */
52 @Column(name = "type") 52 @Column(name = "type")
53 private Integer type; 53 private Integer type;
54 54
55 // 模板参数,json 55 /** 模板参数,json */
56 @Column(name = "params") 56 @Column(name = "params")
57 private String params; 57 private String params;
58 58
59 /** 删除标识 0:正常;1:已删除; */
60 @Column(name = "delete_mark")
61 private Integer deleteMark;
62
59 @CreatedDate 63 @CreatedDate
60 @Column(name = "create_time") 64 @Column(name = "create_time")
61 private Timestamp createTime; 65 private Timestamp createTime;
......
...@@ -3,8 +3,10 @@ package com.topdraw.business.module.task.template.repository; ...@@ -3,8 +3,10 @@ package com.topdraw.business.module.task.template.repository;
3 import com.topdraw.business.module.task.template.domain.TaskTemplate; 3 import com.topdraw.business.module.task.template.domain.TaskTemplate;
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 import org.springframework.data.jpa.repository.Modifying;
7 import org.springframework.data.jpa.repository.Query;
8 import org.springframework.transaction.annotation.Transactional;
6 9
7 import java.util.List;
8 import java.util.Optional; 10 import java.util.Optional;
9 11
10 /** 12 /**
...@@ -17,5 +19,10 @@ public interface TaskTemplateRepository extends JpaRepository<TaskTemplate, Long ...@@ -17,5 +19,10 @@ public interface TaskTemplateRepository extends JpaRepository<TaskTemplate, Long
17 19
18 TaskTemplate findByEvent(String event); 20 TaskTemplate findByEvent(String event);
19 21
20 List<TaskTemplate> findByType(Integer event); 22 TaskTemplate findByType(Integer event);
23
24 @Modifying
25 @Transactional
26 @Query(value = "UPDATE `tr_task_template` SET `delete_mark` = 1 , `update_time` = now() WHERE `id` = ?1", nativeQuery = true)
27 void updateDeleteMark(Long id);
21 } 28 }
......
...@@ -2,11 +2,8 @@ package com.topdraw.business.module.task.template.service; ...@@ -2,11 +2,8 @@ package com.topdraw.business.module.task.template.service;
2 2
3 import com.topdraw.business.module.task.template.domain.TaskTemplate; 3 import com.topdraw.business.module.task.template.domain.TaskTemplate;
4 import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO; 4 import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO;
5 import com.topdraw.business.module.task.template.service.dto.TaskTemplateQueryCriteria;
6 import org.springframework.data.domain.Pageable;
7 5
8 import java.util.List; 6 import java.util.List;
9 import java.util.Map;
10 7
11 /** 8 /**
12 * @author XiangHan 9 * @author XiangHan
...@@ -15,31 +12,28 @@ import java.util.Map; ...@@ -15,31 +12,28 @@ import java.util.Map;
15 public interface TaskTemplateService { 12 public interface TaskTemplateService {
16 13
17 /** 14 /**
18 * 查询数据分页
19 * @param criteria 条件参数
20 * @param pageable 分页参数
21 * @return Map<String,Object>
22 */
23 Map<String,Object> queryAll(TaskTemplateQueryCriteria criteria, Pageable pageable);
24
25 /**
26 * 查询所有数据不分页
27 * @param criteria 条件参数
28 * @return List<TaskTemplateDTO>
29 */
30 List<TaskTemplateDTO> queryAll(TaskTemplateQueryCriteria criteria);
31
32 /**
33 * 根据ID查询 15 * 根据ID查询
34 * @param id ID 16 * @param id ID
35 * @return TaskTemplateDTO 17 * @return TaskTemplateDTO
36 */ 18 */
37 TaskTemplateDTO findById(Long id); 19 TaskTemplateDTO findById(Long id);
38 20
39 void create(TaskTemplate resources); 21 /**
22 *
23 * @param resources
24 */
25 TaskTemplateDTO create(TaskTemplate resources);
40 26
41 void update(TaskTemplate resources); 27 /**
28 *
29 * @param resources
30 */
31 TaskTemplateDTO update(TaskTemplate resources);
42 32
33 /**
34 *
35 * @param id
36 */
43 void delete(Long id); 37 void delete(Long id);
44 38
45 /** 39 /**
...@@ -47,9 +41,19 @@ public interface TaskTemplateService { ...@@ -47,9 +41,19 @@ public interface TaskTemplateService {
47 * @param code 41 * @param code
48 * @return TaskTemplateDTO 42 * @return TaskTemplateDTO
49 */ 43 */
50 TaskTemplateDTO getByCode(String code); 44 TaskTemplateDTO findByCode(String code);
51 45
52 TaskTemplate findByEvent(String event); 46 /**
47 *
48 * @param event
49 * @return
50 */
51 TaskTemplateDTO findByEvent(String event);
53 52
54 List<TaskTemplate> findByType(Integer event); 53 /**
54 *
55 * @param event
56 * @return
57 */
58 TaskTemplateDTO findByType(Integer event);
55 } 59 }
......
...@@ -2,6 +2,7 @@ package com.topdraw.business.module.task.template.service.dto; ...@@ -2,6 +2,7 @@ package com.topdraw.business.module.task.template.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
5 import javax.persistence.Column;
5 import java.io.Serializable; 6 import java.io.Serializable;
6 import java.sql.Timestamp; 7 import java.sql.Timestamp;
7 8
...@@ -15,27 +16,30 @@ public class TaskTemplateDTO implements Serializable { ...@@ -15,27 +16,30 @@ public class TaskTemplateDTO implements Serializable {
15 16
16 private Long id; 17 private Long id;
17 18
18 // 标识 19 /** 标识 */
19 private String code; 20 private String code;
20 21
21 // 名称 22 /** 名称 */
22 private String name; 23 private String name;
23 24
24 // 关注事件(和MQ topic相关) 25 /** 关注事件(和MQ topic相关) */
25 private String event; 26 private String event;
26 27
27 // 描述 28 /** 描述 */
28 private String description; 29 private String description;
29 30
30 // 状态 0:失效;1:生效 31 /** 状态 0:失效;1:生效 */
31 private Integer status; 32 private Integer status;
32 33
33 // 类型 0:活动任务模板 34 /** 类型 0:活动任务模板 */
34 private Integer type; 35 private Integer type;
35 36
36 // 模板参数,json 37 /** 模板参数,json */
37 private String params; 38 private String params;
38 39
40 /** 删除标识 0:正常;1:已删除; */
41 private Integer deleteMark;
42
39 private Timestamp createTime; 43 private Timestamp createTime;
40 44
41 private Timestamp updateTime; 45 private Timestamp updateTime;
......
1 package com.topdraw.business.module.task.template.service.dto;
2
3 import lombok.Data;
4
5 /**
6 * @author XiangHan
7 * @date 2021-10-22
8 */
9 @Data
10 public class TaskTemplateQueryCriteria{
11 }
1 package com.topdraw.business.module.task.template.service.impl; 1 package com.topdraw.business.module.task.template.service.impl;
2 2
3 import com.topdraw.business.module.task.template.domain.TaskTemplate; 3 import com.topdraw.business.module.task.template.domain.TaskTemplate;
4 import com.topdraw.business.module.task.template.repository.TaskTemplateRepository;
4 import com.topdraw.business.module.task.template.service.TaskTemplateService; 5 import com.topdraw.business.module.task.template.service.TaskTemplateService;
5 import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO; 6 import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO;
6 import com.topdraw.business.module.task.template.service.dto.TaskTemplateQueryCriteria; 7 import com.topdraw.business.module.task.template.service.mapper.TaskTemplateMapper;
7 import com.topdraw.utils.PageUtil;
8 import com.topdraw.utils.QueryHelp;
9 import com.topdraw.utils.StringUtils; 8 import com.topdraw.utils.StringUtils;
10 import com.topdraw.utils.ValidationUtil; 9 import com.topdraw.utils.ValidationUtil;
11 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.dao.EmptyResultDataAccessException; 11 import org.springframework.dao.EmptyResultDataAccessException;
13 import org.springframework.data.domain.Page;
14 import org.springframework.data.domain.Pageable;
15 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
16 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
17 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
18 import org.springframework.util.Assert; 15 import org.springframework.util.Assert;
19 16
20 import java.util.List; 17 import java.util.List;
21 import java.util.Map;
22 import java.util.Objects; 18 import java.util.Objects;
23 19
24 /** 20 /**
...@@ -30,69 +26,57 @@ import java.util.Objects; ...@@ -30,69 +26,57 @@ import java.util.Objects;
30 public class TaskTemplateServiceImpl implements TaskTemplateService { 26 public class TaskTemplateServiceImpl implements TaskTemplateService {
31 27
32 @Autowired 28 @Autowired
33 private com.topdraw.business.module.task.template.repository.TaskTemplateRepository TaskTemplateRepository; 29 private TaskTemplateRepository taskTemplateRepository;
34 30
35 @Autowired 31 @Autowired
36 private com.topdraw.business.module.task.template.service.mapper.TaskTemplateMapper TaskTemplateMapper; 32 private TaskTemplateMapper taskTemplateMapper;
37
38 @Override
39 public Map<String, Object> queryAll(TaskTemplateQueryCriteria criteria, Pageable pageable) {
40 Page<TaskTemplate> page = TaskTemplateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
41 return PageUtil.toPage(page.map(TaskTemplateMapper::toDto));
42 }
43
44 @Override
45 public List<TaskTemplateDTO> queryAll(TaskTemplateQueryCriteria criteria) {
46 return TaskTemplateMapper.toDto(TaskTemplateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
47 }
48 33
49 @Override 34 @Override
50 public TaskTemplateDTO findById(Long id) { 35 public TaskTemplateDTO findById(Long id) {
51 TaskTemplate TaskTemplate = TaskTemplateRepository.findById(id).orElseGet(com.topdraw.business.module.task.template.domain.TaskTemplate::new); 36 TaskTemplate taskTemplate = this.taskTemplateRepository.findById(id).orElseGet(TaskTemplate::new);
52 ValidationUtil.isNull(TaskTemplate.getId(),"TaskTemplate","id",id); 37 ValidationUtil.isNull(taskTemplate.getId(),"TaskTemplate","id",id);
53 return TaskTemplateMapper.toDto(TaskTemplate); 38 return this.taskTemplateMapper.toDto(taskTemplate);
54 } 39 }
55 40
56 @Override 41 @Override
57 @Transactional(rollbackFor = Exception.class) 42 @Transactional(rollbackFor = Exception.class)
58 public void create(TaskTemplate resources) { 43 public TaskTemplateDTO create(TaskTemplate resources) {
59 TaskTemplateRepository.save(resources); 44 TaskTemplate taskTemplate = this.taskTemplateRepository.save(resources);
45 return this.taskTemplateMapper.toDto(taskTemplate);
60 } 46 }
61 47
62 @Override 48 @Override
63 @Transactional(rollbackFor = Exception.class) 49 @Transactional(rollbackFor = Exception.class)
64 public void update(TaskTemplate resources) { 50 public TaskTemplateDTO update(TaskTemplate resources) {
65 TaskTemplate TaskTemplate = TaskTemplateRepository.findById(resources.getId()).orElseGet(com.topdraw.business.module.task.template.domain.TaskTemplate::new); 51 TaskTemplate taskTemplate = this.taskTemplateRepository.findById(resources.getId()).orElseGet(TaskTemplate::new);
66 ValidationUtil.isNull( TaskTemplate.getId(),"TaskTemplate","id",resources.getId()); 52 ValidationUtil.isNull(taskTemplate.getId(),"TaskTemplate","id",resources.getId());
67 TaskTemplate.copy(resources); 53 taskTemplate.copy(resources);
68 TaskTemplateRepository.save(TaskTemplate); 54 TaskTemplate template = this.taskTemplateRepository.save(taskTemplate);
55 return this.taskTemplateMapper.toDto(template);
69 } 56 }
70 57
71 @Override 58 @Override
72 @Transactional(rollbackFor = Exception.class) 59 @Transactional(rollbackFor = Exception.class)
73 public void delete(Long id) { 60 public void delete(Long id) {
74 Assert.notNull(id, "The given id must not be null!"); 61 Assert.notNull(id, "The given id must not be null!");
75 TaskTemplate TaskTemplate = TaskTemplateRepository.findById(id).orElseThrow( 62 this.taskTemplateRepository.updateDeleteMark(id);
76 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", com.topdraw.business.module.task.template.domain.TaskTemplate.class, id), 1));
77 TaskTemplateRepository.delete(TaskTemplate);
78 } 63 }
79 64
80 65
81 @Override 66 @Override
82 public TaskTemplateDTO getByCode(String code) { 67 public TaskTemplateDTO findByCode(String code) {
83 return StringUtils.isNotEmpty(code) ? TaskTemplateMapper.toDto(TaskTemplateRepository.findFirstByCode(code).orElseGet(TaskTemplate::new)) 68 return StringUtils.isNotEmpty(code) ? this.taskTemplateMapper.toDto(this.taskTemplateRepository.findFirstByCode(code).orElseGet(TaskTemplate::new))
84 : new TaskTemplateDTO(); 69 : new TaskTemplateDTO();
85 } 70 }
86 71
87 72
88 @Override 73 @Override
89 public TaskTemplate findByEvent(String event) { 74 public TaskTemplateDTO findByEvent(String event) {
90 return StringUtils.isNotEmpty(event) ? this.TaskTemplateRepository.findByEvent(event) : null; 75 return StringUtils.isNotEmpty(event) ? this.taskTemplateMapper.toDto(this.taskTemplateRepository.findByEvent(event)) : null;
91 } 76 }
92 77
93 // @Cacheable(cacheNames = "uc-admin_taskTemplate" , key = "#event")
94 @Override 78 @Override
95 public List<TaskTemplate> findByType(Integer event) { 79 public TaskTemplateDTO findByType(Integer event) {
96 return Objects.nonNull(event) ? this.TaskTemplateRepository.findByType(event) : null; 80 return Objects.nonNull(event) ? this.taskTemplateMapper.toDto(this.taskTemplateRepository.findByType(event)) : null;
97 } 81 }
98 } 82 }
......
1 package com.topdraw.business.process.service;
2
3
4 public interface TaskOperationService {
5
6 }
1 package com.topdraw.business.process.service;
2
3
4 import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO;
5
6 /**
7 * @description 权益操作接口
8 * @author XiangHan
9 * @date 2021.10.22
10 */
11 public interface TaskTemplateOperationService {
12
13
14 TaskTemplateDTO findByCode(String code);
15 }
1 package com.topdraw.business.process.service.impl;
2
3 import com.topdraw.business.module.task.attribute.domain.TaskAttr;
4 import com.topdraw.business.module.task.attribute.service.TaskAttrService;
5 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
6 import com.topdraw.business.module.task.domain.Task;
7 import com.topdraw.business.module.task.service.TaskService;
8 import com.topdraw.business.module.task.service.dto.TaskDTO;
9 import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO;
10 import com.topdraw.business.process.service.TaskOperationService;
11 import com.topdraw.business.process.service.TaskTemplateOperationService;
12 import lombok.extern.slf4j.Slf4j;
13 import org.apache.commons.lang3.StringUtils;
14 import org.springframework.beans.BeanUtils;
15 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.stereotype.Service;
17
18 import java.util.Objects;
19
20 /**
21 * @author :
22 * @description:
23 * @function :
24 * @date :Created in 2022/4/25 15:48
25 * @version: :
26 * @modified By:
27 * @since : modified in 2022/4/25 15:48
28 */
29 @Service
30 @Slf4j
31 public class TaskOperationServiceImpl implements TaskOperationService {
32
33 @Autowired
34 private TaskService taskService;
35 @Autowired
36 private TaskAttrService taskAttrService;
37 @Autowired
38 private TaskTemplateOperationService taskTemplateOperationService;
39
40 public void asyncCreateTask(Task task) {
41 String taskTemplateCode = task.getTaskTemplateCode();
42 TaskTemplateDTO taskTemplateDTO = this.taskTemplateOperationService.findByCode(taskTemplateCode);
43 Long id = taskTemplateDTO.getId();
44 task.setTaskTemplateId(id);
45 this.create(task);
46 }
47
48 private void create(Task task) {
49 String code = task.getCode();
50 TaskDTO taskDTO = this.findByCode(code);
51 if (Objects.isNull(taskDTO.getId())) {
52 TaskDTO taskDTO_ = this.taskService.create(task);
53 if (Objects.nonNull(taskDTO_.getId())) {
54 task.setId(taskDTO_.getId());
55 this.createTaskAttr(task);
56 }
57 }
58 }
59
60 /**
61 *
62 * @param task_
63 */
64 private void createTaskAttr(Task task_) {
65 TaskAttr taskAttr = new TaskAttr();
66 taskAttr.setAttrStr(task_.getAttr());
67 taskAttr.setTaskId(task_.getId());
68 this.taskAttrService.create(taskAttr);
69 }
70
71 public void asyncUpdateTask(Task task) {
72 String code = task.getCode();
73 TaskDTO taskDTO = this.findByCode(code);
74 if (Objects.nonNull(taskDTO.getId())) {
75 Long id = taskDTO.getId();
76 task.setId(id);
77
78 String taskTemplateCode = task.getTaskTemplateCode();
79 TaskTemplateDTO taskTemplateDTO = this.taskTemplateOperationService.findByCode(taskTemplateCode);
80 Long templateId = taskTemplateDTO.getId();
81 task.setTaskTemplateId(templateId);
82 TaskDTO update = this.update(task);
83 if (Objects.nonNull(update)) {
84 this.updateTaskAttr(task);
85 }
86 }
87
88 }
89
90 /**
91 *
92 * @param task_
93 */
94 private void updateTaskAttr(Task task_) {
95
96 TaskAttrDTO taskAttrDTO = this.findTaskAttrByTaskId(task_.getId());
97 if (Objects.nonNull(taskAttrDTO.getId())) {
98 TaskAttr taskAttr = new TaskAttr();
99 BeanUtils.copyProperties(taskAttrDTO, taskAttr);
100 taskAttr.setAttrStr(task_.getAttr());
101 this.taskAttrService.update(taskAttr);
102 }
103
104 }
105
106 private TaskAttrDTO findTaskAttrByTaskId(Long taskId) {
107 return this.taskAttrService.findByTaskId(taskId);
108 }
109
110 private TaskDTO update(Task task) {
111 return this.taskService.update(task);
112 }
113
114 public void asyncDeleteTask(Task task) {
115 String code = task.getCode();
116 TaskDTO taskDTO = this.findByCode(code);
117 if (Objects.nonNull(taskDTO.getId())) {
118
119 Long id = taskDTO.getId();
120 task.setId(id);
121 this.delete(task);
122
123 }
124
125 }
126
127 private void delete(Task task) {
128 this.taskService.delete(task);
129 }
130
131 private TaskDTO findByCode(String code){
132 TaskDTO taskDTO = this.taskService.findByCode(code);
133 return taskDTO;
134 }
135
136 }
1 package com.topdraw.business.process.service.impl;
2
3 import com.topdraw.business.module.task.template.domain.TaskTemplate;
4 import com.topdraw.business.module.task.template.service.TaskTemplateService;
5 import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO;
6 import com.topdraw.business.process.service.TaskTemplateOperationService;
7 import lombok.extern.slf4j.Slf4j;
8 import org.springframework.beans.BeanUtils;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.stereotype.Service;
11
12 import java.util.Objects;
13
14
15 /**
16 * @author :
17 * @description:
18 * @function :
19 * @date :Created in 2022/4/25 22:27
20 * @version: :
21 * @modified By:
22 * @since : modified in 2022/4/25 22:27
23 */
24 @Service
25 @Slf4j
26 public class TaskTemplateOperationServiceImpl implements TaskTemplateOperationService {
27
28 @Autowired
29 private TaskTemplateService taskTemplateService;
30
31 public void asyncCreate(TaskTemplate resources) {
32 this.create(resources);
33 }
34
35 public void asyncUpdate(TaskTemplate resources) {
36 this.update(resources);
37 }
38
39 public void asyncDelete(TaskTemplate resources) {
40 this.delete(resources);
41 }
42
43 private void create(TaskTemplate resources) {
44 String code = resources.getCode();
45 TaskTemplateDTO taskTemplateDTO = this.findByCode(code);
46 if (Objects.isNull(taskTemplateDTO.getId())) {
47 this.taskTemplateService.create(resources);
48 }
49
50 }
51
52 private void update(TaskTemplate resources) {
53 String code = resources.getCode();
54 TaskTemplateDTO taskTemplateDTO = this.findByCode(code);
55 if (Objects.nonNull(taskTemplateDTO.getId())) {
56 Long id = taskTemplateDTO.getId();
57 resources.setId(id);
58 this.taskTemplateService.update(resources);
59 }
60 }
61
62 private void delete(TaskTemplate resources) {
63 String code = resources.getCode();
64 TaskTemplateDTO taskTemplateDTO = this.findByCode(code);
65 if (Objects.nonNull(taskTemplateDTO.getId())) {
66 Long id = taskTemplateDTO.getId();
67 this.taskTemplateService.delete(id);
68 }
69 }
70
71 private void delete(Long id) {
72 TaskTemplateDTO taskTemplateDTO = this.findById(id);
73 this.taskTemplateService.delete(id);
74
75 TaskTemplate taskTemplate = new TaskTemplate();
76 BeanUtils.copyProperties(taskTemplateDTO, taskTemplate);
77 taskTemplate.setDeleteMark(1);
78 }
79
80 @Override
81 public TaskTemplateDTO findByCode(String code) {
82 return this.taskTemplateService.findByCode(code);
83 }
84
85
86 private TaskTemplateDTO findById(Long id) {
87 return this.taskTemplateService.findById(id);
88 }
89
90 }
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <configuration scan="true" scanPeriod="60 seconds" debug="false"> 2 <configuration scan="true" scanPeriod="60 seconds" debug="false">
3 3
4 <contextName>UserCenter</contextName> 4 <contextName>uc-consumer</contextName>
5 <!--定义参数,后面可以通过${app.name}使用--> 5 <!--定义参数,后面可以通过${app.name}使用-->
6 <property name="app.name" value="member-engine"/> 6 <property name="app.name" value="uc-consumer"/>
7 <property name="log.path" value="./logs"/> 7 <property name="log.path" value="./logs"/>
8 <property name="log.pattern" value="%d [%thread] %-5level %logger{36} [%file : %line] - %msg%n"/> 8 <property name="log.pattern" value="%d [%thread] %-5level %logger{36} [%file : %line] - %msg%n"/>
9 9
......