新增jd-api项目
This commit is contained in:
parent
7f39a49dc6
commit
1ad5033e8b
|
|
@ -11,7 +11,7 @@
|
||||||
Target Server Version : 80032
|
Target Server Version : 80032
|
||||||
File Encoding : 65001
|
File Encoding : 65001
|
||||||
|
|
||||||
Date: 01/03/2024 18:47:38
|
Date: 01/03/2024 19:24:01
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
|
|
@ -88,7 +88,7 @@ CREATE TABLE `sys_platform` (
|
||||||
-- Records of sys_platform
|
-- Records of sys_platform
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `sys_platform` VALUES (1, '天猫', 'TMALL', '12175777', '368dbbd183a77d551735be13f59bbcda');
|
INSERT INTO `sys_platform` VALUES (1, '天猫', 'TMALL', '12175777', '368dbbd183a77d551735be13f59bbcda');
|
||||||
INSERT INTO `sys_platform` VALUES (2, '京东', 'JD', NULL, NULL);
|
INSERT INTO `sys_platform` VALUES (2, '京东', 'JD', 'FB4CC3688E6F9065D4FF510A53BB60FF', '40e8c8b2427f4e6db8f4a39af27d719e');
|
||||||
INSERT INTO `sys_platform` VALUES (3, '抖店', 'DOUDIAN', NULL, NULL);
|
INSERT INTO `sys_platform` VALUES (3, '抖店', 'DOUDIAN', NULL, NULL);
|
||||||
INSERT INTO `sys_platform` VALUES (4, '拼多多', 'PDD', NULL, NULL);
|
INSERT INTO `sys_platform` VALUES (4, '拼多多', 'PDD', NULL, NULL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
|
|
@ -0,0 +1,118 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.qihang</groupId>
|
||||||
|
<artifactId>qihang-oms</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>com.qihang.jd</groupId>
|
||||||
|
<artifactId>jd-api</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>jd-api</name>
|
||||||
|
<url>http://maven.apache.org</url>
|
||||||
|
<properties>
|
||||||
|
<java.version>17</java.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<spring-boot.version>3.0.2</spring-boot.version>
|
||||||
|
<spring-cloud-alibaba.version>2022.0.0.0</spring-cloud-alibaba.version>
|
||||||
|
<jwt.version>0.11.5</jwt.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--SpringCloud Alibaba nacos 服务发现依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.qihang</groupId>
|
||||||
|
<artifactId>security</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>8.0.33</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||||
|
<version>3.5.5</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud-alibaba.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>17</source>
|
||||||
|
<target>17</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>com.example.demo.DemoApplication</mainClass>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>repackage</id>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.qihang.jd;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hello world!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@EnableDiscoveryClient
|
||||||
|
@ComponentScan(basePackages={"com.qihang"})
|
||||||
|
//@MapperScan("com.qihang.jd.mapper")
|
||||||
|
@SpringBootApplication
|
||||||
|
public class JdApi
|
||||||
|
{
|
||||||
|
public static void main( String[] args )
|
||||||
|
{
|
||||||
|
System.out.println( "Hello jd-api!" );
|
||||||
|
SpringApplication.run(JdApi.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.qihang.jd.config;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@MapperScan("com.qihang.jd.mapper")
|
||||||
|
public class MybatisPlusConfig {
|
||||||
|
@Bean
|
||||||
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); //注意使用哪种数据库
|
||||||
|
return interceptor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.qihang.jd.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class HomeController {
|
||||||
|
@GetMapping("/")
|
||||||
|
public String home(){
|
||||||
|
return "{'code':0,'msg':'请通过api访问'}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,130 @@
|
||||||
|
package com.qihang.jd.mapper;
|
||||||
|
|
||||||
|
import com.qihang.security.entity.SysUser;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户表 数据层
|
||||||
|
*
|
||||||
|
* @author qihang
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SysUserMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 根据条件分页查询用户列表
|
||||||
|
*
|
||||||
|
* @param sysUser 用户信息
|
||||||
|
* @return 用户信息集合信息
|
||||||
|
*/
|
||||||
|
public List<SysUser> selectUserList(SysUser sysUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件分页查询已配用户角色列表
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 用户信息集合信息
|
||||||
|
*/
|
||||||
|
public List<SysUser> selectAllocatedList(SysUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件分页查询未分配用户角色列表
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 用户信息集合信息
|
||||||
|
*/
|
||||||
|
public List<SysUser> selectUnallocatedList(SysUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过用户名查询用户
|
||||||
|
*
|
||||||
|
* @param userName 用户名
|
||||||
|
* @return 用户对象信息
|
||||||
|
*/
|
||||||
|
public SysUser selectUserByUserName(String userName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过用户ID查询用户
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 用户对象信息
|
||||||
|
*/
|
||||||
|
public SysUser selectUserById(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertUser(SysUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateUser(SysUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户头像
|
||||||
|
*
|
||||||
|
* @param userName 用户名
|
||||||
|
* @param avatar 头像地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateUserAvatar(@Param("userName") String userName, @Param("avatar") String avatar);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置用户密码
|
||||||
|
*
|
||||||
|
* @param userName 用户名
|
||||||
|
* @param password 密码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int resetUserPwd(@Param("userName") String userName, @Param("password") String password);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过用户ID删除用户
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteUserById(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除用户信息
|
||||||
|
*
|
||||||
|
* @param userIds 需要删除的用户ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteUserByIds(Long[] userIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验用户名称是否唯一
|
||||||
|
*
|
||||||
|
* @param userName 用户名称
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public SysUser checkUserNameUnique(String userName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验手机号码是否唯一
|
||||||
|
*
|
||||||
|
* @param phonenumber 手机号码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public SysUser checkPhoneUnique(String phonenumber);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验email是否唯一
|
||||||
|
*
|
||||||
|
* @param email 用户邮箱
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public SysUser checkEmailUnique(String email);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,293 @@
|
||||||
|
package com.qihang.jd.service.impl;
|
||||||
|
|
||||||
|
import com.qihang.common.common.ServiceException;
|
||||||
|
import com.qihang.common.constant.UserConstants;
|
||||||
|
import com.qihang.common.utils.StringUtils;
|
||||||
|
import com.qihang.security.entity.SysUser;
|
||||||
|
import com.qihang.security.service.ISysUserService;
|
||||||
|
import com.qihang.jd.mapper.SysUserMapper;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户 业务层处理
|
||||||
|
*
|
||||||
|
* @author qihang
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysUserServiceImpl implements ISysUserService
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysUserMapper userMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件分页查询用户列表
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 用户信息集合信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysUser> selectUserList(SysUser user)
|
||||||
|
{
|
||||||
|
return userMapper.selectUserList(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件分页查询已分配用户角色列表
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 用户信息集合信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysUser> selectAllocatedList(SysUser user)
|
||||||
|
{
|
||||||
|
return userMapper.selectAllocatedList(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件分页查询未分配用户角色列表
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 用户信息集合信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysUser> selectUnallocatedList(SysUser user)
|
||||||
|
{
|
||||||
|
return userMapper.selectUnallocatedList(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过用户名查询用户
|
||||||
|
*
|
||||||
|
* @param userName 用户名
|
||||||
|
* @return 用户对象信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SysUser selectUserByUserName(String userName)
|
||||||
|
{
|
||||||
|
return userMapper.selectUserByUserName(userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过用户ID查询用户
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 用户对象信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SysUser selectUserById(Long userId)
|
||||||
|
{
|
||||||
|
return userMapper.selectUserById(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验用户名称是否唯一
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean checkUserNameUnique(SysUser user)
|
||||||
|
{
|
||||||
|
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||||
|
SysUser info = userMapper.checkUserNameUnique(user.getUserName());
|
||||||
|
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||||
|
{
|
||||||
|
return UserConstants.NOT_UNIQUE;
|
||||||
|
}
|
||||||
|
return UserConstants.UNIQUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验手机号码是否唯一
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean checkPhoneUnique(SysUser user)
|
||||||
|
{
|
||||||
|
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||||
|
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
|
||||||
|
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||||
|
{
|
||||||
|
return UserConstants.NOT_UNIQUE;
|
||||||
|
}
|
||||||
|
return UserConstants.UNIQUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验email是否唯一
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean checkEmailUnique(SysUser user)
|
||||||
|
{
|
||||||
|
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||||
|
SysUser info = userMapper.checkEmailUnique(user.getEmail());
|
||||||
|
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||||
|
{
|
||||||
|
return UserConstants.NOT_UNIQUE;
|
||||||
|
}
|
||||||
|
return UserConstants.UNIQUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验用户是否允许操作
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void checkUserAllowed(SysUser user)
|
||||||
|
{
|
||||||
|
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin())
|
||||||
|
{
|
||||||
|
throw new ServiceException("不允许操作超级管理员用户");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增保存用户信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public int insertUser(SysUser user)
|
||||||
|
{
|
||||||
|
// 新增用户信息
|
||||||
|
int rows = userMapper.insertUser(user);
|
||||||
|
// // 新增用户岗位关联
|
||||||
|
// insertUserPost(user);
|
||||||
|
// // 新增用户与角色管理
|
||||||
|
// insertUserRole(user);
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册用户信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean registerUser(SysUser user)
|
||||||
|
{
|
||||||
|
return userMapper.insertUser(user) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改保存用户信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public int updateUser(SysUser user)
|
||||||
|
{
|
||||||
|
Long userId = user.getUserId();
|
||||||
|
// // 删除用户与角色关联
|
||||||
|
// userRoleMapper.deleteUserRoleByUserId(userId);
|
||||||
|
// // 新增用户与角色管理
|
||||||
|
// insertUserRole(user);
|
||||||
|
// // 删除用户与岗位关联
|
||||||
|
// userPostMapper.deleteUserPostByUserId(userId);
|
||||||
|
// 新增用户与岗位管理
|
||||||
|
// insertUserPost(user);
|
||||||
|
return userMapper.updateUser(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户状态
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateUserStatus(SysUser user)
|
||||||
|
{
|
||||||
|
return userMapper.updateUser(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户基本信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateUserProfile(SysUser user)
|
||||||
|
{
|
||||||
|
return userMapper.updateUser(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户头像
|
||||||
|
*
|
||||||
|
* @param userName 用户名
|
||||||
|
* @param avatar 头像地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean updateUserAvatar(String userName, String avatar)
|
||||||
|
{
|
||||||
|
return userMapper.updateUserAvatar(userName, avatar) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置用户密码
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int resetPwd(SysUser user)
|
||||||
|
{
|
||||||
|
return userMapper.updateUser(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置用户密码
|
||||||
|
*
|
||||||
|
* @param userName 用户名
|
||||||
|
* @param password 密码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int resetUserPwd(String userName, String password)
|
||||||
|
{
|
||||||
|
return userMapper.resetUserPwd(userName, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过用户ID删除用户
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public int deleteUserById(Long userId)
|
||||||
|
{
|
||||||
|
// // 删除用户与角色关联
|
||||||
|
// userRoleMapper.deleteUserRoleByUserId(userId);
|
||||||
|
// // 删除用户与岗位表
|
||||||
|
// userPostMapper.deleteUserPostByUserId(userId);
|
||||||
|
return userMapper.deleteUserById(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
spring:
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
serverAddr: 127.0.0.1:8848
|
||||||
|
discovery:
|
||||||
|
server-addr: 127.0.0.1:8848
|
||||||
|
config:
|
||||||
|
import:
|
||||||
|
- nacos:qihang-oms.yaml?refresh=true
|
||||||
|
application:
|
||||||
|
name: jd-api
|
||||||
|
security:
|
||||||
|
user:
|
||||||
|
name: admin
|
||||||
|
password: password
|
||||||
|
basic:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# 授权规则
|
||||||
|
security:
|
||||||
|
rules:
|
||||||
|
- pattern: /api/** # 定义需要授权的URL模式
|
||||||
|
|
||||||
|
server:
|
||||||
|
port: 8083
|
||||||
|
|
||||||
|
|
||||||
|
mybatis-plus:
|
||||||
|
mapper-locations: classpath*:mapper/**/*Mapper.xml
|
||||||
|
type-aliases-package: com.qihang.jd.domain;com.qihang.security.entity;
|
||||||
|
configuration:
|
||||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 开启sql日志
|
||||||
|
|
@ -0,0 +1,195 @@
|
||||||
|
<?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.qihang.jd.mapper.SysUserMapper">
|
||||||
|
|
||||||
|
<resultMap type="SysUser" id="SysUserResult">
|
||||||
|
<id property="userId" column="user_id" />
|
||||||
|
<result property="deptId" column="dept_id" />
|
||||||
|
<result property="userName" column="user_name" />
|
||||||
|
<result property="nickName" column="nick_name" />
|
||||||
|
<result property="email" column="email" />
|
||||||
|
<result property="phonenumber" column="phonenumber" />
|
||||||
|
<result property="sex" column="sex" />
|
||||||
|
<result property="avatar" column="avatar" />
|
||||||
|
<result property="password" column="password" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="delFlag" column="del_flag" />
|
||||||
|
<result property="loginIp" column="login_ip" />
|
||||||
|
<result property="loginDate" column="login_date" />
|
||||||
|
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<sql id="selectUserVo">
|
||||||
|
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark
|
||||||
|
|
||||||
|
from sys_user u
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
|
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
|
||||||
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
|
where u.del_flag = '0'
|
||||||
|
<if test="userId != null and userId != 0">
|
||||||
|
AND u.user_id = #{userId}
|
||||||
|
</if>
|
||||||
|
<if test="userName != null and userName != ''">
|
||||||
|
AND u.user_name like concat('%', #{userName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="status != null and status != ''">
|
||||||
|
AND u.status = #{status}
|
||||||
|
</if>
|
||||||
|
<if test="phonenumber != null and phonenumber != ''">
|
||||||
|
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
|
AND date_format(u.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||||
|
</if>
|
||||||
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
|
AND date_format(u.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||||
|
</if>
|
||||||
|
<if test="deptId != null and deptId != 0">
|
||||||
|
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
|
||||||
|
</if>
|
||||||
|
<!-- 数据范围过滤 -->
|
||||||
|
${params.dataScope}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
|
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
||||||
|
from sys_user u
|
||||||
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
|
left join sys_user_role ur on u.user_id = ur.user_id
|
||||||
|
left join sys_role r on r.role_id = ur.role_id
|
||||||
|
where u.del_flag = '0' and r.role_id = #{roleId}
|
||||||
|
<if test="userName != null and userName != ''">
|
||||||
|
AND u.user_name like concat('%', #{userName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="phonenumber != null and phonenumber != ''">
|
||||||
|
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||||
|
</if>
|
||||||
|
<!-- 数据范围过滤 -->
|
||||||
|
${params.dataScope}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
|
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
||||||
|
from sys_user u
|
||||||
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
|
left join sys_user_role ur on u.user_id = ur.user_id
|
||||||
|
left join sys_role r on r.role_id = ur.role_id
|
||||||
|
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
|
||||||
|
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
|
||||||
|
<if test="userName != null and userName != ''">
|
||||||
|
AND u.user_name like concat('%', #{userName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="phonenumber != null and phonenumber != ''">
|
||||||
|
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||||
|
</if>
|
||||||
|
<!-- 数据范围过滤 -->
|
||||||
|
${params.dataScope}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||||
|
<include refid="selectUserVo"/>
|
||||||
|
where u.user_name = #{userName} and u.del_flag = '0'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
||||||
|
<include refid="selectUserVo"/>
|
||||||
|
where u.user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
|
select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
|
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
|
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||||
|
insert into sys_user(
|
||||||
|
<if test="userId != null and userId != 0">user_id,</if>
|
||||||
|
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||||
|
<if test="userName != null and userName != ''">user_name,</if>
|
||||||
|
<if test="nickName != null and nickName != ''">nick_name,</if>
|
||||||
|
<if test="email != null and email != ''">email,</if>
|
||||||
|
<if test="avatar != null and avatar != ''">avatar,</if>
|
||||||
|
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
|
||||||
|
<if test="sex != null and sex != ''">sex,</if>
|
||||||
|
<if test="password != null and password != ''">password,</if>
|
||||||
|
<if test="status != null and status != ''">status,</if>
|
||||||
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
|
create_time
|
||||||
|
)values(
|
||||||
|
<if test="userId != null and userId != ''">#{userId},</if>
|
||||||
|
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||||
|
<if test="userName != null and userName != ''">#{userName},</if>
|
||||||
|
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
||||||
|
<if test="email != null and email != ''">#{email},</if>
|
||||||
|
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
||||||
|
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
|
||||||
|
<if test="sex != null and sex != ''">#{sex},</if>
|
||||||
|
<if test="password != null and password != ''">#{password},</if>
|
||||||
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
|
current_timestamp()
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateUser" parameterType="SysUser">
|
||||||
|
update sys_user
|
||||||
|
<set>
|
||||||
|
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
||||||
|
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||||
|
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||||
|
<if test="email != null ">email = #{email},</if>
|
||||||
|
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
||||||
|
<if test="sex != null and sex != ''">sex = #{sex},</if>
|
||||||
|
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
||||||
|
<if test="password != null and password != ''">password = #{password},</if>
|
||||||
|
<if test="status != null and status != ''">status = #{status},</if>
|
||||||
|
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
||||||
|
<if test="loginDate != null">login_date = #{loginDate},</if>
|
||||||
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
update_time = current_timestamp()
|
||||||
|
</set>
|
||||||
|
where user_id = #{userId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="updateUserStatus" parameterType="SysUser">
|
||||||
|
update sys_user set status = #{status} where user_id = #{userId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="updateUserAvatar" parameterType="SysUser">
|
||||||
|
update sys_user set avatar = #{avatar} where user_name = #{userName}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="resetUserPwd" parameterType="SysUser">
|
||||||
|
update sys_user set password = #{password} where user_name = #{userName}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteUserById" parameterType="Long">
|
||||||
|
update sys_user set del_flag = '2' where user_id = #{userId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteUserByIds" parameterType="Long">
|
||||||
|
update sys_user set del_flag = '2' where user_id in
|
||||||
|
<foreach collection="array" item="userId" open="(" separator="," close=")">
|
||||||
|
#{userId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.qihang.jd;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit test for simple App.
|
||||||
|
*/
|
||||||
|
public class AppTest
|
||||||
|
extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the test case
|
||||||
|
*
|
||||||
|
* @param testName name of the test case
|
||||||
|
*/
|
||||||
|
public AppTest( String testName )
|
||||||
|
{
|
||||||
|
super( testName );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the suite of tests being tested
|
||||||
|
*/
|
||||||
|
public static Test suite()
|
||||||
|
{
|
||||||
|
return new TestSuite( AppTest.class );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rigourous Test :-)
|
||||||
|
*/
|
||||||
|
public void testApp()
|
||||||
|
{
|
||||||
|
assertTrue( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
3
pom.xml
3
pom.xml
|
|
@ -15,7 +15,8 @@
|
||||||
<module>api</module>
|
<module>api</module>
|
||||||
|
|
||||||
<module>core</module>
|
<module>core</module>
|
||||||
<!-- <module>core/common</module>-->
|
<module>jd-api</module>
|
||||||
|
<!-- <module>core/common</module>-->
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
||||||
|
|
@ -109,8 +109,6 @@
|
||||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||||
<version>3.5.5</version>
|
<version>3.5.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
|
@ -121,19 +119,6 @@
|
||||||
<artifactId>security</artifactId>
|
<artifactId>security</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.projectlombok</groupId>-->
|
|
||||||
<!-- <artifactId>lombok</artifactId>-->
|
|
||||||
<!-- <version>1.18.30</version>-->
|
|
||||||
<!-- <scope>provided</scope>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>junit</groupId>-->
|
|
||||||
<!-- <artifactId>junit</artifactId>-->
|
|
||||||
<!-- <version>4.13.2</version>-->
|
|
||||||
<!-- <scope>test</scope>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue