## 点击登为个人模板

- 弹出弹出框，显示"是否确认登为个人模板？"

- 用户点击确认，向后端发送网络请求

  - 后端接口对应代码为：
    ```java
    @Validated
    @RequiredArgsConstructor
    @RestController
    @RequestMapping("/parameter/basicPublicTemplate/enteralNutritionTemplate")
    public class EnteralNutritionTemplateController extends BaseController {
    
        private final IEnteralNutritionTemplateService enteralNutritionTemplateService;
    
        /**
         * 新增肠内处方模板
         */
        @SaCheckPermission("basicPublicTemplate:enteralNutritionTemplate:add")
        @Log(title = "肠内处方模板", businessType = BusinessType.INSERT)
        @RepeatSubmit()
        @PostMapping()
        public R<Void> add(@Validated(AddGroup.class) @RequestBody EnteralNutritionTemplateBo bo) {
            return toAjax(enteralNutritionTemplateService.insertByBo(bo));
        }
    }
    ```

  - `EnteralNutritionTemplateBo`:

    ```java
    @Data
    @EqualsAndHashCode(callSuper = true)
    @AutoMapper(target = EnteralNutritionTemplate.class, reverseConvertGenerate = false)
    public class EnteralNutritionTemplateBo extends BaseEntity {
    
        /**
         * ID
         */
        @NotNull(message = "ID不能为空", groups = { EditGroup.class })
        private Long id;
    
        /**
         * 模板名称
         */
        private String templateName;
    
        /**
         * 模板描述
         */
        private String templateDescription;
    
        /**
         * 处方类型
         */
        private String prescriptionType;
    
        /**
         * 处方科室ID
         */
        private Long prescriptionId;
    
        private String prescriptionDepartmentName;
    
        /**
         * 营养产品信息
         */
        private String content;
    
        /**
         * 状态（0正常 1停用）
         */
        private String status;
    
        /**
         * 删除标志（0代表存在 1代表删除）
         */
        private String delFlag;
    
        /**
         * 1、预包装处方模板
         * 2、配置处方模板
         * 3、长嘱处方模板
         */
        private Integer type;
    
        /**
         * 0、个人模板
         * 1、公共基础模板
         */
        private Integer templateType;
    
    }
    ```

  - `R`:

    ```java
    @Data
    @NoArgsConstructor
    public class R<T> implements Serializable {
    
        @Serial
        private static final long serialVersionUID = 1L;
    
        /**
         * 成功
         */
        public static final int SUCCESS = 200;
    
        /**
         * 失败
         */
        public static final int FAIL = 500;
    
        private int code;
    
        private String msg;
    
        private T data;
    
        public static <T> R<T> ok() {
            return restResult(null, SUCCESS, "操作成功");
        }
    
        public static <T> R<T> ok(T data) {
            return restResult(data, SUCCESS, "操作成功");
        }
    
        public static <T> R<T> ok(String msg) {
            return restResult(null, SUCCESS, msg);
        }
    
        public static <T> R<T> ok(String msg, T data) {
            return restResult(data, SUCCESS, msg);
        }
    
        public static <T> R<T> fail() {
            return restResult(null, FAIL, "操作失败");
        }
    
        public static <T> R<T> fail(String msg) {
            return restResult(null, FAIL, msg);
        }
    
        public static <T> R<T> fail(T data) {
            return restResult(data, FAIL, "操作失败");
        }
    
        public static <T> R<T> fail(String msg, T data) {
            return restResult(data, FAIL, msg);
        }
    
        public static <T> R<T> fail(int code, String msg) {
            return restResult(null, code, msg);
        }
    
        /**
         * 返回警告消息
         *
         * @param msg 返回内容
         * @return 警告消息
         */
        public static <T> R<T> warn(String msg) {
            return restResult(null, HttpStatus.WARN, msg);
        }
    
        /**
         * 返回警告消息
         *
         * @param msg 返回内容
         * @param data 数据对象
         * @return 警告消息
         */
        public static <T> R<T> warn(String msg, T data) {
            return restResult(data, HttpStatus.WARN, msg);
        }
    
        private static <T> R<T> restResult(T data, int code, String msg) {
            R<T> r = new R<>();
            r.setCode(code);
            r.setData(data);
            r.setMsg(msg);
            return r;
        }
    
        public static <T> Boolean isError(R<T> ret) {
            return !isSuccess(ret);
        }
    
        public static <T> Boolean isSuccess(R<T> ret) {
            return R.SUCCESS == ret.getCode();
        }
    }
    ```

- 其中`templateType`为个人模板

- `type`为当前选中的处方类型

- 根据后端返回的状态

  - 如果为`200`，则提示创建成功
  - 否则，提示异常信息