数据库
攻略主题表
CREATE TABLE `strategy_theme` ( `id` bigint NOT NULL AUTO_INCREMENT, `name` varchar(255) DEFAULT NULL, `state` int DEFAULT NULL, `seq` int DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC;
|
实体类
找到模块:trip-article-api,找到包com.swx.article.domain
,创建攻略主题实体类
StrategyTheme@Getter @Setter @TableName("strategy_theme") public class StrategyTheme { public static final int STATE_NORMAL = 1; public static final int STATE_DISABLE = 0;
private Long id; private String name; private Integer state = STATE_NORMAL; private Integer seq; }
|
分页查询
接口信息
Controller
StrategyThemeController@RestController @RequestMapping("/strategies/themes") public class StrategyThemeController {
private final StrategyThemeService strategyThemeService;
public StrategyThemeController(StrategyThemeService strategyThemeService) { this.strategyThemeService = strategyThemeService; }
@GetMapping("/query") public R<Page<StrategyTheme>> pageList(Page<StrategyTheme> page) { return R.ok(strategyThemeService.page(page)); } }
|
查询所有
接口信息
Controller
StrategyThemeController@GetMapping("/list") public R<List<StrategyTheme>> listAll() { return R.ok(strategyThemeService.list()); }
|
主键查询
接口信息
Controller
StrategyThemeController@GetMapping("/detail") public R<StrategyTheme> getById(Long id) { return R.ok(strategyThemeService.getById(id)); }
|
保存攻略主题
接口信息
Controller
StrategyThemeController@PostMapping("/save") public R<?> save(StrategyTheme strategyTheme) { strategyThemeService.save(strategyTheme); return R.ok(); }
|
更新攻略主题
接口信息
Controller
StrategyThemeController@PostMapping("/update") public R<?> update(StrategyTheme strategyTheme) { strategyThemeService.updateById(strategyTheme); return R.ok(); }
|
删除攻略分类
接口信息
Controller
StrategyThemeController@PostMapping("/delete/{id}") public R<?> delete(@PathVariable Long id) { strategyThemeService.removeById(id); return R.ok(); }
|