//CategoryCOntroller
@GetMapping
public Result<List<Category>> list(){
List<Category> cs = categoryService.list();
return Result.success(cs);
}
//Service
List<Category> list();
//ServiceImpl
@Override
public List<Category> list() {
Map<String,Object> map = ThreadLocalUtil.get();
Integer userId = (Integer) map.get("id");
return categoryMapper.list(userId);
}
//mapper
@Select("select * from category where create_user = #{userId}")
List<Category> list(Integer userId);
//pojo
package com.di.bigevent.pojo;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class Category {
private Integer id;//主键ID
@NotEmpty
private String categoryName;//分类名称
@NotEmpty
private String categoryAlias;//分类别名
private Integer createUser;//创建人ID
@JsonFormat(pattern = "yyyy-HH-dd HH:mm:ss")
private LocalDateTime createTime;//创建时间
@JsonFormat(pattern = "yyyy-HH-dd HH:mm:ss")
private LocalDateTime updateTime;//更新时间
}
标签:21,userId,list,private,列表,2024,HH,import,Integer
From: https://www.cnblogs.com/muzhaodi/p/18088282