Beispiel #1
0
        public AdminNewsResp CNews([FromBody] AdminCNewsReq req)
        {
            AdminNewsResp resp = new AdminNewsResp();

            try
            {
                Fun.GetSqlConn().Execute($"update news set title = '{req.title}', detail = '{req.detail}' where id = {req.nid}");
            }
            catch (Exception ex)
            {
                resp.msg    = "未知错误" + ex.ToString();
                resp.status = -2;
                Console.WriteLine(resp.msg);
            }

            return(resp);
        }
Beispiel #2
0
        public AdminNewsResp News(int nid)
        {
            AdminNewsResp resp = new AdminNewsResp();

            try
            {
                Fun.GetSqlConn().Execute($"update news set is_active = false where id={nid}");
                resp.status = 0;
                resp.msg    = "ok";
            }
            catch (Exception ex)
            {
                resp.msg    = "未知错误" + ex.ToString();
                resp.status = -2;
                Console.WriteLine(resp.msg);
            }

            return(resp);
        }
Beispiel #3
0
        public AdminNewsResp News([FromBody] AdminNewsReq req)
        {
            AdminNewsResp resp = new AdminNewsResp();

            try
            {
                Fun.GetSqlConn().Execute($"insert into `news` (title, detail, create_time, is_active) values ('{req.title}', '{req.detail}', '{Fun.GetNowTimestampString()}', {1})");
                resp.status = 0;
                resp.msg    = "ok";
            }
            catch (Exception ex)
            {
                resp.msg    = "未知错误" + ex.ToString();
                resp.status = -2;
                Console.WriteLine(resp.msg);
            }

            return(resp);
        }