数据库表
按照categoryType进行条件查询
controller
@RestController
@RequestMapping("/product-category")
public class ProductCategoryController {
@Autowired
private ProductCategoryService productCategoryService;
@ApiOperation("按id查找")
@GetMapping("find/{categoryId}")
public ProductCategory findById(@PathVariable String categoryId){
ProductCategory byId = productCategoryService.getById(categoryId);
return byId;
}
@ApiOperation("按type查找")
@GetMapping("/find/{categoryType}")
public List<ProductCategory> findByType(@PathVariable List<Integer> categoryType) {
}
数据库sql
DROP TABLE IF EXISTS `product_category`;
CREATE TABLE `product_category` (
`category_id` int(0) NOT NULL AUTO_INCREMENT,
`category_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '类目名字',
`category_type` int(0) NOT NULL COMMENT '类目编号',
`create_time` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
PRIMARY KEY (`category_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '类目表' ROW_FORMAT = Dynamic;
实体类
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="ProductCategory对象", description="类目表")
public class ProductCategory implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "category_id", type = IdType.AUTO)
private Integer categoryId;
@ApiModelProperty(value = "类目名字")
private String categoryName;
@ApiModelProperty(value = "类目编号")
private Integer categoryType;
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@ApiModelProperty(value = "修改时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
}
最好能帮忙详细写下service层接口实现和controller层
感激不尽