/community

My_First_Project_Practice

Primary LanguageJava

威弟弟社区

资料

Spring 文档
Spring Web
es
Github deploy key
Bootstrap
Github OAuth thymeleaf帮助文档 MarkDown 插件 UCloud UFile SDK

工具

Git flyway lombok mybatis generator

笔记

@GetMapping("/publish/{questionId}")
public String republish(@PathVariable(name="questionId") Integer id,
                        Model model);
@PostMapping("/publish")
public String dopublish(
        @RequestParam(value = "title",required = false) String title,
        @RequestParam(value = "description",required = false) String description,;
        
mybatis generator的使用;

//Example具有限定功能,当没有限定时,传入一个无参构造Example(必传)
 //使用创建的sql语句,语句中使id等于,有where xxx=xxx的语句就用这个
 UserExample example=new UserExample();
 userExample.createCriteria().andIdEqualTo(dbUser.getId());
 //更新局部数据,直接是有where之前的update语句;
 User updateUser = new User();
 updateUser.setGmtModify(System.currentTimeMillis());
 updateUser.setAvatarUrl(user.getAvatarUrl());
 updateUser.setName(user.getName());
 updateUser.setToken(user.getToken());
 userMapper.updateByExampleSelective(updateUser,example);                       

图解说明

Image text

脚本

Create Table

CREATE TABLE `user` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `account_id` varchar(100) DEFAULT NULL,
  `name` varchar(50) DEFAULT NULL,
  `token` char(36) DEFAULT NULL,
  `gmt_create` bigint(20) DEFAULT NULL,
  `gmt_modify` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) 


Create Table

CREATE TABLE `questionid` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `description` text,
  `title` varchar(50) DEFAULT NULL,
  `gmt_create` bigint(20) DEFAULT NULL,
  `gmt_modify` bigint(20) DEFAULT NULL,
  `creator_id` int(11) DEFAULT NULL,
  `comment_count` int(11) DEFAULT '0',
  `view_count` int(11) DEFAULT '0',
  `like_count` int(11) DEFAULT '0',
  `tag` varchar(256) DEFAULT NULL,
  PRIMARY KEY (`id`)
)
terminal中使用
mvn flyway:migrate
mvn -Dmybatis.generator.overwrite=true mybatis-generator:generate