feat:增加密码管理接口
This commit is contained in:
@@ -3,7 +3,7 @@ package com.cxx.admin.controller;
|
|||||||
import com.cxx.admin.service.AccountService;
|
import com.cxx.admin.service.AccountService;
|
||||||
import com.cxx.common.ReadView;
|
import com.cxx.common.ReadView;
|
||||||
import com.cxx.common.WriteView;
|
import com.cxx.common.WriteView;
|
||||||
import com.cxx.admin.dto.user.AccountDto;
|
import com.cxx.common.dto.AccountDto;
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.cxx.admin.controller;
|
package com.cxx.admin.controller;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import com.cxx.common.dto.user.SessionDto;
|
import com.cxx.common.dto.SessionDto;
|
||||||
import com.cxx.admin.service.SessionService;
|
import com.cxx.admin.service.SessionService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cxx.admin.dao;
|
package com.cxx.admin.dao;
|
||||||
|
|
||||||
import com.cxx.admin.dto.user.AccountDto;
|
import com.cxx.common.dto.AccountDto;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.cxx.admin.service;
|
package com.cxx.admin.service;
|
||||||
|
|
||||||
|
|
||||||
import com.cxx.admin.dto.user.AccountDto;
|
import com.cxx.common.dto.AccountDto;
|
||||||
import com.cxx.common.entity.Account;
|
import com.cxx.common.entity.Account;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cxx.admin.service;
|
package com.cxx.admin.service;
|
||||||
|
|
||||||
import com.cxx.common.dto.user.SessionDto;
|
import com.cxx.common.dto.SessionDto;
|
||||||
|
|
||||||
public interface SessionService {
|
public interface SessionService {
|
||||||
SessionDto create(String name, String password);
|
SessionDto create(String name, String password);
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package com.cxx.admin.service.impl;
|
|||||||
|
|
||||||
import cn.dev33.satoken.secure.BCrypt;
|
import cn.dev33.satoken.secure.BCrypt;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.cxx.admin.dao.AccountDao;
|
|
||||||
import com.cxx.admin.service.AccountService;
|
import com.cxx.admin.service.AccountService;
|
||||||
import com.cxx.admin.dto.user.AccountDto;
|
import com.cxx.admin.dao.AccountDao;
|
||||||
|
import com.cxx.common.dto.AccountDto;
|
||||||
import com.cxx.common.entity.Account;
|
import com.cxx.common.entity.Account;
|
||||||
import com.cxx.common.entity.User;
|
import com.cxx.common.entity.User;
|
||||||
import com.cxx.common.mapper.AccountMapper;
|
import com.cxx.common.mapper.AccountMapper;
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import cn.dev33.satoken.secure.BCrypt;
|
|||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.cxx.common.dto.user.SessionDto;
|
|
||||||
import com.cxx.admin.service.SessionService;
|
import com.cxx.admin.service.SessionService;
|
||||||
import com.cxx.common.dto.user.UserDto;
|
import com.cxx.common.dto.SessionDto;
|
||||||
|
import com.cxx.common.dto.UserDto;
|
||||||
import com.cxx.common.entity.Account;
|
import com.cxx.common.entity.Account;
|
||||||
import com.cxx.common.entity.User;
|
import com.cxx.common.entity.User;
|
||||||
import com.cxx.common.mapper.AccountMapper;
|
import com.cxx.common.mapper.AccountMapper;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ spring:
|
|||||||
name: @project.artifactId@
|
name: @project.artifactId@
|
||||||
version: @project.version@
|
version: @project.version@
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: prod
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
max-file-size: 10MB
|
max-file-size: 10MB
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cxx.admin.dao.AccountDao">
|
<mapper namespace="com.cxx.admin.dao.AccountDao">
|
||||||
<select id="queryAccount" resultType="com.cxx.admin.dto.user.AccountDto">
|
<select id="queryAccount" resultType="com.cxx.common.dto.AccountDto">
|
||||||
SELECT b.id AS id,
|
SELECT b.id AS id,
|
||||||
b.account_name AS accountName,
|
b.account_name AS accountName,
|
||||||
a.username AS username,
|
a.username AS username,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cxx.admin.dto.user;
|
package com.cxx.common.dto;
|
||||||
|
|
||||||
import com.cxx.common.PlainView;
|
import com.cxx.common.PlainView;
|
||||||
import com.cxx.common.ReadView;
|
import com.cxx.common.ReadView;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cxx.common.dto.user;
|
package com.cxx.common.dto;
|
||||||
|
|
||||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cxx.common.dto.user;
|
package com.cxx.common.dto;
|
||||||
|
|
||||||
import com.cxx.common.PlainView;
|
import com.cxx.common.PlainView;
|
||||||
import com.cxx.common.ReadView;
|
import com.cxx.common.ReadView;
|
||||||
@@ -32,6 +32,12 @@
|
|||||||
<artifactId>weixin-java-mp</artifactId>
|
<artifactId>weixin-java-mp</artifactId>
|
||||||
<version>4.7.5.B</version>
|
<version>4.7.5.B</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 加密工具 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-crypto</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.cxx.home.controller;
|
||||||
|
|
||||||
|
import com.cxx.common.ReadView;
|
||||||
|
import com.cxx.common.WriteView;
|
||||||
|
import com.cxx.home.dto.password.PasswordDto;
|
||||||
|
import com.cxx.home.service.PasswordService;
|
||||||
|
import com.cxx.home.vo.PasswordQueryVo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/password")
|
||||||
|
@Tag(name = "密码管理")
|
||||||
|
public class PasswordController {
|
||||||
|
@Resource
|
||||||
|
private PasswordService passwordService;
|
||||||
|
|
||||||
|
@Operation(summary = "查询密码记录")
|
||||||
|
@GetMapping("")
|
||||||
|
public @JsonView(ReadView.class) List<PasswordDto> queryPassword(PasswordQueryVo query) {
|
||||||
|
return passwordService.query(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "新增密码记录")
|
||||||
|
@PostMapping("")
|
||||||
|
public Boolean addPassword(@RequestBody @JsonView(WriteView.class) @Validated PasswordDto passwordDto) {
|
||||||
|
return passwordService.add(passwordDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新密码记录")
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public Boolean updatePassword(@PathVariable("id") long id,
|
||||||
|
@RequestBody @JsonView(WriteView.class) PasswordDto passwordDto) {
|
||||||
|
return passwordService.update(id, passwordDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除密码记录")
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public Boolean deletePassword(@PathVariable("id") long id) {
|
||||||
|
return passwordService.delete(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "查询密码记录类别")
|
||||||
|
@GetMapping("/category")
|
||||||
|
public List<String> queryPasswordCategory() {
|
||||||
|
return passwordService.queryCategory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.cxx.home.controller;
|
package com.cxx.home.controller;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
|
import com.cxx.common.dto.SessionDto;
|
||||||
import com.cxx.home.service.SessionService;
|
import com.cxx.home.service.SessionService;
|
||||||
import com.cxx.common.dto.user.SessionDto;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.cxx.admin.controller;
|
package com.cxx.home.controller;
|
||||||
|
|
||||||
import com.cxx.admin.service.UserService;
|
|
||||||
import com.cxx.common.ReadView;
|
import com.cxx.common.ReadView;
|
||||||
import com.cxx.common.WriteView;
|
import com.cxx.common.WriteView;
|
||||||
import com.cxx.common.dto.user.UserDto;
|
import com.cxx.common.dto.UserDto;
|
||||||
|
import com.cxx.home.service.UserService;
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
15
home-service/src/main/java/com/cxx/home/dao/PasswordDao.java
Normal file
15
home-service/src/main/java/com/cxx/home/dao/PasswordDao.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package com.cxx.home.dao;
|
||||||
|
|
||||||
|
import com.cxx.home.dto.password.PasswordDto;
|
||||||
|
import com.cxx.home.vo.PasswordQueryVo;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface PasswordDao {
|
||||||
|
List<PasswordDto> query(@Param("query") PasswordQueryVo query);
|
||||||
|
|
||||||
|
List<String> queryCategory();
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.cxx.home.dto.password;
|
||||||
|
|
||||||
|
import com.cxx.common.PlainView;
|
||||||
|
import com.cxx.common.ReadView;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@JsonView(PlainView.class)
|
||||||
|
public class PasswordDto
|
||||||
|
{
|
||||||
|
@Schema(description = "id")
|
||||||
|
@JsonView(ReadView.class)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "标题")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Schema(description = "网站")
|
||||||
|
private String website;
|
||||||
|
|
||||||
|
@Schema(description = "用户名")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@Schema(description = "密码")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Schema(description = "类别")
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
@Schema(description = "所属人")
|
||||||
|
private String owner;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cxx.admin.dto.user;
|
package com.cxx.home.dto.user;
|
||||||
|
|
||||||
import com.cxx.common.PlainView;
|
import com.cxx.common.PlainView;
|
||||||
import com.cxx.common.ReadView;
|
import com.cxx.common.ReadView;
|
||||||
33
home-service/src/main/java/com/cxx/home/entity/Password.java
Normal file
33
home-service/src/main/java/com/cxx/home/entity/Password.java
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package com.cxx.home.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.cxx.framework.data.AbstractEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("password")
|
||||||
|
public class Password extends AbstractEntity {
|
||||||
|
@TableField(value = "title")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@TableField("website")
|
||||||
|
private String website;
|
||||||
|
|
||||||
|
@TableField("username")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@TableField("password")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@TableField("category")
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
@TableField("owner")
|
||||||
|
private String owner;
|
||||||
|
|
||||||
|
@TableField("remark")
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
package com.cxx.home.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.cxx.home.entity.Password;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface PasswordMapper extends BaseMapper<Password> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.cxx.home.service;
|
||||||
|
|
||||||
|
import com.cxx.home.dto.password.PasswordDto;
|
||||||
|
import com.cxx.home.vo.PasswordQueryVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface PasswordService {
|
||||||
|
Boolean add(PasswordDto passwordDto);
|
||||||
|
|
||||||
|
Boolean update(Long id, PasswordDto passwordDto);
|
||||||
|
|
||||||
|
Boolean delete(Long id);
|
||||||
|
|
||||||
|
List<PasswordDto> query(PasswordQueryVo query);
|
||||||
|
|
||||||
|
List<String> queryCategory();
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cxx.home.service;
|
package com.cxx.home.service;
|
||||||
|
|
||||||
import com.cxx.common.dto.user.SessionDto;
|
import com.cxx.common.dto.SessionDto;
|
||||||
|
|
||||||
public interface SessionService {
|
public interface SessionService {
|
||||||
SessionDto create(String name, String password);
|
SessionDto create(String name, String password);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.cxx.admin.service;
|
package com.cxx.home.service;
|
||||||
|
|
||||||
|
|
||||||
import com.cxx.common.dto.user.UserDto;
|
import com.cxx.common.dto.UserDto;
|
||||||
|
|
||||||
public interface UserService {
|
public interface UserService {
|
||||||
UserDto queryUser(Long id);
|
UserDto queryUser(Long id);
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package com.cxx.home.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.crypto.SecureUtil;
|
||||||
|
import com.cxx.framework.web.CustomException;
|
||||||
|
import com.cxx.home.dao.PasswordDao;
|
||||||
|
import com.cxx.home.dto.password.PasswordDto;
|
||||||
|
import com.cxx.home.entity.Password;
|
||||||
|
import com.cxx.home.mapper.PasswordMapper;
|
||||||
|
import com.cxx.home.service.PasswordService;
|
||||||
|
import com.cxx.home.vo.PasswordQueryVo;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PasswordServiceImpl implements PasswordService {
|
||||||
|
@Resource
|
||||||
|
private PasswordDao passwordDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PasswordMapper passwordMapper;
|
||||||
|
|
||||||
|
private static final String SECRET_KEY = "MySuperSecretKey";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean add(PasswordDto passwordDto) {
|
||||||
|
Password password = new Password();
|
||||||
|
BeanUtils.copyProperties(passwordDto, password);
|
||||||
|
password.setPassword(encryptPassword(passwordDto.getPassword()));
|
||||||
|
|
||||||
|
return passwordMapper.insert(password) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean update(Long id, PasswordDto passwordDto) {
|
||||||
|
if (passwordMapper.selectById(id) == null) {
|
||||||
|
throw new CustomException("该密码记录不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
Password password = new Password();
|
||||||
|
BeanUtils.copyProperties(passwordDto, password);
|
||||||
|
password.setId(id);
|
||||||
|
password.setPassword(encryptPassword(passwordDto.getPassword()));
|
||||||
|
return passwordMapper.updateById(password) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean delete(Long id) {
|
||||||
|
if (passwordMapper.selectById(id) == null) {
|
||||||
|
throw new CustomException("该密码记录不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
return passwordMapper.deleteById(id) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PasswordDto> query(PasswordQueryVo query) {
|
||||||
|
List<PasswordDto> passwordList = passwordDao.query(query);
|
||||||
|
|
||||||
|
passwordList.forEach(item -> item.setPassword(decryptStr(item.getPassword())));
|
||||||
|
return passwordList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String > queryCategory() {
|
||||||
|
return passwordDao.queryCategory();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String encryptPassword(String password) {
|
||||||
|
return SecureUtil.aes(SECRET_KEY.getBytes()).encryptBase64(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String decryptStr(String password) {
|
||||||
|
return SecureUtil.aes(SECRET_KEY.getBytes()).decryptStr(password);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,9 +5,8 @@ import cn.dev33.satoken.secure.BCrypt;
|
|||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.cxx.common.dto.SessionDto;
|
||||||
import com.cxx.common.dto.user.SessionDto;
|
import com.cxx.common.dto.UserDto;
|
||||||
import com.cxx.common.dto.user.UserDto;
|
|
||||||
import com.cxx.common.entity.Account;
|
import com.cxx.common.entity.Account;
|
||||||
import com.cxx.common.entity.User;
|
import com.cxx.common.entity.User;
|
||||||
import com.cxx.common.mapper.AccountMapper;
|
import com.cxx.common.mapper.AccountMapper;
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package com.cxx.admin.service.impl;
|
package com.cxx.home.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.cxx.admin.service.AccountService;
|
import com.cxx.common.dto.UserDto;
|
||||||
import com.cxx.admin.service.UserService;
|
import com.cxx.common.entity.Account;
|
||||||
import com.cxx.common.dto.user.UserDto;
|
|
||||||
import com.cxx.common.entity.User;
|
import com.cxx.common.entity.User;
|
||||||
|
import com.cxx.common.mapper.AccountMapper;
|
||||||
import com.cxx.common.mapper.UserMapper;
|
import com.cxx.common.mapper.UserMapper;
|
||||||
import com.cxx.framework.web.CustomException;
|
import com.cxx.framework.web.CustomException;
|
||||||
|
import com.cxx.home.service.UserService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -18,7 +19,7 @@ public class UserServiceImpl implements UserService {
|
|||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AccountService accountService;
|
private AccountMapper accountMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDto queryUser(Long id) {
|
public UserDto queryUser(Long id) {
|
||||||
@@ -29,7 +30,9 @@ public class UserServiceImpl implements UserService {
|
|||||||
|
|
||||||
UserDto userDto = new UserDto();
|
UserDto userDto = new UserDto();
|
||||||
BeanUtils.copyProperties(user, userDto);
|
BeanUtils.copyProperties(user, userDto);
|
||||||
userDto.setAccountName(accountService.queryAccountByUserId(id).getAccountName());
|
|
||||||
|
LambdaQueryWrapper<Account> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
userDto.setAccountName(accountMapper.selectOne(queryWrapper.eq(Account::getUserId, id)).getAccountName());
|
||||||
return userDto;
|
return userDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
package com.cxx.home.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class PasswordQueryVo {
|
||||||
|
@Schema(description = "类别")
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
@Schema(description = "所属人")
|
||||||
|
private String owner;
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ spring:
|
|||||||
name: @project.artifactId@
|
name: @project.artifactId@
|
||||||
version: @project.version@
|
version: @project.version@
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: prod
|
||||||
mail:
|
mail:
|
||||||
host: smtp.163.com
|
host: smtp.163.com
|
||||||
port: 465
|
port: 465
|
||||||
|
|||||||
31
home-service/src/main/resources/mapper/PasswordMapper.xml
Normal file
31
home-service/src/main/resources/mapper/PasswordMapper.xml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?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.cxx.home.dao.PasswordDao">
|
||||||
|
<select id="query" resultType="com.cxx.home.dto.password.PasswordDto">
|
||||||
|
SELECT
|
||||||
|
id AS id,
|
||||||
|
title AS title,
|
||||||
|
website AS website,
|
||||||
|
username AS username,
|
||||||
|
password AS password,
|
||||||
|
category AS category,
|
||||||
|
owner AS owner,
|
||||||
|
remark AS remark
|
||||||
|
FROM
|
||||||
|
password
|
||||||
|
<where>
|
||||||
|
<if test="query.category != null and query.category != ''">
|
||||||
|
category = #{query.category}
|
||||||
|
</if>
|
||||||
|
<if test="query.owner != null and query.owner != ''">
|
||||||
|
AND owner = #{query.owner}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="queryCategory" resultType="string">
|
||||||
|
SELECT DISTINCT category
|
||||||
|
FROM password
|
||||||
|
WHERE category IS NOT NULL AND category != '';
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user