发布博客中添加了分类选择以及封面上传,引入七牛云存储,优化了token登录验证

This commit is contained in:
Xubx 2024-11-01 16:17:51 +08:00
parent c0ac1f5ae1
commit 1510401ccc
21 changed files with 308 additions and 234 deletions

25
pom.xml
View File

@ -9,7 +9,7 @@
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.xubx</groupId>
<artifactId>Springboot_01Demo</artifactId>
<artifactId>XubxBlog</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Springboot_01Demo</name>
<description>Springboot_01Demo</description>
@ -101,18 +101,6 @@
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<!-- Poi-->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.0.0</version>
</dependency>
<!-- websocket-->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -139,6 +127,17 @@
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.0.0</version>
</dependency>
<!--七牛云存储-->
<dependency>
<groupId>com.qiniu</groupId>
<artifactId>qiniu-java-sdk</artifactId>
<version>[7.16.0, 7.16.99]</version>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies>
<build>

View File

@ -1,67 +0,0 @@
package com.xubx.springboot_01demo.Poi;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
//POI操作Excel
public class PoiTest {
//写入
public static void write() throws Exception{
//在内存中创建一个Excel文件
XSSFWorkbook workbook = new XSSFWorkbook();
//在Excel文件中创建一个sheet
XSSFSheet sheet = workbook.createSheet("info");
//在sheet中创建行对象rownum编号从0开始
XSSFRow row = sheet.createRow(0);
//创建单元格并写入文件内容
row.createCell(0).setCellValue("姓名");
row.createCell(1).setCellValue("城市");
//创建一个新的行
XSSFRow row1 = sheet.createRow(1);
row1.createCell(0).setCellValue("张三");
row1.createCell(1).setCellValue("北京");
//创建一个新的行
XSSFRow row2 = sheet.createRow(2);
row2.createCell(0).setCellValue("李四");
row2.createCell(1).setCellValue("上海");
//通过输出流将workbook对象输出到磁盘
FileOutputStream out = new FileOutputStream(new File("C:\\info.xlsx"));
//关闭资源
workbook.write(out);
out.close();
}
//读取
public static void read() throws Exception{
FileInputStream fileInputStream = new FileInputStream(new File("C:\\Users\\Xubx\\info.xlsx"));
//读取Excel文件
XSSFWorkbook excel = new XSSFWorkbook(fileInputStream);
//读取第一个sheet
XSSFSheet sheet = excel.getSheetAt(0);
//获取sheet中的最后一行行号
int lastRowNum = sheet.getLastRowNum();
for (int i = 0; i <= lastRowNum; i++) {
//获取行对象
XSSFRow row = sheet.getRow(i);
//获取单元格对象
String name = row.getCell(0).getStringCellValue();
String city = row.getCell(1).getStringCellValue();
System.out.println(name + " " + city);
}
//关闭资源
excel.close();
fileInputStream.close();
}
public static void main(String[] args) throws Exception {
// write();
read();
}
}

View File

@ -0,0 +1,32 @@
package com.xubx.springboot_01demo.configuration;
import com.qiniu.storage.Region;
import com.qiniu.util.Auth;
import com.qiniu.util.StringMap;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
@Data
@Component
@Configuration
@ConfigurationProperties(prefix = "qiniu")
public class QiniuConfig {
private String accessKey;
private String secretKey;
private String bucket;
@Bean
public String getUpToken() {
Auth auth = Auth.create(accessKey, secretKey);
StringMap putPolicy = new StringMap(); //创建上传策略
//指定返回的json格式key文件名称hash文件内容的哈希值用于校验文件一致性bucket文件所属的空间名 fsize文件大小
putPolicy.put("returnBody", "{\"key\":\"$(key)\",\"hash\":\"$(etag)\",\"bucket\":\"$(bucket)\",\"fsize\":$(fsize)}");
// 设置 Token 的过期时间为 3600 1 小时
long expireSeconds = 3600;
String upToken = auth.uploadToken(bucket, null, expireSeconds, putPolicy);
return upToken;
}
}

View File

