feat(controller): 优化发送消息接口的消息类型处理
- 引入IDictionaryItemService以动态获取消息类型ID - 在发送消息时校验消息类型ID是否存在,异常时抛出业务错误 - 替换固定消息类型ID为动态获取的ID,提高灵活性和可维护性 - 导入VUtil工具类用于抛出业务异常 - 添加必要的import语句和@Resource注入装配新服务
This commit is contained in:
parent
26bbb7275f
commit
edda75ff02
|
|
@ -4,7 +4,9 @@ import com.nflg.qms.admin.service.BasdeSerialNumberControllerService;
|
|||
import com.nflg.qms.admin.service.ISendMessageService;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.common.util.VUtil;
|
||||
import com.nflg.wms.repository.entity.QmsTodoItem;
|
||||
import com.nflg.wms.repository.service.IDictionaryItemService;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -13,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 测试
|
||||
|
|
@ -28,15 +31,20 @@ public class TestController extends BaseController {
|
|||
@Resource
|
||||
private BasdeSerialNumberControllerService basdeSerialNumberControllerService;
|
||||
|
||||
@Resource
|
||||
private IDictionaryItemService dictionaryItemService;
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*/
|
||||
@GetMapping("/sendMessage")
|
||||
public ApiResult<Void> sendMessage() {
|
||||
Long dictionaryItemServiceId = dictionaryItemService.getId("消息类型", "COANotificationSent");
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(dictionaryItemServiceId)).throwMessage("消息类型不存在");
|
||||
QmsTodoItem qmsTodoItem = new QmsTodoItem()
|
||||
.setCode(basdeSerialNumberControllerService.generateSerialNumber(32))
|
||||
.setIsRead(false)
|
||||
.setSourceTypeId(2046157760401182721L)
|
||||
.setSourceTypeId(dictionaryItemServiceId)
|
||||
.setSourceId(0L)
|
||||
.setCreateUserId(UserUtil.getUserId())
|
||||
.setCreateUserName(UserUtil.getUserName())
|
||||
|
|
|
|||
Loading…
Reference in New Issue