feat(all): 添加了用户相关数据结构、表结构
This commit is contained in:
parent
30b39802db
commit
50220334d7
19
.idea/dataSources.xml
generated
Normal file
19
.idea/dataSources.xml
generated
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="itzx@wzpmc.cn" uuid="6d73dcf2-41f4-4403-89d0-be443cbd1b39">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<imported>true</imported>
|
||||
<remarks>$PROJECT_DIR$/src/main/resources/application.properties</remarks>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://wzpmc.cn:3306/itzx</jdbc-url>
|
||||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/clubs.main.iml" filepath="$PROJECT_DIR$/.idea/modules/clubs.main.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
8
.idea/modules/clubs.main.iml
generated
Normal file
8
.idea/modules/clubs.main.iml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="AdditionalModuleElements">
|
||||
<content url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/main">
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/main" isTestSource="false" generated="true" />
|
||||
</content>
|
||||
</component>
|
||||
</module>
|
33
README.md
33
README.md
@ -1,4 +1,33 @@
|
||||
# ITZX-Clubs-Home-Server
|
||||
|
||||
A clubs home for Hangzhou Electron & Information Vocational School
|
||||
building by springboot3.0 with mysql db
|
||||
A clubs home for Hangzhou Electron & Information Vocational School
|
||||
building by springboot3.0 with mysql db
|
||||
---
|
||||
## Usage
|
||||
|
||||
### 1.Create user table
|
||||
|
||||
```mysql
|
||||
create table user
|
||||
(
|
||||
id int comment '用户ID(自增)',
|
||||
name varchar(20) not null comment '用户名',
|
||||
password char(40) not null comment '密码(使用SHA1)',
|
||||
auth int default 0 not null comment '用户对应权限组ID',
|
||||
avatar char(40) null comment '用户头像sha1',
|
||||
create_time datetime default now() not null comment '用户创建时间',
|
||||
update_time datetime default now() not null on update now() comment '用户数据更新时间'
|
||||
)
|
||||
comment '用户表';
|
||||
|
||||
create unique index user_id_index
|
||||
on user (id)
|
||||
comment '用户表主键';
|
||||
|
||||
alter table user
|
||||
add constraint user_pk
|
||||
primary key (id) comment '用户表主键';
|
||||
|
||||
alter table user
|
||||
modify id int auto_increment comment '用户ID(自增)';
|
||||
```
|
||||
|
@ -4,6 +4,7 @@ plugins {
|
||||
id("io.spring.dependency-management") version "1.1.4"
|
||||
id("org.graalvm.buildtools.native") version "0.9.28"
|
||||
id("org.asciidoctor.jvm.convert") version "3.3.2"
|
||||
id("org.springdoc.openapi-gradle-plugin") version "1.8.0"
|
||||
}
|
||||
|
||||
group = "org.mmga"
|
||||
@ -32,13 +33,16 @@ dependencies {
|
||||
implementation("org.springframework.boot:spring-boot-starter-websocket")
|
||||
implementation("org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.3")
|
||||
implementation("org.springframework.shell:spring-shell-starter")
|
||||
implementation("org.springdoc:springdoc-openapi-starter-webmvc-api:2.5.0")
|
||||
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0")
|
||||
// https://mvnrepository.com/artifact/commons-codec/commons-codec
|
||||
implementation("commons-codec:commons-codec:1.16.1")
|
||||
compileOnly("org.projectlombok:lombok")
|
||||
developmentOnly("org.springframework.boot:spring-boot-devtools")
|
||||
runtimeOnly("com.mysql:mysql-connector-j")
|
||||
annotationProcessor("org.projectlombok:lombok")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.3")
|
||||
testImplementation("org.springframework.restdocs:spring-restdocs-mockmvc")
|
||||
}
|
||||
|
||||
dependencyManagement {
|
||||
|
@ -0,0 +1,16 @@
|
||||
package org.mmga.clubs.configuration;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class DocsConfiguration {
|
||||
@Bean
|
||||
public OpenAPI api(){
|
||||
return new OpenAPI().info(new Info()
|
||||
.title("ITZX-Clubs-Home")
|
||||
.description("杭州电子信息职业学校社团主页"));
|
||||
}
|
||||
}
|
35
src/main/java/org/mmga/clubs/controller/UserController.java
Normal file
35
src/main/java/org/mmga/clubs/controller/UserController.java
Normal file
@ -0,0 +1,35 @@
|
||||
package org.mmga.clubs.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mmga.clubs.entities.BaseResponse;
|
||||
import org.mmga.clubs.entities.user.User;
|
||||
import org.mmga.clubs.entities.user.UserLoginVo;
|
||||
import org.mmga.clubs.entities.user.UserRegVo;
|
||||
import org.mmga.clubs.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/user")
|
||||
@Tag(name = "用户", description = "用户相关接口")
|
||||
@Slf4j
|
||||
public class UserController {
|
||||
private final UserService service;
|
||||
@Autowired
|
||||
public UserController(UserService userService){
|
||||
this.service = userService;
|
||||
}
|
||||
@PostMapping("/login")
|
||||
@Operation(description = "用户登录", responses = {@ApiResponse(description = "返回是否登录成功", responseCode = "200")})
|
||||
public BaseResponse<User> login(@RequestBody UserLoginVo user){
|
||||
return service.login(user);
|
||||
}
|
||||
@PutMapping("/create")
|
||||
@Operation(description = "创建用户", responses = {@ApiResponse(description = "返回创建后的用户")})
|
||||
public BaseResponse<User> createUser(@RequestBody UserRegVo user){
|
||||
return service.createUser(user);
|
||||
}
|
||||
}
|
8
src/main/java/org/mmga/clubs/dao/AuthDao.java
Normal file
8
src/main/java/org/mmga/clubs/dao/AuthDao.java
Normal file
@ -0,0 +1,8 @@
|
||||
package org.mmga.clubs.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface AuthDao {
|
||||
|
||||
}
|
7
src/main/java/org/mmga/clubs/dao/AuthPermissionDao.java
Normal file
7
src/main/java/org/mmga/clubs/dao/AuthPermissionDao.java
Normal file
@ -0,0 +1,7 @@
|
||||
package org.mmga.clubs.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface AuthPermissionDao {
|
||||
}
|
7
src/main/java/org/mmga/clubs/dao/PermissionDao.java
Normal file
7
src/main/java/org/mmga/clubs/dao/PermissionDao.java
Normal file
@ -0,0 +1,7 @@
|
||||
package org.mmga.clubs.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PermissionDao {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package org.mmga.clubs.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PermissionRouterDao {
|
||||
}
|
7
src/main/java/org/mmga/clubs/dao/RouterDao.java
Normal file
7
src/main/java/org/mmga/clubs/dao/RouterDao.java
Normal file
@ -0,0 +1,7 @@
|
||||
package org.mmga.clubs.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface RouterDao {
|
||||
}
|
13
src/main/java/org/mmga/clubs/dao/UserDao.java
Normal file
13
src/main/java/org/mmga/clubs/dao/UserDao.java
Normal file
@ -0,0 +1,13 @@
|
||||
package org.mmga.clubs.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.mmga.clubs.entities.user.UserRegResponseVo;
|
||||
import org.mmga.clubs.entities.user.UserVo;
|
||||
|
||||
@Mapper
|
||||
public interface UserDao {
|
||||
UserVo getUser(String username, String password);
|
||||
void addUser(UserRegResponseVo userVo);
|
||||
int countUser(String username);
|
||||
UserVo getUserById(int id);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package org.mmga.clubs.entities;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public record AuthPermissionVo(int authId, int permissionId, Date createTime, Date updateTime) {
|
||||
}
|
28
src/main/java/org/mmga/clubs/entities/BaseResponse.java
Normal file
28
src/main/java/org/mmga/clubs/entities/BaseResponse.java
Normal file
@ -0,0 +1,28 @@
|
||||
package org.mmga.clubs.entities;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.mmga.clubs.entities.user.User;
|
||||
|
||||
@Data
|
||||
@Schema(description = "基础返回值")
|
||||
public class BaseResponse<T> {
|
||||
@Schema(description = "返回代码(参考HTTP响应码)", examples = {"200", "404", "500", "403"})
|
||||
private int code;
|
||||
@Schema(description = "返回信息(自定义)")
|
||||
private String msg;
|
||||
@Schema(description = "返回数据")
|
||||
private T data;
|
||||
private BaseResponse(int code, String msg, T data){
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
public static <T> BaseResponse<T> success(T data){
|
||||
return new BaseResponse<>(200, "接口执行成功", data);
|
||||
}
|
||||
|
||||
public static<T> BaseResponse<T> failed(int code, String msg) {
|
||||
return new BaseResponse<>(code, msg, null);
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package org.mmga.clubs.entities;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public record PermissionRouterVo (int permissionId, int routerId, Date createTime, Date updateTime) {
|
||||
}
|
18
src/main/java/org/mmga/clubs/entities/auth/Auth.java
Normal file
18
src/main/java/org/mmga/clubs/entities/auth/Auth.java
Normal file
@ -0,0 +1,18 @@
|
||||
package org.mmga.clubs.entities.auth;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.mmga.clubs.entities.permission.Permission;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Schema(description = "用户权限组")
|
||||
public class Auth {
|
||||
@Schema(description = "权限组ID")
|
||||
private int id;
|
||||
@Schema(description = "权限组名称")
|
||||
private String name;
|
||||
@Schema(description = "权限组所拥有的权限")
|
||||
private List<Permission> permissions;
|
||||
}
|
7
src/main/java/org/mmga/clubs/entities/auth/AuthVo.java
Normal file
7
src/main/java/org/mmga/clubs/entities/auth/AuthVo.java
Normal file
@ -0,0 +1,7 @@
|
||||
package org.mmga.clubs.entities.auth;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public record AuthVo(int id, String name, Date createTime, Date updateTime) {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package org.mmga.clubs.entities.permission;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.mmga.clubs.entities.router.Router;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Schema(description = "单个权限")
|
||||
public class Permission {
|
||||
@Schema(description = "权限ID")
|
||||
private int id;
|
||||
@Schema(description = "权限名称")
|
||||
private String name;
|
||||
@Schema(description = "此权限可访问的Router")
|
||||
private List<Router> routers;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package org.mmga.clubs.entities.permission;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public record PermissionVo(int id, String name, Date createTime, Date updateTime) {
|
||||
}
|
19
src/main/java/org/mmga/clubs/entities/router/Router.java
Normal file
19
src/main/java/org/mmga/clubs/entities/router/Router.java
Normal file
@ -0,0 +1,19 @@
|
||||
package org.mmga.clubs.entities.router;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Schema(description = "路由节点")
|
||||
public class Router {
|
||||
@Schema(description = "节点ID")
|
||||
private int id;
|
||||
@Schema(description = "节点名称")
|
||||
private String name;
|
||||
@Schema(description = "节点对应组件名称")
|
||||
private String component;
|
||||
@Schema(description = "节点的子节点")
|
||||
private List<Router> children;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package org.mmga.clubs.entities.router;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public record RouterVo(int id, String name, int parent, String component, Date createTime, Date updateTime) {
|
||||
}
|
18
src/main/java/org/mmga/clubs/entities/user/User.java
Normal file
18
src/main/java/org/mmga/clubs/entities/user/User.java
Normal file
@ -0,0 +1,18 @@
|
||||
package org.mmga.clubs.entities.user;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.mmga.clubs.entities.auth.Auth;
|
||||
|
||||
@Data
|
||||
@Schema(description = "用户")
|
||||
public class User {
|
||||
@Schema(description = "用户ID")
|
||||
private int id;
|
||||
@Schema(description = "用户名")
|
||||
private String name;
|
||||
@Schema(description = "用户所在权限组")
|
||||
private Auth auth;
|
||||
@Schema(description = "用户头像SHA1值")
|
||||
private String avatar;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package org.mmga.clubs.entities.user;
|
||||
|
||||
public record UserLoginVo(String name, String password) {
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package org.mmga.clubs.entities.user;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
@Data
|
||||
public class UserRegResponseVo {
|
||||
private int id;
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final int auth;
|
||||
public UserRegResponseVo(UserRegVo userRegVo) {
|
||||
this.username = userRegVo.username();
|
||||
this.password = DigestUtils.sha1Hex(userRegVo.password());
|
||||
this.auth = userRegVo.auth();
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package org.mmga.clubs.entities.user;
|
||||
|
||||
public record UserRegVo(String username, String password, int auth) {
|
||||
}
|
6
src/main/java/org/mmga/clubs/entities/user/UserVo.java
Normal file
6
src/main/java/org/mmga/clubs/entities/user/UserVo.java
Normal file
@ -0,0 +1,6 @@
|
||||
package org.mmga.clubs.entities.user;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public record UserVo(int id, String name, String password, int auth, String avatar, Date createTime, Date updateTime) {
|
||||
}
|
17
src/main/java/org/mmga/clubs/service/AuthService.java
Normal file
17
src/main/java/org/mmga/clubs/service/AuthService.java
Normal file
@ -0,0 +1,17 @@
|
||||
package org.mmga.clubs.service;
|
||||
|
||||
import org.mmga.clubs.dao.AuthDao;
|
||||
import org.mmga.clubs.dao.AuthPermissionDao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AuthService {
|
||||
private final AuthDao authDao;
|
||||
private final AuthPermissionDao authPermissionDao;
|
||||
@Autowired
|
||||
public AuthService(AuthDao authDao, AuthPermissionDao authPermissionDao) {
|
||||
this.authDao = authDao;
|
||||
this.authPermissionDao = authPermissionDao;
|
||||
}
|
||||
}
|
15
src/main/java/org/mmga/clubs/service/PermissionService.java
Normal file
15
src/main/java/org/mmga/clubs/service/PermissionService.java
Normal file
@ -0,0 +1,15 @@
|
||||
package org.mmga.clubs.service;
|
||||
|
||||
import org.mmga.clubs.dao.PermissionDao;
|
||||
import org.mmga.clubs.dao.PermissionRouterDao;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class PermissionService {
|
||||
private final PermissionDao permissionDao;
|
||||
private final PermissionRouterDao permissionRouterDao;
|
||||
public PermissionService(PermissionDao permissionDao, PermissionRouterDao permissionRouterDao) {
|
||||
this.permissionDao = permissionDao;
|
||||
this.permissionRouterDao = permissionRouterDao;
|
||||
}
|
||||
}
|
12
src/main/java/org/mmga/clubs/service/RouterService.java
Normal file
12
src/main/java/org/mmga/clubs/service/RouterService.java
Normal file
@ -0,0 +1,12 @@
|
||||
package org.mmga.clubs.service;
|
||||
|
||||
import org.mmga.clubs.dao.RouterDao;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class RouterService {
|
||||
private final RouterDao routerDao;
|
||||
public RouterService(RouterDao routerDao) {
|
||||
this.routerDao = routerDao;
|
||||
}
|
||||
}
|
40
src/main/java/org/mmga/clubs/service/UserService.java
Normal file
40
src/main/java/org/mmga/clubs/service/UserService.java
Normal file
@ -0,0 +1,40 @@
|
||||
package org.mmga.clubs.service;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.mmga.clubs.dao.UserDao;
|
||||
import org.mmga.clubs.entities.BaseResponse;
|
||||
import org.mmga.clubs.entities.user.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
private final UserDao userDao;
|
||||
@Autowired
|
||||
public UserService(UserDao userDao){
|
||||
this.userDao = userDao;
|
||||
}
|
||||
|
||||
public BaseResponse<User> login(UserLoginVo user) {
|
||||
UserVo userVo = userDao.getUser(user.name(), DigestUtils.sha1Hex(user.name()));
|
||||
User u = packageUser(userVo);
|
||||
return u == null ? BaseResponse.failed(404, "无效用户") : BaseResponse.success(u);
|
||||
}
|
||||
|
||||
public BaseResponse<User> createUser(UserRegVo user) {
|
||||
String username = user.username();
|
||||
if (userDao.countUser(username) > 0) {
|
||||
return BaseResponse.failed(409, "用户已存在");
|
||||
}
|
||||
UserRegResponseVo response = new UserRegResponseVo(user);
|
||||
userDao.addUser(response);
|
||||
int newUserId = response.getId();
|
||||
return BaseResponse.success(packageUser(userDao.getUserById(newUserId)));
|
||||
}
|
||||
private User packageUser(UserVo vo) {
|
||||
if (vo == null){
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1 +1,5 @@
|
||||
spring.application.name=ITZX-Clubs-Home-Server
|
||||
spring.datasource.url=jdbc:mysql://wzpmc.cn:3306/itzx
|
||||
spring.datasource.username=itzx
|
||||
spring.datasource.password=jdy53QFMm3yATQk3
|
||||
springdoc.swagger-ui.path=/docs
|
6
src/main/resources/org/mmga/clubs/dao/AuthDao.xml
Normal file
6
src/main/resources/org/mmga/clubs/dao/AuthDao.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.mmga.clubs.dao.AuthDao">
|
||||
</mapper>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.mmga.clubs.dao.AuthPermissionDao">
|
||||
</mapper>
|
6
src/main/resources/org/mmga/clubs/dao/PermissionDao.xml
Normal file
6
src/main/resources/org/mmga/clubs/dao/PermissionDao.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.mmga.clubs.dao.PermissionDao">
|
||||
</mapper>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.mmga.clubs.dao.PermissionRouterDao">
|
||||
</mapper>
|
6
src/main/resources/org/mmga/clubs/dao/RouterDao.xml
Normal file
6
src/main/resources/org/mmga/clubs/dao/RouterDao.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.mmga.clubs.dao.RouterDao">
|
||||
</mapper>
|
18
src/main/resources/org/mmga/clubs/dao/UserDao.xml
Normal file
18
src/main/resources/org/mmga/clubs/dao/UserDao.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.mmga.clubs.dao.UserDao">
|
||||
<insert id="addUser" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into `user`(`name`, `password`, `auth`) values(#{username}, #{password}, #{auth});
|
||||
</insert>
|
||||
<select id="getUser" resultType="org.mmga.clubs.entities.user.UserVo">
|
||||
select * from `user` where `name` = #{username} and `password` = #{password};
|
||||
</select>
|
||||
<select id="countUser" resultType="java.lang.Integer">
|
||||
select count(*) from `user` where `name` = #{username};
|
||||
</select>
|
||||
<select id="getUserById" resultType="org.mmga.clubs.entities.user.UserVo">
|
||||
select * from `user` where `id` = #{id};
|
||||
</select>
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user