登录表

This commit is contained in:
hezi66677 2024-10-30 15:31:39 +08:00
parent 9e0a76d881
commit bfff8ec9d4
10 changed files with 234 additions and 5 deletions

19
pom.xml
View File

@ -60,16 +60,31 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!--<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
</dependency>-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.25</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
<version>3.5.7</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.5.7</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.31</version>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,33 @@
package com.c202201020128.task2.powermanagement;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import java.nio.file.Paths;
public class AI {
public static void main(String[] args) {
FastAutoGenerator.create("jdbc:mysql://10.33.66.120:3306/smallcoursedesign202201020128?serverTimezone=UTC",
"202201020128", "@hnucm1254")
.globalConfig(builder -> builder
.author("Baomidou")
.outputDir(Paths.get(System.getProperty("user.dir")) + "/src/ai")
.commentDate("yyyy-MM-dd")
)
.packageConfig(builder -> builder
.parent("com.baomidou.mybatisplus")
.entity("entity")
.mapper("mapper")
.service("service")
.serviceImpl("service.impl")
.xml("mapper.xml")
)
.strategyConfig(builder -> builder
.entityBuilder()
.enableLombok()
)
.templateEngine(new FreemarkerTemplateEngine())
.execute();
}
}

View File

@ -0,0 +1,37 @@
package com.c202201020128.task2.powermanagement.controller;
import com.c202201020128.task2.powermanagement.model.Person;
import com.c202201020128.task2.powermanagement.model.Result;
import com.c202201020128.task2.powermanagement.service.IPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author Baomidou
* @since 2024-10-30
*/
@Controller
@RequestMapping("/person")
public class PersonController {
@Autowired
IPersonService iPersonService;
@ResponseBody
@RequestMapping("/personlist")
public Result getPersonList(){
List<Person> personList = iPersonService.list();
return Result.ok().put("data",personList);
}
}

View File

@ -0,0 +1,18 @@
package com.c202201020128.task2.powermanagement.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.c202201020128.task2.powermanagement.model.Person;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author Baomidou
* @since 2024-10-30
*/
@Mapper
public interface PersonMapper extends BaseMapper<Person> {
}

View File

@ -1,4 +1,29 @@
package com.c202201020128.task2.powermanagement.model;
public class Person {
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
/**
* <p>
*
* </p>
*
* @author Baomidou
* @since 2024-10-30
*/
@Getter
@Setter
public class Person implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String person;
private String password;
}

View File

@ -0,0 +1,58 @@
package com.c202201020128.task2.powermanagement.model;
import java.util.HashMap;
import java.util.Map;
/**
* 返回数据封装类
*/
public class Result extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
public Result() {
put("code", 0);
put("msg", "success");
}
public static Result error() {
return error(500, "未知异常,请联系管理员");
}
public static Result error(String msg) {
return error(500, msg);
}
public static Result error(int code, String msg) {
Result r = new Result();
r.put("code", code);
r.put("msg", msg);
return r;
}
public static Result ok(String msg) {
Result r = new Result();
r.put("msg", msg);
return r;
}
public static Result ok(Object obj) {
Result r = new Result();
r.put("data", obj);
return r;
}
public static Result ok(Map<String, Object> map) {
Result r = new Result();
r.putAll(map);
return r;
}
public static Result ok() {
return new Result();
}
public Result put(String key, Object value) {
super.put(key, value);
return this;
}
}

View File

@ -0,0 +1,17 @@
package com.c202201020128.task2.powermanagement.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.c202201020128.task2.powermanagement.model.Person;
/**
* <p>
* 服务类
* </p>
*
* @author Baomidou
* @since 2024-10-30
*/
public interface IPersonService extends IService<Person> {
}

View File

@ -0,0 +1,21 @@
package com.c202201020128.task2.powermanagement.service.Impl;
import com.c202201020128.task2.powermanagement.dao.PersonMapper;
import com.c202201020128.task2.powermanagement.model.Person;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.c202201020128.task2.powermanagement.service.IPersonService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author Baomidou
* @since 2024-10-30
*/
@Service
public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person> implements IPersonService {
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.c202201020128.task2.powermanagement.dao.PersonMapper">
</mapper>

View File

@ -10,8 +10,8 @@ spring.datasource.username=202201020128
spring.datasource.password=@hnucm1254
#??????????MyBatis??
#??Mybatis?Mapper??
mybatis.mapper-locations=classpath:mapper/*.xml
mybatis-plus.mapper-locations=classpath:mapper/*.xml
#??Mybatis?????
mybatis.type-aliases-package=com.c202201020128.task2.powermanagement.model
mybatis-plus.type-aliases-package=com.c202201020128.task2.powermanagement.model
logging.level.com.c202201020128.task2.powermanagement = debug