Ejemplo n.º 1
0
        [HttpPost]                                                               //新增
        public ActionResult <ResponseJson> Post([FromBody] Models.cm_menu model) //新建保存
        {
            ResponseJson json = new ResponseJson();

            if (!service.Insert(model))
            {
                json.Code = "500";
                json.Msg  = $"增加[角色:{model.name}]失败!";
            }
            return(json);
        }
Ejemplo n.º 2
0
        [HttpPut("{id}")]                                                                //修改
        public ActionResult <ResponseJson> Put(long id, [FromBody] Models.cm_menu model) //编辑方法
        {
            ResponseJson json = new ResponseJson();
            bool         flag = false;

            if (service.Exists(id))
            {
                model.id = id;
                flag     = service.Update(model);
            }
            if (!flag)
            {
                json.Code = "500";
                json.Msg  = "修改失败!";
            }
            return(json);
        }