6 changed files with 111 additions and 51 deletions
-
51sql/demo.sql
-
36src/main/java/com/qyft/gd/controller/directive/DirectiveController.java
-
32src/main/java/com/qyft/gd/enums/DirectiveTypeEnum.java
-
16src/main/java/com/qyft/gd/model/dto/directive/DirectiveDto.java
-
9src/main/java/com/qyft/gd/service/DirectiveService.java
-
18src/main/java/com/qyft/gd/service/impl/DirectiveServiceImpl.java
@ -0,0 +1,36 @@ |
|||
package com.qyft.gd.controller.directive; |
|||
|
|||
import com.qyft.gd.model.dto.directive.DirectiveDto; |
|||
import com.qyft.gd.service.DirectiveService; |
|||
import com.qyft.gd.system.common.result.Result; |
|||
import com.qyft.gd.system.service.UserService; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import jakarta.annotation.Resource; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* 指令控制器 |
|||
*/ |
|||
@Tag(name = "指令") |
|||
@RestController |
|||
@RequestMapping("/api/directive") |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class DirectiveController { |
|||
|
|||
@Resource |
|||
private DirectiveService directiveService; |
|||
|
|||
@Operation(summary = "发送指令") |
|||
@PostMapping("/sendDirective") |
|||
public Result<String> sendDirective(@RequestBody DirectiveDto dto) { |
|||
directiveService.sendDirective(dto); |
|||
return Result.success(); |
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.qyft.gd.enums; |
|||
|
|||
import cn.hutool.core.util.StrUtil; |
|||
|
|||
public enum DirectiveTypeEnum { |
|||
ADD("add", "抬起托盘"); |
|||
|
|||
private final String typeCode; |
|||
private final String typeName; |
|||
DirectiveTypeEnum(String typeCode, String typeName) { |
|||
this.typeCode = typeCode; |
|||
this.typeName = typeName; |
|||
} |
|||
|
|||
public String typeCode() { |
|||
return typeCode; |
|||
} |
|||
public String typeName() { |
|||
return typeName; |
|||
} |
|||
|
|||
public static String getByCode(String code) { |
|||
if (StrUtil.isNotBlank(code)) { |
|||
for (DirectiveTypeEnum item : DirectiveTypeEnum.values()) { |
|||
if (item.typeCode().equals(code.trim())) { |
|||
return item.typeCode(); |
|||
} |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.qyft.gd.model.dto.directive; |
|||
|
|||
import com.qyft.gd.enums.DirectiveTypeEnum; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Schema(name = "指令数据") |
|||
@Data |
|||
public class DirectiveDto { |
|||
|
|||
@Schema(description = "指令类型") |
|||
private DirectiveTypeEnum type; |
|||
|
|||
@Schema(description = "指令配置") |
|||
private String option; |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.qyft.gd.service; |
|||
|
|||
|
|||
import com.qyft.gd.model.dto.directive.DirectiveDto; |
|||
|
|||
public interface DirectiveService { |
|||
|
|||
void sendDirective(DirectiveDto dto); |
|||
} |
@ -0,0 +1,18 @@ |
|||
package com.qyft.gd.service.impl; |
|||
|
|||
import com.qyft.gd.model.dto.directive.DirectiveDto; |
|||
import com.qyft.gd.service.DirectiveService; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* 指令实现类 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class DirectiveServiceImpl implements DirectiveService { |
|||
@Override |
|||
public void sendDirective(DirectiveDto dto) { |
|||
// 发送指令 |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue