mirror of
https://gitee.com/270580156/weiyu.git
synced 2025-12-30 02:42:25 +00:00
update
This commit is contained in:
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-05-11 18:14:28
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-07-12 10:17:46
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
* 联系:270580156@qq.com
|
||||
* Copyright (c) 2024 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytedesk.core.base.BaseEntity;
|
||||
import com.bytedesk.core.constant.I18Consts;
|
||||
import com.bytedesk.core.constant.TypeConsts;
|
||||
import com.bytedesk.core.converter.StringListConverter;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Convert;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EntityListeners;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* Task entity for Kanban board task management
|
||||
* Represents individual tasks within a Kanban board system
|
||||
*
|
||||
* Database Table: bytedesk_plugin_kanban_task
|
||||
* Purpose: Stores task information, status, and organization within Kanban boards
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EntityListeners({TaskEntityListener.class})
|
||||
@Table(name = "bytedesk_plugin_kanban_task")
|
||||
public class TaskEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* Name or title of the task
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Description of the task
|
||||
*/
|
||||
@Builder.Default
|
||||
private String description = I18Consts.I18N_DESCRIPTION;
|
||||
|
||||
/**
|
||||
* Type of task (CUSTOMER, PROJECT, etc.)
|
||||
*/
|
||||
@Builder.Default
|
||||
@Column(name = "task_type")
|
||||
private String type = TaskTypeEnum.CUSTOMER.name();
|
||||
|
||||
/**
|
||||
* Color theme for the task display
|
||||
*/
|
||||
@Builder.Default
|
||||
@Column(name = "task_color")
|
||||
private String color = "red";
|
||||
|
||||
/**
|
||||
* Display order of the task within its todo list
|
||||
*/
|
||||
@Builder.Default
|
||||
@Column(name = "task_order")
|
||||
private int order = 0;
|
||||
|
||||
/**
|
||||
* Tags for task categorization and search
|
||||
*/
|
||||
@Builder.Default
|
||||
@Convert(converter = StringListConverter.class)
|
||||
@Column(columnDefinition = TypeConsts.COLUMN_TYPE_TEXT)
|
||||
private List<String> tagList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Whether the task has been completed
|
||||
*/
|
||||
@Builder.Default
|
||||
@Column(name = "task_complete")
|
||||
private boolean complete = false;
|
||||
|
||||
/**
|
||||
* Associated project UID for project-specific tasks
|
||||
*/
|
||||
private String projectUid;
|
||||
|
||||
/**
|
||||
* Associated module UID for module-specific tasks
|
||||
*/
|
||||
private String moduleUid;
|
||||
|
||||
/**
|
||||
* Associated todo list UID where this task belongs
|
||||
*/
|
||||
private String todoListUid;
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2025-02-25 09:52:34
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-03-08 10:48:29
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
*
|
||||
* Copyright (c) 2025 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import jakarta.persistence.PostPersist;
|
||||
import jakarta.persistence.PostUpdate;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TaskEntityListener {
|
||||
|
||||
@PostPersist
|
||||
public void onPostPersist(TaskEntity task) {
|
||||
log.info("onPostPersist: {}", task);
|
||||
}
|
||||
|
||||
@PostUpdate
|
||||
public void onPostUpdate(TaskEntity task) {
|
||||
log.info("onPostUpdate: {}", task);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2025-02-25 09:44:18
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-02-25 09:54:17
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
*
|
||||
* Copyright (c) 2025 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class TaskEventListener {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-08-01 06:18:10
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-03-03 23:09:02
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
* 联系:270580156@qq.com
|
||||
* Copyright (c) 2024 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* https://github.com/alibaba/easyexcel
|
||||
*/
|
||||
@Data
|
||||
public class TaskExcel {
|
||||
|
||||
@ExcelProperty(index = 0, value = "Name")
|
||||
@ColumnWidth(20)
|
||||
private String name;
|
||||
|
||||
@ExcelProperty(index = 1, value = "Type")
|
||||
@ColumnWidth(20)
|
||||
private String type;
|
||||
|
||||
@ExcelProperty(index = 2, value = "Color")
|
||||
@ColumnWidth(20)
|
||||
private String color;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-11-05 16:58:18
|
||||
* @LastEditors: jack ning github@bytedesk.com
|
||||
* @LastEditTime: 2025-03-08 10:32:22
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
* 联系:270580156@qq.com
|
||||
* Copyright (c) 2024 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task;
|
||||
|
||||
public class TaskPermissions {
|
||||
|
||||
public static final String TAG_PREFIX = "TAG_";
|
||||
// Task permissions
|
||||
public static final String TAG_CREATE = "hasAuthority('TAG_CREATE')";
|
||||
public static final String TAG_READ = "hasAuthority('TAG_READ')";
|
||||
public static final String TAG_UPDATE = "hasAuthority('TAG_UPDATE')";
|
||||
public static final String TAG_DELETE = "hasAuthority('TAG_DELETE')";
|
||||
public static final String TAG_EXPORT = "hasAuthority('TAG_EXPORT')";
|
||||
|
||||
//
|
||||
public static final String TAG_ANY = "hasAnyAuthority('TAG_CREATE', 'TAG_READ', 'TAG_UPDATE', 'TAG_EXPORT', 'TAG_DELETE')";
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-05-11 18:25:55
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2024-10-24 18:20:39
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
* 联系:270580156@qq.com
|
||||
* Copyright (c) 2024 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
public interface TaskRepository extends JpaRepository<TaskEntity, Long>, JpaSpecificationExecutor<TaskEntity> {
|
||||
|
||||
Optional<TaskEntity> findByUid(String uid);
|
||||
|
||||
// Boolean existsByPlatform(String platform);
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-05-11 18:26:04
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-07-12 10:18:22
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
* 联系:270580156@qq.com
|
||||
* Copyright (c) 2024 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bytedesk.core.base.BaseRequest;
|
||||
import com.bytedesk.core.constant.I18Consts;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TaskRequest extends BaseRequest {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
@Builder.Default
|
||||
private String description = I18Consts.I18N_DESCRIPTION;
|
||||
|
||||
// @Builder.Default
|
||||
// private String type = TaskTypeEnum.CUSTOMER.name();
|
||||
|
||||
@Builder.Default
|
||||
private String color = "red";
|
||||
|
||||
@Builder.Default
|
||||
private Integer order = 0;
|
||||
|
||||
@Builder.Default
|
||||
private List<String> tagList = new ArrayList<>();
|
||||
|
||||
// @Builder.Default
|
||||
// private String level = LevelEnum.ORGANIZATION.name();
|
||||
|
||||
// @Builder.Default
|
||||
// private String platform = PlatformEnum.BYTEDESK.name();
|
||||
|
||||
@Builder.Default
|
||||
private Boolean complete = false;
|
||||
|
||||
private String projectUid;
|
||||
|
||||
private String moduleUid;
|
||||
|
||||
private String todoListUid;
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-05-11 18:26:12
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-03-10 17:55:50
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
* 联系:270580156@qq.com
|
||||
* Copyright (c) 2024 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bytedesk.core.base.BaseResponse;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TaskResponse extends BaseResponse {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private String type;
|
||||
|
||||
private String color;
|
||||
|
||||
private Integer order;
|
||||
|
||||
private List<String> tagList;
|
||||
|
||||
private Boolean complete;
|
||||
|
||||
private String projectUid;
|
||||
|
||||
private String moduleUid;
|
||||
|
||||
private String todoListUid;
|
||||
|
||||
// private ZonedDateTime createdAt;
|
||||
|
||||
// private ZonedDateTime updatedAt;
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-05-11 18:25:36
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-08-20 16:58:37
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
* 联系:270580156@qq.com
|
||||
* Copyright (c) 2024 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bytedesk.core.base.BaseRestController;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/task")
|
||||
@AllArgsConstructor
|
||||
public class TaskRestController extends BaseRestController<TaskRequest, TaskRestService> {
|
||||
|
||||
private final TaskRestService taskService;
|
||||
|
||||
@Override
|
||||
protected TaskRestService getService() {
|
||||
return taskService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object export(TaskRequest request, HttpServletResponse response) {
|
||||
// TASK Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'export'");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-05-11 18:25:45
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-08-20 12:15:58
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
* 联系:270580156@qq.com
|
||||
* Copyright (c) 2024 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.orm.ObjectOptimisticLockingFailureException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.bytedesk.core.base.BaseRestService;
|
||||
import com.bytedesk.core.rbac.user.UserEntity;
|
||||
import com.bytedesk.core.uid.UidUtils;
|
||||
import com.bytedesk.kanban.todo_list.TodoListEntity;
|
||||
import com.bytedesk.kanban.todo_list.TodoListRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class TaskRestService extends BaseRestService<TaskEntity, TaskRequest, TaskResponse> {
|
||||
|
||||
private final TaskRepository taskRepository;
|
||||
private final TodoListRepository todoListRepository;
|
||||
private final ModelMapper modelMapper;
|
||||
private final UidUtils uidUtils;
|
||||
|
||||
// === 实现必需的抽象方法 ===
|
||||
|
||||
@Override
|
||||
protected Specification<TaskEntity> createSpecification(TaskRequest request) {
|
||||
return TaskSpecification.search(request, authService);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Page<TaskEntity> executePageQuery(Specification<TaskEntity> spec, Pageable pageable) {
|
||||
return taskRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Cacheable(value = "task", key = "#uid", unless = "#result == null")
|
||||
@Override
|
||||
public Optional<TaskEntity> findByUid(String uid) {
|
||||
return taskRepository.findByUid(uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskResponse convertToResponse(TaskEntity entity) {
|
||||
return modelMapper.map(entity, TaskResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskEntity doSave(TaskEntity entity) {
|
||||
return taskRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskEntity handleOptimisticLockingFailureException(ObjectOptimisticLockingFailureException e, TaskEntity entity) {
|
||||
try {
|
||||
Optional<TaskEntity> latest = taskRepository.findByUid(entity.getUid());
|
||||
if (latest.isPresent()) {
|
||||
TaskEntity latestEntity = latest.get();
|
||||
// 合并需要保留的数据
|
||||
modelMapper.map(entity, latestEntity);
|
||||
return taskRepository.save(latestEntity);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("无法处理乐观锁冲突: " + ex.getMessage(), ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// === 业务逻辑方法 ===
|
||||
|
||||
@Override
|
||||
public TaskResponse create(TaskRequest request) {
|
||||
UserEntity user = authService.getUser();
|
||||
|
||||
request.setUserUid(user.getUid());
|
||||
|
||||
TaskEntity entity = modelMapper.map(request, TaskEntity.class);
|
||||
entity.setUid(uidUtils.getUid());
|
||||
entity.setOrgUid(user.getOrgUid());
|
||||
|
||||
TaskEntity savedEntity = save(entity);
|
||||
if (savedEntity == null) {
|
||||
throw new RuntimeException("Create task failed");
|
||||
}
|
||||
|
||||
// 处理与TodoList的关联
|
||||
handleTodoListAssociation(request, savedEntity);
|
||||
|
||||
return convertToResponse(savedEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskResponse update(TaskRequest request) {
|
||||
Optional<TaskEntity> optional = taskRepository.findByUid(request.getUid());
|
||||
if (optional.isPresent()) {
|
||||
TaskEntity entity = optional.get();
|
||||
modelMapper.map(request, entity);
|
||||
//
|
||||
TaskEntity savedEntity = save(entity);
|
||||
if (savedEntity == null) {
|
||||
throw new RuntimeException("Update task failed");
|
||||
}
|
||||
return convertToResponse(savedEntity);
|
||||
} else {
|
||||
throw new RuntimeException("Task not found");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByUid(String uid) {
|
||||
Optional<TaskEntity> optional = taskRepository.findByUid(uid);
|
||||
if (optional.isPresent()) {
|
||||
optional.get().setDeleted(true);
|
||||
save(optional.get());
|
||||
} else {
|
||||
throw new RuntimeException("Task not found");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(TaskRequest request) {
|
||||
deleteByUid(request.getUid());
|
||||
}
|
||||
|
||||
// === 私有辅助方法 ===
|
||||
|
||||
/**
|
||||
* 处理与TodoList的关联关系
|
||||
*/
|
||||
private void handleTodoListAssociation(TaskRequest request, TaskEntity savedEntity) {
|
||||
if (request.getTodoListUid() != null) {
|
||||
Optional<TodoListEntity> todoListOptional = todoListRepository.findByUid(request.getTodoListUid());
|
||||
if (todoListOptional.isPresent()) {
|
||||
todoListOptional.get().getTasks().add(savedEntity);
|
||||
todoListRepository.save(todoListOptional.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-07-09 22:19:21
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-03-03 14:25:07
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
* 联系:270580156@qq.com
|
||||
* Copyright (c) 2024 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.bytedesk.core.base.BaseSpecification;
|
||||
import com.bytedesk.core.rbac.auth.AuthService;
|
||||
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class TaskSpecification extends BaseSpecification<TaskEntity, TaskRequest> {
|
||||
|
||||
public static Specification<TaskEntity> search(TaskRequest request, AuthService authService) {
|
||||
log.info("request: {}", request);
|
||||
return (root, query, criteriaBuilder) -> {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
predicates.addAll(getBasicPredicates(root, criteriaBuilder, request, authService));
|
||||
//
|
||||
if (StringUtils.hasText(request.getUserUid())) {
|
||||
predicates.add(criteriaBuilder.equal(root.get("userUid"), request.getUserUid()));
|
||||
}
|
||||
//
|
||||
return criteriaBuilder.and(predicates.toArray(new Predicate[0]));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-07-23 17:02:46
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2024-07-23 17:02:48
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
* 联系:270580156@qq.com
|
||||
* Copyright (c) 2024 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task;
|
||||
|
||||
public enum TaskTypeEnum {
|
||||
THREAD,
|
||||
CUSTOMER
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2025-02-25 09:59:29
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-02-25 10:00:34
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
*
|
||||
* Copyright (c) 2025 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task.event;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import com.bytedesk.kanban.task.TaskEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class TaskCreateEvent extends ApplicationEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private TaskEntity task;
|
||||
|
||||
public TaskCreateEvent(TaskEntity task) {
|
||||
super(task);
|
||||
this.task = task;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2025-02-25 12:31:16
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-02-25 12:31:19
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
*
|
||||
* Copyright (c) 2025 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task.event;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import com.bytedesk.kanban.task.TaskEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class TaskDeleteEvent extends ApplicationEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private TaskEntity task;
|
||||
|
||||
public TaskDeleteEvent(TaskEntity task) {
|
||||
super(task);
|
||||
this.task = task;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2025-02-25 09:59:29
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-02-25 10:01:00
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
*
|
||||
* Copyright (c) 2025 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kanban.task.event;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import com.bytedesk.kanban.task.TaskEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class TaskUpdateEvent extends ApplicationEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private TaskEntity task;
|
||||
|
||||
public TaskUpdateEvent(TaskEntity task) {
|
||||
super(task);
|
||||
this.task = task;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
@NonNullApi
|
||||
package com.bytedesk.kanban.task;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
@@ -18,7 +18,7 @@ import java.util.ArrayList;
|
||||
|
||||
import com.bytedesk.core.base.BaseEntity;
|
||||
import com.bytedesk.core.constant.I18Consts;
|
||||
import com.bytedesk.kanban.task.TaskEntity;
|
||||
import com.bytedesk.core.task.TaskEntity;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
|
||||
@@ -16,7 +16,7 @@ package com.bytedesk.kanban.todo_list;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytedesk.core.base.BaseResponse;
|
||||
import com.bytedesk.kanban.task.TaskResponse;
|
||||
import com.bytedesk.core.task.TaskResponse;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
||||
Reference in New Issue
Block a user