摘要: 首先我们需要用一个接口表明service层都有哪些操作: public interface InfoService { Ret add(Info info); //注册 Ret delete(String name,String password); //删除用户信息 Ret login(Strin 阅读全文
posted @ 2021-11-25 21:05 Acc22222222 阅读(429) 评论(0) 推荐(0)
摘要: @Data @RestController @RequestMapping(value = "/info") //处理/info 开头的请求 public class InfoController { @Autowired private InfoService infoService; //必须在 阅读全文
posted @ 2021-11-25 20:59 Acc22222222 阅读(100) 评论(0) 推荐(0)
摘要: 是utils包中的一个方法 public static boolean judge(String name){ int n = 0; for(int i=0;i<name.length();i++){ n = (int)name.charAt(i); //强转为中文 if(n >= 19968 && 阅读全文
posted @ 2021-11-25 20:51 Acc22222222 阅读(75) 评论(0) 推荐(0)
摘要: 为了规范编程,我们一般用一个专门的来表示返回的值,其中发生错误就返回错误码,操作成功就返回操作的对象。 那么我们首先需要一个错误码类:Code @Data @AllArgsConstructor public class Code { private String code; private Str 阅读全文
posted @ 2021-11-25 20:48 Acc22222222 阅读(281) 评论(0) 推荐(0)
摘要: @Repository public interface InfoRepository extends JpaRepository<Info,Integer> { @Override Info save(Info info); void deleteByPassword(String passwor 阅读全文
posted @ 2021-11-25 19:38 Acc22222222 阅读(521) 评论(0) 推荐(0)
摘要: 对于数据库的表,我们除了要设置我们必要的属性(比如name,id等等),为了规范等原因,我们还需要加入一些别的属性,这里列举几个。 对于操作数据库,我们一般不调用delete方法,因为这样可能会删除大量数据。我们一般会在数据库中加入一个status属性,当我们加入数据时,把status设为1。需要删 阅读全文
posted @ 2021-11-25 19:24 Acc22222222 阅读(269) 评论(0) 推荐(0)
摘要: @Data @NoArgsConstructor @Table(name = "info") //对应数据库表的映射 @Entity //表明这是一个实体类 public class Info { @Id @GeneratedValue(strategy = GenerationType.IDENT 阅读全文
posted @ 2021-11-25 15:46 Acc22222222 阅读(147) 评论(0) 推荐(0)
摘要: common:存放各种要用到的常量。 config:配置类,比如添加时间格式化器等等。 repository:定义对数据库的各种操作。 utils:工具类,里面有各种静态方法。 logger:日志类。 ret:返回值类,用于controller的返回。 demo:数据库的表的映射。 controll 阅读全文
posted @ 2021-11-25 15:30 Acc22222222 阅读(43) 评论(0) 推荐(0)