➕ Feat: 部署二期权限管理
This commit is contained in:
parent
d6b1551aaf
commit
2a7642a050
160
commerce_system.sql
Normal file
160
commerce_system.sql
Normal file
@ -0,0 +1,160 @@
|
||||
/*
|
||||
Navicat Premium Data Transfer
|
||||
|
||||
Source Server : commerce_system
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 80024 (8.0.24)
|
||||
Source Host : wzpmc.cn:3306
|
||||
Source Schema : commerce_system
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 80024 (8.0.24)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 27/04/2023 16:14:29
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for auth_account
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `auth_account`;
|
||||
CREATE TABLE `auth_account` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '#',
|
||||
`username` varchar(20) COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户名',
|
||||
`email` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '邮箱',
|
||||
`rel_name` varchar(5) COLLATE utf8mb4_general_ci NOT NULL COMMENT '真实姓名',
|
||||
`password` varchar(255) COLLATE utf8mb4_general_ci NOT NULL COMMENT '密码',
|
||||
`status` tinyint(1) DEFAULT '1' COMMENT '状态',
|
||||
`role_id` int DEFAULT '0' COMMENT '角色',
|
||||
`create_time` timestamp NOT NULL COMMENT '创建时间',
|
||||
`update_time` timestamp NULL DEFAULT NULL COMMENT '最近更新时间',
|
||||
`del` tinyint(1) DEFAULT '0' COMMENT '逻辑删除',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `username` (`username`),
|
||||
UNIQUE KEY `email` (`email`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for auth_permissions
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `auth_permissions`;
|
||||
CREATE TABLE `auth_permissions` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '#',
|
||||
`permission_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '权限名',
|
||||
`permission_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '权限代码',
|
||||
`description` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '介绍',
|
||||
`account_id` int NOT NULL COMMENT '创建者id',
|
||||
`create_time` timestamp NOT NULL COMMENT '创建时间',
|
||||
`update_time` timestamp NULL DEFAULT NULL COMMENT '最后更新时间',
|
||||
`status` tinyint(1) DEFAULT '1' COMMENT '状态',
|
||||
`del` tinyint(1) DEFAULT '0' COMMENT '逻辑删除',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `permission_name` (`permission_name`),
|
||||
UNIQUE KEY `permission_code` (`permission_code`),
|
||||
KEY `account_id` (`account_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for auth_roles
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `auth_roles`;
|
||||
CREATE TABLE `auth_roles` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '#',
|
||||
`role_name` varchar(20) COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色名',
|
||||
`description` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '简介',
|
||||
`account_id` int NOT NULL COMMENT '创建者id',
|
||||
`create_time` timestamp NOT NULL COMMENT '创建时间',
|
||||
`update_time` timestamp NULL DEFAULT NULL COMMENT '最后更新时间',
|
||||
`status` tinyint(1) DEFAULT '1' COMMENT '状态',
|
||||
`del` tinyint(1) DEFAULT '0' COMMENT '逻辑删除',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `role_name` (`role_name`),
|
||||
KEY `account_id` (`account_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for auth_route
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `auth_route`;
|
||||
CREATE TABLE `auth_route` (
|
||||
`id` int NOT NULL COMMENT '#',
|
||||
`path` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '前端访问路径',
|
||||
`name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '前端路由名称',
|
||||
`parent_id` int DEFAULT NULL COMMENT '父组件id',
|
||||
`component` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '前端本地组件路径',
|
||||
`title` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '前端标题栏',
|
||||
`status` blob COMMENT '状态',
|
||||
`create_id` int DEFAULT NULL COMMENT '创建者id',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_id` int DEFAULT NULL COMMENT '最后修改者id',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '最后修改时间',
|
||||
`remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
|
||||
`del` int DEFAULT '0' COMMENT '逻辑删除',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for commission
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `commission`;
|
||||
CREATE TABLE `commission` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '#',
|
||||
`price_min` double(9,2) NOT NULL COMMENT '最小区间',
|
||||
`price_max` double(9,2) NOT NULL COMMENT '最大区间',
|
||||
`commission` double(5,2) NOT NULL COMMENT '佣金',
|
||||
`store_id` int NOT NULL COMMENT '店铺名称',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`del` int DEFAULT '0' COMMENT '逻辑删除',
|
||||
`status` blob COMMENT '状态',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for shop_order
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `shop_order`;
|
||||
CREATE TABLE `shop_order` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '#',
|
||||
`order_no` varchar(30) COLLATE utf8mb4_general_ci NOT NULL COMMENT '订单号',
|
||||
`order_time` datetime NOT NULL COMMENT '下单时间',
|
||||
`order_status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '订单状态',
|
||||
`wang_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '旺旺号',
|
||||
`wechat_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '微信账号',
|
||||
`alipay_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '支付宝账号',
|
||||
`pay_amt` double(10,2) NOT NULL COMMENT '付款金额',
|
||||
`store_id` int NOT NULL COMMENT '店铺id',
|
||||
`commission` double(10,2) DEFAULT NULL COMMENT '佣金',
|
||||
`alipay_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '支付宝收款名称',
|
||||
`rp_name` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '负责人',
|
||||
`rp_wechat_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '负责放单人微信名',
|
||||
`remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
|
||||
`phone_number` varchar(11) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '买家电话',
|
||||
`card_no` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '银行卡号',
|
||||
`flag` int DEFAULT NULL COMMENT '插旗',
|
||||
`flag_remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '插旗备注',
|
||||
`pay_time` datetime DEFAULT NULL COMMENT '付款时间',
|
||||
`address` varchar(255) COLLATE utf8mb4_general_ci NOT NULL COMMENT '收货地址',
|
||||
`shop_id` int DEFAULT NULL COMMENT '商品id',
|
||||
`sku` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'sku',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for store
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `store`;
|
||||
CREATE TABLE `store` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '#',
|
||||
`name` varchar(255) COLLATE utf8mb4_general_ci NOT NULL COMMENT '店铺名称',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`del` int DEFAULT '0' COMMENT '逻辑删除',
|
||||
`status` blob COMMENT '状态',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
8
pom.xml
8
pom.xml
@ -129,4 +129,12 @@
|
||||
<version>3.2.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.xinsin.pojo.Account;
|
||||
import top.xinsin.pojo.AuthAccount;
|
||||
import top.xinsin.service.AccountService;
|
||||
import top.xinsin.util.R;
|
||||
|
||||
@ -24,7 +24,7 @@ public class AccountController {
|
||||
private AccountService accountService;
|
||||
|
||||
@RequestMapping(path = "/changeAccount", method = RequestMethod.POST)
|
||||
public R<String> changeAccount(@RequestBody Account account) {return this.accountService.changeAccount(account);}
|
||||
public R<String> changeAccount(@RequestBody AuthAccount authAccount) {return this.accountService.changeAccount(authAccount);}
|
||||
|
||||
@RequestMapping(path = "/changeStatus", method = RequestMethod.GET)
|
||||
public R<String> changeStatus(@RequestParam("userId") Integer userId, @RequestParam("status") Boolean status) {return this.accountService.changeStatus(userId, status);}
|
||||
|
@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.xinsin.pojo.Account;
|
||||
import top.xinsin.pojo.AuthAccount;
|
||||
import top.xinsin.service.AccountService;
|
||||
import top.xinsin.util.R;
|
||||
|
||||
@ -24,12 +24,12 @@ public class AuthorizeController {
|
||||
|
||||
@RequestMapping(path = "/register", method = RequestMethod.POST)
|
||||
public R<String> register(@RequestParam("username") String username, @RequestParam("relName") String relName, @RequestParam("email") String email, @RequestParam("password") String password, @RequestParam("roleId") Integer roleId) {
|
||||
Account account = new Account();
|
||||
account.setUsername(username);
|
||||
account.setPassword(password);
|
||||
account.setRelName(relName);
|
||||
account.setEmail(email);
|
||||
account.setRoleId(roleId);
|
||||
return this.accountService.register(account);
|
||||
AuthAccount authAccount = new AuthAccount();
|
||||
authAccount.setUsername(username);
|
||||
authAccount.setPassword(password);
|
||||
authAccount.setRelName(relName);
|
||||
authAccount.setEmail(email);
|
||||
authAccount.setRoleId(roleId);
|
||||
return this.accountService.register(authAccount);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import top.xinsin.mapper.AccountMapper;
|
||||
import top.xinsin.pojo.Account;
|
||||
import top.xinsin.pojo.AuthAccount;
|
||||
|
||||
@Component
|
||||
public class AuthorizeInterceptor implements HandlerInterceptor {
|
||||
@ -24,12 +24,12 @@ public class AuthorizeInterceptor implements HandlerInterceptor {
|
||||
Authentication authentication = context.getAuthentication();
|
||||
User user = (User)authentication.getPrincipal();
|
||||
String username = user.getUsername();
|
||||
Account account = accountMapper.selectOne(new LambdaQueryWrapper<Account>()
|
||||
.eq(Account::getUsername,username)
|
||||
AuthAccount authAccount = accountMapper.selectOne(new LambdaQueryWrapper<AuthAccount>()
|
||||
.eq(AuthAccount::getUsername,username)
|
||||
.or()
|
||||
.eq(Account::getEmail,username)
|
||||
.eq(Account::getStatus,true));
|
||||
request.getSession().setAttribute("account", account);
|
||||
.eq(AuthAccount::getEmail,username)
|
||||
.eq(AuthAccount::getStatus,true));
|
||||
request.getSession().setAttribute("account", authAccount);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package top.xinsin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xinsin.pojo.Account;
|
||||
import top.xinsin.pojo.AuthAccount;
|
||||
|
||||
/**
|
||||
* @author xinsin
|
||||
@ -10,5 +10,5 @@ import top.xinsin.pojo.Account;
|
||||
* @version 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface AccountMapper extends BaseMapper<Account> {
|
||||
public interface AccountMapper extends BaseMapper<AuthAccount> {
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package top.xinsin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xinsin.pojo.Permissions;
|
||||
import top.xinsin.pojo.AuthPermissions;
|
||||
|
||||
/**
|
||||
* @author xinsin
|
||||
@ -10,5 +10,5 @@ import top.xinsin.pojo.Permissions;
|
||||
* @version 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface PermissionsMapper extends BaseMapper<Permissions> {
|
||||
public interface PermissionsMapper extends BaseMapper<AuthPermissions> {
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package top.xinsin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xinsin.pojo.Roles;
|
||||
import top.xinsin.pojo.AuthRoles;
|
||||
|
||||
/**
|
||||
* @author xinsin
|
||||
@ -10,5 +10,5 @@ import top.xinsin.pojo.Roles;
|
||||
* @version 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface RolesMapper extends BaseMapper<Roles> {
|
||||
public interface RolesMapper extends BaseMapper<AuthRoles> {
|
||||
}
|
@ -15,8 +15,8 @@ import java.util.Date;
|
||||
* @version 1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("account")
|
||||
public class Account implements Serializable {
|
||||
@TableName("auth_account")
|
||||
public class AuthAccount implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
@ -15,8 +15,8 @@ import java.time.LocalDateTime;
|
||||
* @version 1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("permissions")
|
||||
public class Permissions implements Serializable {
|
||||
@TableName("auth_permissions")
|
||||
public class AuthPermissions implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
@ -15,8 +15,8 @@ import java.time.LocalDateTime;
|
||||
* @version 1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("roles")
|
||||
public class Roles implements Serializable {
|
||||
@TableName("auth_roles")
|
||||
public class AuthRoles implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
@ -1,12 +1,9 @@
|
||||
package top.xinsin.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
@ -15,7 +12,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import top.xinsin.mapper.AccountMapper;
|
||||
import top.xinsin.pojo.Account;
|
||||
import top.xinsin.pojo.AuthAccount;
|
||||
import top.xinsin.util.HttpCodes;
|
||||
import top.xinsin.util.R;
|
||||
|
||||
@ -42,37 +39,37 @@ public class AccountService implements UserDetailsService {
|
||||
if (username == null) {
|
||||
throw new UsernameNotFoundException("用户名不能为空");
|
||||
} else {
|
||||
Account account = this.accountMapper.selectOne(new LambdaQueryWrapper<Account>().eq(Account::getUsername, username).or().eq(Account::getEmail, username).eq(Account::getStatus, true));
|
||||
if (account == null) {
|
||||
AuthAccount authAccount = this.accountMapper.selectOne(new LambdaQueryWrapper<AuthAccount>().eq(AuthAccount::getUsername, username).or().eq(AuthAccount::getEmail, username).eq(AuthAccount::getStatus, true));
|
||||
if (authAccount == null) {
|
||||
throw new UsernameNotFoundException("用户名或密码错误");
|
||||
} else {
|
||||
return User.withUsername(account.getUsername()).password(account.getPassword()).roles(new String[]{"role=" + account.getRoleId(), "id=" + account.getId()}).build();
|
||||
return User.withUsername(authAccount.getUsername()).password(authAccount.getPassword()).roles(new String[]{"role=" + authAccount.getRoleId(), "id=" + authAccount.getId()}).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public R<String> register(Account account) {
|
||||
account.setCreateTime(new Date());
|
||||
account.setStatus(true);
|
||||
account.setPassword(this.encoder.encode(account.getPassword()));
|
||||
int insert = this.accountMapper.insert(account);
|
||||
public R<String> register(AuthAccount authAccount) {
|
||||
authAccount.setCreateTime(new Date());
|
||||
authAccount.setStatus(true);
|
||||
authAccount.setPassword(this.encoder.encode(authAccount.getPassword()));
|
||||
int insert = this.accountMapper.insert(authAccount);
|
||||
return insert == 1 ? R.success("注册成功") : R.failed(HttpCodes.HTTP_CODES555, "注册失败,您的用户名或者邮箱已经被注册过了");
|
||||
}
|
||||
|
||||
public R<String> changeAccount(Account account) {
|
||||
if (account.getPassword() != null) {
|
||||
account.setPassword(this.encoder.encode(account.getPassword()));
|
||||
public R<String> changeAccount(AuthAccount authAccount) {
|
||||
if (authAccount.getPassword() != null) {
|
||||
authAccount.setPassword(this.encoder.encode(authAccount.getPassword()));
|
||||
}
|
||||
|
||||
int update = this.accountMapper.updateById(account);
|
||||
int update = this.accountMapper.updateById(authAccount);
|
||||
return update == 1 ? R.success("修改用户信息成功") : R.failed(HttpCodes.HTTP_CODES555, "修改用户信息失败,请联系服务器管理员");
|
||||
}
|
||||
|
||||
public R<String> changeStatus(Integer userId, Boolean status) {
|
||||
Account account = new Account();
|
||||
account.setId(userId);
|
||||
account.setStatus(status);
|
||||
int i = this.accountMapper.updateById(account);
|
||||
AuthAccount authAccount = new AuthAccount();
|
||||
authAccount.setId(userId);
|
||||
authAccount.setStatus(status);
|
||||
int i = this.accountMapper.updateById(authAccount);
|
||||
if (i == 1) {
|
||||
return status ? R.success("启用该用户成功") : R.success("禁用该用户成功");
|
||||
} else {
|
||||
@ -81,19 +78,19 @@ public class AccountService implements UserDetailsService {
|
||||
}
|
||||
|
||||
public R<String> changePassword(Integer userId, String oldPassword, String newPassword) {
|
||||
Account account = new Account();
|
||||
account.setPassword(this.encoder.encode(newPassword));
|
||||
LambdaQueryWrapper<Account> accountLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
accountLambdaQueryWrapper.eq(Account::getId, userId).eq(Account::getPassword, this.encoder.encode(oldPassword));
|
||||
int update = this.accountMapper.update(account, accountLambdaQueryWrapper);
|
||||
AuthAccount authAccount = new AuthAccount();
|
||||
authAccount.setPassword(this.encoder.encode(newPassword));
|
||||
LambdaQueryWrapper<AuthAccount> accountLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
accountLambdaQueryWrapper.eq(AuthAccount::getId, userId).eq(AuthAccount::getPassword, this.encoder.encode(oldPassword));
|
||||
int update = this.accountMapper.update(authAccount, accountLambdaQueryWrapper);
|
||||
return update == 1 ? R.success("修改密码成功") : R.failed(HttpCodes.HTTP_CODES555, "修改密码失败,请联系服务器管理员");
|
||||
}
|
||||
|
||||
public R<JSONObject> getUser(Integer page, Integer num) {
|
||||
Page<Account> accountPage = new Page<>((long)page, (long)num);
|
||||
Page<Account> accountPage1 = this.accountMapper.selectPage(accountPage, null);
|
||||
Page<AuthAccount> accountPage = new Page<>((long)page, (long)num);
|
||||
Page<AuthAccount> accountPage1 = this.accountMapper.selectPage(accountPage, null);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
List<Account> collect = accountPage1.getRecords().stream().peek((e) -> {
|
||||
List<AuthAccount> collect = accountPage1.getRecords().stream().peek((e) -> {
|
||||
e.setPassword((String)null);
|
||||
}).toList();
|
||||
jsonObject.fluentPut("info", collect).fluentPut("total", accountPage1.getTotal());
|
||||
|
@ -6,10 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import top.xinsin.mapper.CommissionMapper;
|
||||
import top.xinsin.pojo.Account;
|
||||
import top.xinsin.pojo.Commission;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import top.xinsin.pojo.Store;
|
||||
import top.xinsin.util.HttpCodes;
|
||||
import top.xinsin.util.R;
|
||||
|
||||
|
@ -149,7 +149,7 @@ public class OrderService {
|
||||
@SneakyThrows
|
||||
public void downloadTemplate(HttpServletResponse response) {
|
||||
try {
|
||||
File file = new File("template/example.xlsx");
|
||||
File file = new File("./template/example.xlsx");
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
|
||||
byte[] bytes = new byte[bufferedInputStream.available()];
|
||||
|
@ -2,9 +2,9 @@ server:
|
||||
port: 8001
|
||||
spring:
|
||||
datasource:
|
||||
username: commerce_system
|
||||
password: Jix656dzD6St4YCn
|
||||
url: jdbc:mysql://www.wzpmc.cn:3306/commerce_system?serverTimezone=UTC-8
|
||||
username: commerce
|
||||
password: Jix656dzD6St4YCn_
|
||||
url: jdbc:mysql://localhost:3306/commerce_system?serverTimezone=UTC-8
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# druid配置
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
@ -36,8 +36,8 @@ spring:
|
||||
user:
|
||||
password: 123456
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# configuration:
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
global-config:
|
||||
db-config:
|
||||
logic-delete-field: del # 全局逻辑删除的实体字段名(since 3.3.0,配置后可以忽略不配置步骤2)
|
||||
|
@ -3,7 +3,7 @@
|
||||
<mapper namespace="top.xinsin.mapper.AccountMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="top.xinsin.pojo.Account">
|
||||
<resultMap id="BaseResultMap" type="top.xinsin.pojo.AuthAccount">
|
||||
<id column="id" property="id" />
|
||||
<result column="username" property="username" />
|
||||
<result column="email" property="email" />
|
||||
|
@ -3,7 +3,7 @@
|
||||
<mapper namespace="top.xinsin.mapper.PermissionsMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="top.xinsin.pojo.Permissions">
|
||||
<resultMap id="BaseResultMap" type="top.xinsin.pojo.AuthPermissions">
|
||||
<id column="id" property="id" />
|
||||
<result column="permission_name" property="permissionName" />
|
||||
<result column="permission_code" property="permissionCode" />
|
||||
|
@ -3,7 +3,7 @@
|
||||
<mapper namespace="top.xinsin.mapper.RolesMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="top.xinsin.pojo.Roles">
|
||||
<resultMap id="BaseResultMap" type="top.xinsin.pojo.AuthRoles">
|
||||
<id column="id" property="id" />
|
||||
<result column="role_name" property="roleName" />
|
||||
<result column="description" property="description" />
|
||||
|
BIN
src/main/resources/template/example.xlsx
Normal file
BIN
src/main/resources/template/example.xlsx
Normal file
Binary file not shown.
@ -16,7 +16,7 @@ public class MainTest {
|
||||
|
||||
@Test
|
||||
public void test01(){
|
||||
System.out.println(new BCryptPasswordEncoder().encode(DigestUtils.md5Hex("xinsin")));
|
||||
System.out.println(new BCryptPasswordEncoder().encode(DigestUtils.md5Hex("12345678")));
|
||||
System.out.println(DigestUtils.md5Hex("xinsin"));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user