MessageBusinessTypeController.java
2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package cn.fw.hermes.controller.erp;
import static cn.fw.common.web.util.ExceptionHandler.handleException;
import static cn.fw.common.web.util.ResultBuilder.failureWithMessage;
import static cn.fw.common.web.util.ResultBuilder.success;
import static cn.fw.hermes.common.constant.MessageStr.SAVE_FAILURE;
import cn.fw.data.base.domain.common.Message;
import cn.fw.hermes.domain.db.MessageBusinessType;
import cn.fw.hermes.service.biz.MessageBusinessTypeBizService;
import cn.fw.security.auth.client.annotation.Authorization;
import cn.fw.security.auth.client.annotation.IgnoreAuth;
import cn.fw.security.auth.client.enums.AuthType;
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;
/**
* @Author: Chenery
* @Date: 2021/2/3 16:00
*/
@RestController
@Slf4j
@RequestMapping("/erp/messageType")
@RequiredArgsConstructor
@Authorization(AuthType.ERP)
public class MessageBusinessTypeController {
private final MessageBusinessTypeBizService businessTypeBizService;
/**
* 添加单个消息业务类型
*
* @param messageBusinessType 消息业务类型对象
* @return 添加结果
*/
@PostMapping("/addOne")
@IgnoreAuth
public Message<Boolean> addMessageType(@RequestBody MessageBusinessType messageBusinessType) {
final String msg = "添加单个消息业务类型[/erp/messageType/addOne]";
try {
log.info("{}: param[{}]", msg, messageBusinessType);
Boolean result = businessTypeBizService.add(messageBusinessType);
return success(result, data -> log.info("{} 成功: result:[{}]", msg, result));
} catch (Exception ex) {
handleException(ex, e -> log.error("{} 失败: result:[{}]", msg, e));
return failureWithMessage(SAVE_FAILURE);
}
}
}