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

怎样建网站才赚钱wordpress自动采集插件怎么用

怎样建网站才赚钱,wordpress自动采集插件怎么用,wordpress的ping列表,静态网站代做1.1.1 实体类id增加NotNull注释,并做分组校验 1.1.1.1 定义分组 1.1.1.2 实体类中指定校验项属于哪个分组 如果说某个校验项没有指定分组,默认属于Default分组 分组之间可以继承, A extends B 那么A中拥有B中所有的校验项package com.geji.pojo;import com.faste…

1.1.1 实体类id增加NotNull注释,并做分组校验

1.1.1.1 定义分组

1.1.1.2 实体类中指定校验项属于哪个分组

如果说某个校验项没有指定分组,默认属于Default分组
分组之间可以继承, A extends B  那么A中拥有B中所有的校验项
package com.geji.pojo;import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.groups.Default;
import lombok.Data;import java.time.LocalDateTime;@Data
public class Category {@NotNull(groups = Update.class)private Integer id;//主键ID@NotEmpty(groups={Add.class,Update.class})private String categoryName;//分类名称@NotEmpty(groups={Add.class,Update.class})private String categoryAlias;//分类别名private Integer createUser;//创建人ID@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")private LocalDateTime createTime;//创建时间@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")private LocalDateTime updateTime;//更新时间//如果说某个校验项没有指定分组,默认属于Default分组//分组之间可以继承, A extends B  那么A中拥有B中所有的校验项public interface Add extends Default {}public interface Update extends Default {}
}

1.1.1.3 Controller中指定校验分组

package com.geji.controller;import com.geji.pojo.Category;
import com.geji.pojo.Result;
import com.geji.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;import java.util.List;@RestController
@RequestMapping("/category")
public class CategoryController {@Autowiredprivate CategoryService categoryService;@PostMappingpublic Result add(@RequestBody @Validated(Category.Add.class) Category category) {categoryService.add(category);return Result.success();}@GetMappingpublic Result<List<Category>> list(){List<Category> cs = categoryService.list();return Result.success(cs);}@GetMapping("/detail")public Result<Category> detail(Integer id){Category c = categoryService.findById(id);return Result.success(c);}@PutMappingpublic Result update(@RequestBody @Validated(Category.Update.class) Category category){categoryService.update(category);return Result.success();}}

1.1.2 Service

package com.geji.service;import com.geji.pojo.Category;import java.util.List;public interface CategoryService {void add(Category category);List<Category> list();Category findById(Integer id);void update(Category category);
}

1.1.3 ServiceImpl

package com.geji.service.impl;import com.geji.mapper.CategoryMapper;
import com.geji.pojo.Category;
import com.geji.service.CategoryService;
import com.geji.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;@Service
public class CategoryServiceImpl implements CategoryService {@Autowiredprivate CategoryMapper categoryMapper;@Overridepublic void add(Category category) {//补充属性值category.setCreateTime(LocalDateTime.now());category.setUpdateTime(LocalDateTime.now());Map<String,Object> map = ThreadLocalUtil.get();Integer userId = (Integer) map.get("id");category.setCreateUser(userId);categoryMapper.add(category);}@Overridepublic List<Category> list() {Map<String,Object> map = ThreadLocalUtil.get();Integer userId = (Integer) map.get("id");return categoryMapper.list(userId);}@Overridepublic Category findById(Integer id) {Category c = categoryMapper.findById(id);return c;}@Overridepublic void update(Category category) {category.setUpdateTime(LocalDateTime.now());categoryMapper.update(category);}}

1.1.4 Mapper

package com.geji.mapper;import com.geji.pojo.Category;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;import java.util.List;@Mapper
public interface CategoryMapper {//新增@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 create_user = #{userId}")List<Category> list(Integer userId);//根据id查询@Select("select * from category where id = #{id}")Category findById(Integer id);//更新@Update("update category set category_name=#{categoryName},category_alias=#{categoryAlias},update_time=#{updateTime} where id=#{id}")void update(Category category);}

1.1.5 postman测试

http://www.yayakq.cn/news/554832/

相关文章:

  • 做网站工资高么建设网站的必要与可行性
  • 网站建设的重要性南通市住房和建设局网站
  • 网站开发师wordpress 安全狗
  • flask 网站开发wordpress直链视频
  • 城市建设与管理网站wordpress10和3优先级
  • 网站备案跟网安备案区别wordpress预订插件
  • 网站建设需解决问题中国检验认证集团北京有限公司
  • 手表网站那个好丹东建设网官方网站
  • 小企业做网站多少钱网站建设百科
  • 免域名x网站临沂市建设局网站勘察设计
  • 广州网站建设c2c海口省建设厅网站
  • 衡阳外贸网站设计上海网站建设公司联系方式
  • 松江品划网站建设推广做那个网站的图客比较好
  • dj网站模板免费下载目前流行的网站开发工具
  • 做电影网站要不要收费现在手机网站设计
  • 做移动网站快速排企点
  • 网站建设优化兰州淘宝客网站怎么做推广计划
  • 做企业网站设计北京app定制公司
  • 企业网站建站费用如何查询网站开发商
  • 设计师学编程能自己做网站吗企业策划书ppt
  • 怎么查一个公司是否正规合肥网站seo优化排名公司
  • 校园网站建设初探珠海网站建设培训学校
  • 南宁律师网站建设枣庄网站开发
  • 企业做网站乐云seo快速上线yahoo网站提交
  • 哪个网站可以做卖房公众号登陆
  • 网站建设沧州网站做营销推广公司
  • 一键网站提交广告公司接单软件
  • 免费网站知乎深圳做购物网站
  • 网站计数器代码js网站建设费如何核算
  • 做网站需要租服务器seo排名的影响因素有哪些