1.写完了elasticsearch的接口部分。
2.对于elasticsearch的理解很浅薄。所以写起来很费解。而且es的语法和平常的不一样。所以写起来也很不容易。
3.写完用户的功能。
4.
package com.medicalretrieval.controller; import com.medicalretrieval.pojo.user.User; import com.medicalretrieval.service.UserService; import com.medicalretrieval.utils.Result; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/user") public class UserController { @Autowired private UserService userService; @PostMapping("/") User addUser(@RequestBody User user){ if (user.getSex()==1){ user.setAvatar("http://192.168.43.144:8080/avatar/default_avatar_female.png"); } System.out.println(user); userService.save(user); System.out.println("添加成功:"+user); return user; } @DeleteMapping("/{id}") Object deleteUser(@PathVariable String id){ userService.deleteById(Long.parseLong(id)); return Result.success(); } @PutMapping("/") Object updateUser(@RequestBody User user){ userService.updatePasswordAndEmailAndTelephoneAndPermissionGroupIdAndAvatarAndDisabledById(user.getPassword(),user.getEmail(),user.getTelephone(), user.getPermissionGroupId(), user.getAvatar(), user.getDisabled(), user.getId()); System.out.println("修改成功:"+user); return Result.success(); } @GetMapping("/") Object queryUser(String account,String password){ User user = userService.findByAccountAndPassword(account,password); if (user==null){ return Result.fail("登录失败,用户名或密码错误"); } System.out.println("查询成功:"+user); return Result.success(user); } }
package com.medicalretrieval.pojo.user; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import javax.persistence.*; @Entity @Data @NoArgsConstructor @AllArgsConstructor public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @Column(columnDefinition = "varchar(128) not null default '' ") private String account=""; @Column(columnDefinition = "varchar(128) not null default '' ") private String password=""; @Column(columnDefinition = "varchar(128) not null default '' ") private String email=""; @Column(columnDefinition = "int not null default '0'") private int sex = 0; @Column(columnDefinition = "varchar(128) not null default '' ") private String telephone=""; @Column(columnDefinition = "int not null default '0' ") private int permissionGroupId=0; @Column(columnDefinition = "varchar(128) not null default '' ") private String avatar="http://192.168.43.144:8080/avatar/default_avatar_man.png"; @Column(columnDefinition = "int not null default '0' ") private int disabled=0; }
标签:String,default,private,user,import,null,冲刺 From: https://www.cnblogs.com/lhk20213937/p/17331476.html