当前位置: 首页 > news >正文

网站建设策划书网站发布与推广wordpress打开很慢

网站建设策划书网站发布与推广,wordpress打开很慢,资源网搭建源码,seo文章优化技巧今天主要完成了#xff1a; 新增棋子分类 棋子分类列表 获取棋子分类详情 更新棋子分类 更新棋子分类和添加棋子分类_分组校验 新增棋子 新增棋子参数校验 棋子分类列表查询(条件分页) 先给出分类实体类 Data public class Category {private Integer id;//主键IDNot…今天主要完成了 新增棋子分类 棋子分类列表 获取棋子分类详情 更新棋子分类 更新棋子分类和添加棋子分类_分组校验 新增棋子 新增棋子参数校验 棋子分类列表查询(条件分页) 先给出分类实体类 Data public class Category {private Integer id;//主键IDNotEmptyprivate String categoryName;//分类名称(赛季全名)NotEmptyprivate String categoryAlias;//分类别名(赛季版本号)private Integer createUser;//创建人IDprivate LocalDateTime createTime;//创建时间private LocalDateTime updateTime;//更新时间 }新增棋子分类 接口文档 读接口文档需求就是一个Insert但是发现接口文档没有考虑到可能会有重复分类的创建我认为重复分类的创建是不合适的所以我做了一个分类存在检测以防止重复分类的出现 基本属于User新建的小修小改直接上代码 Controller层 PostMappingpublic Result add(RequestBody Validated Category category){String init_name category.getCategoryName();Category incategory categoryService.getCategoryByNAME(init_name);if (incategory null){ categoryService.add(category);return Result.success();} else {return Result.error(棋子分类已存在);}} 写了一个条件判断来防止重复分类的出现用json里给的分类名查分类是否存在 Service层 Overridepublic void add(Category category) {MapString,Object map ThreadLocalUtil.get();Integer id (Integer) map.get(id);category.setCreateTime(LocalDateTime.now());category.setUpdateTime(LocalDateTime.now());category.setCreateUser(id);categoryMapper.add(category);}Overridepublic Category getCategoryByNAME(String init_name) {Category c categoryMapper.getCategoryByNAME(init_name);return c;} 一个新增一个查询为了达成给分类写入创建人相关信息还是老方法从ThreadLocal里面取 Mapper层 Insert(insert into category(category_name,category_alias,create_user,create_time,update_time) values(#{categoryName},#{categoryAlias},#{createUser},#{createTime},#{updateTime}) )void add(Category category);Select(Select * from category where category_name #{init_name})Category getCategoryByNAME(String init_name); 搞定 棋子分类列表 接口文档 可以看到这次不需要接入任何参数返回的是一个棋子分类列表区别不大开搞 ps:突然发现接口文档要求的时间格式跟直接捞出来的localdatatime格式不一样这是个问题 Controller层 GetMappingpublic ResultListCategory list(){ListCategory categoryList categoryService.list();return Result.success(categoryList);} Service层 Overridepublic ListCategory list() {MapString,Object map ThreadLocalUtil.get();Integer id (Integer) map.get(id);return categoryMapper.list(id);} 老规矩ThreadLocal拿用户信息  Mapper层 Select(select * from category where create_user #{id})ListCategory list(Integer id); 解决给出时间格式需修改问题  在实体类中用 JsonFormat接口 private LocalDateTime createTime;//创建时间JsonFormat(pattern TIME_REGEXP)private LocalDateTime updateTime;//更新时间 RT相应的也更新了我的正则文件 public static final String TIME_REGEXP ^yyyy-MM-dd HH:mm:ss; 搞定收工  获取棋子分类详情 接口文档 阅读接口文档通过分类ID获取分类全部信息再多考虑下非法ID输入就行 Controller层 GetMapping(detail)public ResultCategory getDetail(Integer id){Category category categoryService.getCategoryByID(id);if (category null){return Result.error(查询分类不存在);}else {return Result.success(category);}} 做了个简单逻辑判断来确保查询的分类是存在的  Service层 Overridepublic Category getCategoryByID(Integer init_ID) {return categoryMapper.getCategoryByID(init_ID);} Mapper层 Select(Select * from category where id #{init_ID})Category getCategoryByID(Integer init_ID); 顺手修改下新增棋子接口 由于这个按ID查询棋子和新增棋子接口用的按分类名查询实际上效果一样为了提高代码复用率把新增棋子接口的查询直接改成按ID查询如下 PostMappingpublic Result add(RequestBody Validated Category category){Integer init_ID category.getId();Category incategory categoryService.getCategoryByID(init_ID);if (incategory null){ categoryService.add(category);return Result.success();} else {return Result.error(棋子分类已存在);}} 别忘了删除其他基层的按分类名查询  更新棋子分类 接口文档 读接口文档注意下参数校验和身份验证就行 先看Controller层 PutMappingpublic Result update(RequestBody Validated Category incategory){Category category categoryService.getCategoryByID(incategory.getId());if (category null){return Result.error(要修改的分类不存在);}else {Integer userID category.getCreateUser();MapString,Object map ThreadLocalUtil.get();Integer id_user (Integer) map.get(id);if (userID.equals(id_user)){categoryService.update(incategory);return Result.success();}else {return Result.error(您所要更改的分类不属于您);}}} 先对要更改的分类存不存在进行验证如果存在在进行身份验证都验证通过了就可以进行修改操作了 Service层 Overridepublic void update(Category category) {category.setUpdateTime(LocalDateTime.now());categoryMapper.update(category);} Mapper层 Update(update category set category_name #{categoryName} , category_alias #{categoryAlias} , update_time #{updateTime} where id #{id})void update(Category category); 对了要在实体类中给id加一个NotNull注解来验证 NotNullprivate Integer id;//主键ID 搞定收工  更新棋子分类和添加棋子分类_分组校验 由于我们在刚刚写修改棋子分类的时候给ID加上了notnull的注解导致了在每次检验CateGory对象的时候都会检验id是否为null而我们在写新增分类的时候由于id是会自增的所以我们并没有传入棋子id。这时刚刚的更改会导致新增分类接口无法正常使用为了解决这个问题我们就要用到分组校验 分组校验 把校验项进行归类分组在完成不同功能的时候校验指定组中的校验项 步骤 1.定义分组 使用接口来定义分组 例如我们要给category加add和update两个分组我们就可以在其实体类中定义如下两个分组 public interface Add{}public interface Update{} 2.定义校验项时指定归属的分组 如下例 NotNull(groups Update.class)private Integer id;//主键IDNotEmpty(groups {Update.class,Add.class})private String categoryName;//分类名称NotEmpty(groups {Update.class,Add.class})private String categoryAlias;//分类别名 可以看到分组可以同时指定多个用{}来承接  3.校验时指定要校验的分组 public Result add(RequestBody Validated(Category.Add.class) Category category){public Result update(RequestBody Validated(Category.Update.class) Category incategory){ 小优化 校验分组存在如下两条规则 1.如果某个校验项没有指定分组则默认属于Defult分组 2.分组之间可以继承A extends B则A中继承B中所有的校验项目 那么我们可以对上例进行如下优化 我们可以看到add和update的唯一区别就是对于ID非空的检验所以我们可以让其他所有校验直接进入Defult组并让我们自定义的两个分组都继承Defult组add独立的划入对于ID的飞控检查 Data public class Category {NotNull(groups Update.class)private Integer id;//主键IDNotEmptyprivate String categoryName;//分类名称NotEmptyprivate String categoryAlias;//分类别名private Integer createUser;//创建人IDJsonFormat(pattern TIME_REGEXP)private LocalDateTime createTime;//创建时间JsonFormat(pattern TIME_REGEXP)private LocalDateTime updateTime;//更新时间public interface Add extends Default {}public interface Update extends Default {}
http://www.pierceye.com/news/758389/

