layui框架与SSM前后台交互的方法(2)

@GetMapping("/delCarouselById") public RecycleResult delCarouselById(HttpServletResponse response,@RequestParam("id") Integer id){ response.setHeader("Access-Control-Allow-Origin", "*"); cmsService.delCarouselById(id); return RecycleResult.ok(); } <delete> DELETE FROM carousel WHERE id = #{id} </delete>

补充LayuiReplay类(其中get、set方法省略)

public class LayuiReplay <T> { private int code; private String msg; private int count; private List<T> data; public LayuiReplay(int code, String msg, int count, List<T> data) { this.code = code; this.msg = msg; this.count = count; this.data = data; } public String toJson() { Gson gson = new Gson(); String json = gson.toJson(this); return json; } public static <T> String toJson(int count, List<T> data) { LayuiReplay<T> replay = new LayuiReplay<>(ReplyCode.OK.getCode(), ReplyCode.OK.getMessage(), count, data); return replay.toJson(); } }

补充ReplyCode.java枚举类

public enum ReplyCode { NOT_LOGIN(-1,"您尚未登录或登录时间过长,请重新登录或刷新页面!"), OK(0, "OK"), WRONG_URL(400,"请求路径错误"), WRONG_ROLE(401, "身份错误"), REQUEST_FAILED(500, "请求失败,请重试"), NULL_ATTR(30,"属性不能为空"), ATTR_WRONG(31, "属性填写错误"), WRONG_LENGTH(32, "数据长度不符合要求"), WRONG_PATTERN(33, "数据格式错误"), VAILD_WRONG(100,"验证码错误"), CUSTOM(999, "") ; ReplyCode(int code, String message) { this.code = code; this.message = message; } private int code; private String message; public int getCode() { return code; } public ReplyCode setCode(int code) { this.code = code; return this; } public String getMessage() { return message; } public ReplyCode setMessage(String message) { this.message = message; return this; } }

以上这篇layui框架与SSM前后台交互的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/a82b02958d60d9817d1bda333d183ff4.html