@ -1,15 +1,22 @@
package com.xubx.springboot_01demo.controller;
import com.alibaba.fastjson.JSONObject;
import com.xubx.springboot_01demo.dto.blog.addBlogDto;
import com.xubx.springboot_01demo.pojo.Blogs;
import com.xubx.springboot_01demo.service.BlogService;
import com.xubx.springboot_01demo.utils.api.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
@RestController //注解标识这是一个控制器类
@ -25,55 +32,74 @@ public class BlogsController {
* 获取所有博客
*/
@GetMapping("/getBlogs")
@Cacheable(value = "blogs")
@ApiOperation("获取所有博客")
public List<Blogs> getBlogs (){
log.info("博客展示");
return blogService.findAllBlogs();
public ResponseEntity<List<Blogs>> getBlogs() {
log.info("获取所有博客");
return ResponseEntity.ok(blogService.findAllBlogs());
}
/**
* 获取博客详情
*
* @param id
* @return
*/
@GetMapping("/getBlogDetail")
@Cacheable(value = "blogDetail")
@ApiOperation("获取博客详情")
public Blogs getBlogDetail(@RequestParam("blogId") int id){
return blogService.findByIdBlogs(id);
public ResponseEntity<Blogs> getBlogDetail(@RequestParam("blogId") int id) {
log.info("获取博客详情ID: {}", id);
Blogs blog = blogService.findByIdBlogs(id);
if (blog == null) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
}
return ResponseEntity.ok(blog);
}
/**
* 新增博客
*
* @param blogs
*/
@PostMapping("/addBlog")
@CacheEvict(value = "blogs",allEntries = true)
@ApiOperation("新增博客")
public void addBlog(@RequestBody Blogs blogs){
blogService.addBlogs(blogs);
public ResponseEntity<String> addBlog(@Valid @RequestBody addBlogDto blogs, BindingResult bindingResult) {
log.info("新增博客入参:{}", JSONObject.toJSONString(blogs));
if (bindingResult.hasErrors()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(bindingResult.getFieldError().getDefaultMessage());
}
try {
blogService.addBlogs(blogs);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("博客新增失败");
}
return ResponseEntity.status(HttpStatus.CREATED).body("博客新增成功");
}
/**
* 修改博客
*
* @param blogs
*/
@PostMapping("/updateBlog")
@CacheEvict(value = "blogs",allEntries = true)
@ApiOperation("修改博客")
public void updateBlog(@RequestBody Blogs blogs){
public ResponseEntity<String> updateBlog(@RequestBody Blogs blogs) {
blogService.updateBlogs(blogs);
return ResponseEntity.ok("博客更新成功");
}
/**
* 删除博客
*
* @param id
*/
@GetMapping("/deleteBlog")
@CacheEvict(value = "blogs",allEntries = true)
@ApiOperation("删除博客")
public void deleteBlog(@RequestParam("blogId") int id){
public ResponseEntity<String> deleteBlog(@RequestParam("blogId") int id) {
blogService.deleteBlogs(id);
return ResponseEntity.ok("博客删除成功");
}
}

View File

@ -0,0 +1,39 @@
package com.xubx.springboot_01demo.controller;
import com.xubx.springboot_01demo.service.Uploadservice;
import com.xubx.springboot_01demo.utils.api.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
@Controller //注解标识这是一个控制器类
@CrossOrigin //加上CrossOrigin可解决跨域问题
@Slf4j
@Api(tags = "文件上传接口")
@RequestMapping("/upload")
public class UploadController {
@Resource
Uploadservice uploadservice;
/**
* 获取上传凭证
* @return {@link Result }<{@link String }>
*/
@RequestMapping("/getUploadCredentials")
@ApiOperation("value = \"获取上传凭证\"")
public ResponseEntity<String> getUploadCredentials() {
log.info("获取上传凭证");
try {
String uploadCredentials = uploadservice.getUploadCredentials();
return ResponseEntity.ok(uploadCredentials);
} catch (Exception e) {
return ResponseEntity.badRequest().body(e.getMessage());
}
}
}

View File

@ -1,13 +1,9 @@
package com.xubx.springboot_01demo.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xubx.springboot_01demo.pojo.Relationship;
import com.xubx.springboot_01demo.pojo.User;
import com.xubx.springboot_01demo.service.UserService;
import com.xubx.springboot_01demo.utils.api.Result;
import com.xubx.springboot_01demo.utils.token.RedisUtil;
import com.xubx.springboot_01demo.utils.token.RequestHolder;
import com.xubx.springboot_01demo.utils.token.TokenGenerate;
import io.swagger.annotations.Api;
@ -22,7 +18,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.util.List;
@RestController //注解标识这是一个控制器类
@CrossOrigin //加上CrossOrigin可解决跨域问题
@ -32,8 +27,6 @@ import java.util.List;
public class UserController {
@Resource
UserService userService;
@Resource
RedisUtil redisUtil;
// 注入session
@Resource
private HttpSession session;
@ -81,7 +74,6 @@ public class UserController {
String token = new TokenGenerate().generateToken(user.getUsername());
//将username存入session
session.setAttribute("username", user.getUsername());
redisUtil.addTokens(user.getUsername(), token);
return token;
}
return "false";

View File

@ -0,0 +1,31 @@
package com.xubx.springboot_01demo.dto.blog;
import lombok.Data;
import java.util.List;
import javax.validation.constraints.NotBlank;
/**
* 新增博客入参
* @author Xubx
* @date 2024/11/01
*/
@Data
public class addBlogDto {
@NotBlank
private String title;
@NotBlank
private String description;
@NotBlank
private List<String> categories;
@NotBlank
private String content;
private String coverImage;
private String status;
}

View File

@ -1,18 +1,27 @@
package com.xubx.springboot_01demo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xubx.springboot_01demo.dto.blog.addBlogDto;
import com.xubx.springboot_01demo.pojo.Blogs;
import java.util.List;
public interface BlogsMapper {
public interface BlogsMapper extends BaseMapper<Blogs> {
//获取所有博客文章信息
List<Blogs> findAllBlogs();
//根据id获取博客
Blogs findByIdBlogs(int id);
//新增博客
void addBlogs(Blogs blogs);
void addBlogs(addBlogDto blogs);
//更新博客
void updateBlogs(Blogs blogs);
//删除博客
void deleteBlogs(int id);
/**
* 插入博客分类中间表
* @param blogId
* @param categoryId
*/
void insertCategory(int blogId, String categoryId);
}

View File

@ -1,70 +1,65 @@
package com.xubx.springboot_01demo.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* 博客实体类
*
* @author Xubx
* @date 2024/11/01
*/
@Data
@ApiModel(description = "博客实体类")
@TableName("blog")
public class Blogs implements Serializable {
/**
*开启了主键回填
*/
@ApiModelProperty(value = "id")
@TableId(type = IdType.AUTO)
private int id;
/**标题*/
@ApiModelProperty(value = "标题")
private String title;
/**描述*/
@ApiModelProperty(value = "描述")
private String description;
/**内容*/
@ApiModelProperty(value = "内容")
private String content;
/**创建时间*/
private Timestamp created;
@Override
public String toString() {
return "Blogs{" +
"id=" + id +
", title='" + title + '\'' +
", description='" + description + '\'' +
", content='" + content + '\'' +
", create='" + created + '\'' +
'}';
}
@ApiModelProperty(value = "封面图片")
private String coverImage;
public int getId() {
return id;
}
@ApiModelProperty(value = "作者id")
private String authorId;
public void setId(int id) {
this.id = id;
}
@ApiModelProperty(value = "点赞数")
private int likeCount;
public String getTitle() {
return title;
}
@ApiModelProperty(value = "浏览数")
private int viewCount;
public void setTitle(String title) {
this.title = title;
}
@ApiModelProperty(value = "收藏数")
private int favoriteCount;
public String getDescription() {
return description;
}
@ApiModelProperty(value = "分享数")
private int shareCount;
public void setDescription(String description) {
this.description = description;
}
@ApiModelProperty(value = "状态")
private String status;
public String getContent() {
return content;
}
@ApiModelProperty(value = "更新时间")
private Timestamp updatedTime;
public void setContent(String content) {
this.content = content;
}
public Timestamp getCreated() {
return created;
}
public void setCreated(Timestamp create) {
this.created = create;
}
@ApiModelProperty(value = "创建时间")
private Timestamp createdTime;
}

View File

@ -1,5 +1,6 @@
package com.xubx.springboot_01demo.service;
import com.xubx.springboot_01demo.dto.blog.addBlogDto;
import com.xubx.springboot_01demo.pojo.Blogs;
import java.util.List;
@ -11,7 +12,7 @@ public interface BlogService {
//根据id获取博客
Blogs findByIdBlogs(int id);
//添加博客
void addBlogs(Blogs blogs);
void addBlogs(addBlogDto blogs);
//更新博客
void updateBlogs(Blogs blogs);
//删除博客

View File

@ -0,0 +1,8 @@
package com.xubx.springboot_01demo.service;
public interface Uploadservice {
/**
* @return {@link String }
*/
String getUploadCredentials();
}

View File

@ -1,11 +1,15 @@
package com.xubx.springboot_01demo.service.impl;
import com.xubx.springboot_01demo.dto.blog.addBlogDto;
import com.xubx.springboot_01demo.mapper.BlogsMapper;
import com.xubx.springboot_01demo.pojo.Blogs;
import com.xubx.springboot_01demo.service.BlogService;
import com.xubx.springboot_01demo.utils.token.RequestHolder;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.List;
@Service
@ -23,8 +27,23 @@ public class BlogsServiceImpl implements BlogService {
}
@Override
public void addBlogs(Blogs blogs) {
blogsMapper.addBlogs(blogs);
public void addBlogs(addBlogDto blogDto) {
LocalDateTime now = LocalDateTime.now();
// 博客内容的插入
Blogs blog = new Blogs();
blog.setTitle(blogDto.getTitle());
blog.setDescription(blogDto.getDescription());
blog.setContent(blogDto.getContent());
blog.setCoverImage(blogDto.getCoverImage());
blog.setStatus(blogDto.getStatus());
blog.setAuthorId(RequestHolder.getuserId());
// TODO 后续改为AOP切面统一进行创建更新时间的插入
blog.setCreatedTime(Timestamp.valueOf(now));
blogsMapper.insert(blog);
// 插入博客分类中间表
blogDto.getCategories().forEach(category -> {
blogsMapper.insertCategory(blog.getId(), category);
});
}
@Override

View File

@ -0,0 +1,18 @@
package com.xubx.springboot_01demo.service.impl;
import com.xubx.springboot_01demo.configuration.QiniuConfig;
import com.xubx.springboot_01demo.service.Uploadservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class UploadServiceImpl implements Uploadservice {
@Autowired
QiniuConfig qiniuConfig;
@Override
public String getUploadCredentials() {
return qiniuConfig.getUpToken();
}
}

View File

@ -1,5 +1,6 @@
package com.xubx.springboot_01demo.utils.api;
import com.xubx.springboot_01demo.pojo.Blogs;
import lombok.Data;
import java.util.List;
@ -33,6 +34,13 @@ public class Result<T> {
r.setResult(resultData);
return r;
}
public static <T> Result<T> error(String message) {
Result<T> r = new Result<>();
r.setCode(500);
r.setMessage(message);
return r;
}
@Override
public String toString() {

View File

@ -1,28 +0,0 @@
package com.xubx.springboot_01demo.utils.token;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class RedisUtil {
@Resource
private RedisTemplate<String, String> stringRedisTemplate;//这是一个使用redis的API可以直接用StringRedisTemplate
public void addTokens(String username,String token) {//存入token
ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue();
valueOperations.set(username, token);
}
public String getTokens(String token) {//获取token
//根据token获取用户信息
String username = TokenGenerate.getUsername(token);
return stringRedisTemplate.opsForValue().get(username);
}
public void delTokens(String username) {//删除token在前端已经进行
stringRedisTemplate.delete(username);
}
}

View File

@ -9,7 +9,7 @@ import java.util.Date;
public class TokenGenerate {
private static final long EXPIRE_TIME = 60 * 60 * 1000;
private static final long EXPIRE_TIME = 24 * 60 * 60 * 1000;
private static final String TOKEN_SECRET = "tokenqkj"; //密钥盐
public String generateToken(String username) {
@ -50,21 +50,4 @@ public class TokenGenerate {
}
}
/**
* 获取token中的username
*/
public static String getUsername(String token) {
try {
//去掉token的第一个和最后一个引号
if (token != null && token.startsWith("\"") && token.endsWith("\"")) {
token = token.substring(1, token.length() - 1);
}
JWTVerifier verifier = JWT.require(Algorithm.HMAC256(TOKEN_SECRET)).withIssuer("auth0").build();
DecodedJWT jwt = verifier.verify(token);
return jwt.getClaim("username").asString();
} catch (Exception e) {
return null;
}
}
}

View File

@ -12,8 +12,6 @@ import javax.servlet.http.HttpServletResponse;
// 在提供一个有效的token时才能通过验证,否则给出认证失败的响应
@Component
public class TokenInterceptor implements HandlerInterceptor {
@Resource
RedisUtil redisUtil;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
@ -26,14 +24,9 @@ public class TokenInterceptor implements HandlerInterceptor {
response.setCharacterEncoding("utf-8");
// 从请求头中获取token
String token = request.getHeader("Authorization");
// 从redis中获取token
String redisToken = redisUtil.getTokens(token);
// 验证token
if (redisToken != null) {
boolean result = TokenGenerate.verify(token);
if (result) {
return true;
}
if (token != null && TokenGenerate.verify(token)) {
return true;
}
response.setCharacterEncoding("UTF-8");
response.getWriter().write("认证失败,错误码:50000");

View File

@ -1,18 +0,0 @@
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://62.234.217.137:3306/vue
spring.datasource.username=root
spring.datasource.password=nWZpHMb8mNxWE5Xk
server.port=8088
#spring.web.resources.static-locations=classpath:/static/
spring.web.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
mybatis.mapper-locations=classpath:mapper/*.xml
mybatis.type-aliases-package=com.xubx.springboot_01demo.pojo
spring.redis.host=62.234.217.137
spring.redis.port=6379
spring.redis.password=LSHCwjr6ZN4hzCxS
logging.level.com.xubx.springboot_01demo.mapper= debug
#Path???????ant_path_matcher
spring.mvc.pathmatch.matching-strategy=ant_path_matcher

View File

@ -0,0 +1,30 @@
server:
port: 8088
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://62.234.217.137:3306/vue
username: root
password: nWZpHMb8mNxWE5Xk
redis:
host: 62.234.217.137
port: 6379
password: LSHCwjr6ZN4hzCxS
web:
resources:
static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
mvc:
pathmatch:
matching-strategy: ant_path_matcher
mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.xubx.springboot_01demo.pojo
logging:
level:
com.xubx.springboot_01demo.mapper: debug
qiniu:
accessKey: McJYQOg3S6PhkljCg2DQeggBQTcGcUZyK_s6vkxy
secretKey: 5hUuHs-BEzJIEKPCEj292h14evv5L59bDSZuYXa-
bucket: xubx-blog

View File

@ -25,6 +25,10 @@
insert into blog (title, description, content, created)
values (#{title}, #{description}, #{content}, #{created})
</insert>
<insert id="insertCategory">
insert into blog_category(blog_id, category_id)
values (#{blogId}, #{categoryId})
</insert>
<!--更新博客-->
<update id="updateBlogs" parameterType="com.xubx.springboot_01demo.pojo.Blogs">

View File

@ -11,36 +11,36 @@
</resultMap>
<!-- 查询用户 -->
<select id="findUserByUsername" resultMap="BaseResultMap">
select username, password from register where username = #{username}
select username, password from user where username = #{username}
</select>
<!-- 插入用户 -->
<insert id="insertUser" parameterType="com.xubx.springboot_01demo.pojo.User" useGeneratedKeys="true" keyProperty="id">
insert into register(username, password) values(#{username}, #{password})
insert into user(username, password) values(#{username}, #{password})
</insert>
<!--添加头像-->
<insert id="addAvatar" parameterType="com.xubx.springboot_01demo.pojo.User">
UPDATE register
UPDATE user
SET avatar = #{path}
WHERE username = #{username};
</insert>
<!--获取头像地址-->
<select id="getAvatar" resultType="java.lang.String">
select avatar from register where username = #{username}
select avatar from user where username = #{username}
</select>
<!--修改用户名-->
<insert id="usernameChange" >
UPDATE register
UPDATE user
SET username = #{username}
WHERE username = #{usernameNow}
</insert>
<!--修改密码-->
<insert id="passwordChange" >
UPDATE register
UPDATE user
SET password = #{newPassword}
WHERE username = #{username}
</insert>
<!-- 根据name查密码 -->
<select id="getPasswordByname" resultType="java.lang.String">
select password from register where username = #{username}
select password from user where username = #{username}
</select>
</mapper>