相关文章:

  • 网页界面设计评分标准东营网站关键字优化
  • 手表网站背景素材玉山网站建设
  • 增城新塘网站建设温州网站推广效果
  • 东莞市住房建设局网站编程能干什么
  • asp做一个简单网站推广图片素材
  • 新网站一直不被收录wordpress 视频 广告
  • 网站建设费账务处理一个小胖子从网站做任务的网站故事
  • 国外被墙网站东营建设信息网最新消息
  • iphone下载网页视频北京百度seo排名公司
  • 怎么自己做网站免费的衡阳seo网站推广
  • 一键生成论文的网站做亚马逊有哪些网站可以清货
  • 一屏网站模板下载 迅雷下载 迅雷下载地址网站建设合并但与那个
  • 营销型网站四大功能吉林市网站制作
  • 如何制作钓鱼网站网页制作基础教程9787121095306教案
  • 专业定制网站企业吉林省住房城乡建设厅网站首页
  • 免费高清素材网站方维网络科技有限公司
  • 长春行业网站重庆智能建站模板
  • 北湖区网站建设公司wordpress的cute主题
  • 沈阳网站建设 景乔科技网站制作杭州
  • 网站维护工程师月薪多少精品网站建设公
  • 永久免费企业网站申请网站开发主框架一般用什么布局
  • 网站做非经营性广告需备案python免费看电影的应用
  • 网站分哪些种类自己做网站模版
  • 汪峰做的音乐网站长沙制作公园仿竹护栏实体厂家
  • 深圳专业网站建设公司排名好的h5网站模板
  • h5做网站教程网店营销的推广方法有哪些
  • 网站关键词快速排名工具wordpress子主题
  • 做百度网站那家好google 网站质量问题
  • 网站建设维护书网站资料清单
  • 网站建设公司 深圳信科网站维护计划