1
This commit is contained in:
@@ -38,6 +38,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers(HttpMethod.GET, "/api/file/**", "/api/captcha", "/")
|
||||
.permitAll()
|
||||
.antMatchers(
|
||||
"/api/auth/**",
|
||||
"/api/login",
|
||||
"/druid/**",
|
||||
"/swagger-ui.html",
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.eleadmin.common.system.controller;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.eleadmin.common.core.config.ConfigProperties;
|
||||
import com.eleadmin.common.core.security.JwtSubject;
|
||||
import com.eleadmin.common.core.security.JwtUtil;
|
||||
import com.eleadmin.common.core.utils.CommonUtil;
|
||||
import com.eleadmin.common.core.utils.JSONUtil;
|
||||
import com.eleadmin.common.core.web.ApiResult;
|
||||
import com.eleadmin.common.core.web.BaseController;
|
||||
import com.eleadmin.common.system.entity.*;
|
||||
import com.eleadmin.common.system.param.UserParam;
|
||||
import com.eleadmin.common.system.result.LoginResult;
|
||||
import com.eleadmin.common.system.service.UserRoleService;
|
||||
import com.eleadmin.common.system.service.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 第三方登录认证控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2018-12-24 16:10:11
|
||||
*/
|
||||
@Api(tags = "第三方登录认证")
|
||||
@RestController
|
||||
@RequestMapping("/api/auth")
|
||||
public class AuthController extends BaseController {
|
||||
@Resource
|
||||
private ConfigProperties configProperties;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
|
||||
@ApiOperation("获取sessionId")
|
||||
@GetMapping("getSessionId")
|
||||
public String getSessionId(String code){
|
||||
return userService.getSessionId(code);
|
||||
}
|
||||
|
||||
@ApiOperation("第三方登录")
|
||||
@PostMapping("/login")
|
||||
public ApiResult<LoginResult> login(@RequestBody UserParam param, HttpServletRequest request) {
|
||||
Integer tenantId = param.getTenantId();
|
||||
String code = param.getCode();
|
||||
|
||||
// 获取openid
|
||||
String url = "https://api.weixin.qq.com/sns/jscode2session?appid={0}&secret={1}&js_code={2}&grant_type=authorization_code";
|
||||
String replaceUrl = url.replace("{0}","wx2766b62be0ef0e6f").replace("{1}","205451097a44ef67b6684f50c93c23af").replace("{2}",code);
|
||||
String res = HttpUtil.get(replaceUrl);
|
||||
Map<String,String> map = JSONUtil.parseObject(res, Map.class);
|
||||
String openid = map.get("openid");
|
||||
|
||||
System.out.println(param);
|
||||
|
||||
// 根据openid查询用户是否存在,不存在则创建,存在则登录成功并返回
|
||||
User user = userService.getByOpenid(openid, tenantId);
|
||||
if (user == null) {
|
||||
// 添加用户
|
||||
User u = new User();
|
||||
u.setOpenid(openid);
|
||||
u.setTenantId(param.getTenantId());
|
||||
u.setUsername("wx_" + CommonUtil.randomUUID16());
|
||||
u.setNickname(param.getNickname());
|
||||
u.setAvatar(param.getAvatar());
|
||||
u.setSex(param.getSex());
|
||||
u.setPassword(userService.encodePassword(CommonUtil.randomUUID16()));
|
||||
userService.saveUser(u);
|
||||
|
||||
// 添加默认角色(普通用户)
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setUserId(u.getUserId());
|
||||
userRole.setRoleId(5);
|
||||
userRole.setTenantId(u.getTenantId());
|
||||
userRoleService.save(userRole);
|
||||
|
||||
user = u;
|
||||
}
|
||||
// 移除敏感信息
|
||||
user.setPassword(null);
|
||||
user.setOpenid(null);
|
||||
// 签发token
|
||||
String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), tenantId),
|
||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||
return success("登录成功", new LoginResult(access_token, user));
|
||||
}
|
||||
}
|
||||
@@ -240,7 +240,7 @@ public class UserController extends BaseController {
|
||||
if (CommonUtil.checkRepeat(list, UserImportParam::getUsername)) {
|
||||
return fail("账号存在重复", null);
|
||||
}
|
||||
if (CommonUtil.checkRepeat(list, UserImportParam::getPhone)) {
|
||||
if (CommonUtil.checkRepeat(list, UserImportParam::getMobile)) {
|
||||
return fail("手机号存在重复", null);
|
||||
}
|
||||
// 校验是否存在
|
||||
@@ -250,11 +250,11 @@ public class UserController extends BaseController {
|
||||
return fail("账号已经存在",
|
||||
usernameExists.stream().map(User::getUsername).collect(Collectors.toList()));
|
||||
}
|
||||
List<User> phoneExists = userService.list(new LambdaQueryWrapper<User>().in(User::getPhone,
|
||||
list.stream().map(UserImportParam::getPhone).collect(Collectors.toList())));
|
||||
List<User> phoneExists = userService.list(new LambdaQueryWrapper<User>().in(User::getMobile,
|
||||
list.stream().map(UserImportParam::getMobile).collect(Collectors.toList())));
|
||||
if (phoneExists.size() > 0) {
|
||||
return fail("手机号已经存在",
|
||||
phoneExists.stream().map(User::getPhone).collect(Collectors.toList()));
|
||||
phoneExists.stream().map(User::getMobile).collect(Collectors.toList()));
|
||||
}
|
||||
// 添加
|
||||
List<User> users = new ArrayList<>();
|
||||
@@ -264,7 +264,7 @@ public class UserController extends BaseController {
|
||||
u.setUsername(one.getUsername());
|
||||
u.setPassword(userService.encodePassword(one.getPassword()));
|
||||
u.setNickname(one.getNickname());
|
||||
u.setPhone(one.getPhone());
|
||||
u.setMobile(one.getMobile());
|
||||
Role role = roleService.getOne(new QueryWrapper<Role>()
|
||||
.eq("role_name", one.getRoleName()), false);
|
||||
if (role == null) {
|
||||
|
||||
@@ -26,6 +26,9 @@ public class User implements UserDetails {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty("微信openid")
|
||||
private String openid;
|
||||
|
||||
@ApiModelProperty("账号")
|
||||
private String username;
|
||||
|
||||
@@ -42,7 +45,7 @@ public class User implements UserDetails {
|
||||
private String sex;
|
||||
|
||||
@ApiModelProperty("手机号")
|
||||
private String phone;
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty("邮箱")
|
||||
private String email;
|
||||
@@ -69,6 +72,15 @@ public class User implements UserDetails {
|
||||
@ApiModelProperty("机构id")
|
||||
private Integer organizationId;
|
||||
|
||||
@ApiModelProperty(value = "国家")
|
||||
private String country;
|
||||
|
||||
@ApiModelProperty("省份")
|
||||
private String province;
|
||||
|
||||
@ApiModelProperty("城市")
|
||||
private String city;
|
||||
|
||||
@ApiModelProperty("状态, 0正常, 1冻结")
|
||||
private Integer status;
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.eleadmin.common.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 第三方用户信息表
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-09-01 16:17:28
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "UserOauth对象", description = "第三方用户信息表")
|
||||
@TableName("sys_user_oauth")
|
||||
public class UserOauth implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "第三方登陆类型(MP-WEIXIN)")
|
||||
private String oauthType;
|
||||
|
||||
@ApiModelProperty(value = "第三方用户唯一标识 (uid openid)")
|
||||
private String oauthId;
|
||||
|
||||
@ApiModelProperty(value = "微信unionID")
|
||||
private String unionid;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -43,4 +43,7 @@ public class UserRole implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String roleName;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
}
|
||||
|
||||
@@ -45,4 +45,14 @@ public interface UserMapper extends BaseMapper<User> {
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
User selectByUsername(@Param("username") String username, @Param("tenantId") Integer tenantId);
|
||||
|
||||
/**
|
||||
* 根据openid查询
|
||||
*
|
||||
* @param openid 微信openid
|
||||
* @param tenantId 租户id
|
||||
* @return User
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
User selectByOpenid(@Param("openid") String openid, @Param("tenantId") Integer tenantId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.eleadmin.common.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.eleadmin.common.system.entity.UserOauth;
|
||||
import com.eleadmin.common.system.param.UserOauthParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 第三方用户信息表Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-09-01 16:17:28
|
||||
*/
|
||||
public interface UserOauthMapper extends BaseMapper<UserOauth> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<UserOauth>
|
||||
*/
|
||||
List<UserOauth> selectPageRel(@Param("page") IPage<UserOauth> page,
|
||||
@Param("param") UserOauthParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<UserOauth> selectListRel(@Param("param") UserOauthParam param);
|
||||
|
||||
}
|
||||
@@ -2,139 +2,161 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.eleadmin.common.system.mapper.UserMapper">
|
||||
|
||||
<!-- 性别字典查询sql -->
|
||||
<sql id="selectSexDictSql">
|
||||
SELECT ta.*
|
||||
FROM sys_dictionary_data ta
|
||||
LEFT JOIN sys_dictionary tb
|
||||
ON ta.dict_id = tb.dict_id
|
||||
AND tb.deleted = 0
|
||||
WHERE ta.deleted = 0
|
||||
AND tb.dict_code = 'sex'
|
||||
</sql>
|
||||
<!-- 性别字典查询sql -->
|
||||
<sql id="selectSexDictSql">
|
||||
SELECT ta.*
|
||||
FROM sys_dictionary_data ta
|
||||
LEFT JOIN sys_dictionary tb
|
||||
ON ta.dict_id = tb.dict_id
|
||||
AND tb.deleted = 0
|
||||
WHERE ta.deleted = 0
|
||||
AND tb.dict_code = 'sex'
|
||||
</sql>
|
||||
|
||||
<!-- 用户角色查询sql -->
|
||||
<sql id="selectUserRoleSql">
|
||||
SELECT a.user_id,
|
||||
GROUP_CONCAT(b.role_name) role_name
|
||||
FROM sys_user_role a
|
||||
LEFT JOIN sys_role b ON a.role_id = b.role_id
|
||||
GROUP BY a.user_id
|
||||
</sql>
|
||||
<!-- 用户角色查询sql -->
|
||||
<sql id="selectUserRoleSql">
|
||||
SELECT a.user_id,
|
||||
GROUP_CONCAT(b.role_name) role_name
|
||||
FROM sys_user_role a
|
||||
LEFT JOIN sys_role b ON a.role_id = b.role_id
|
||||
GROUP BY a.user_id
|
||||
</sql>
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*,
|
||||
b.organization_name,
|
||||
c.dict_data_name sex_name
|
||||
FROM sys_user a
|
||||
LEFT JOIN sys_organization b ON a.organization_id = b.organization_id
|
||||
LEFT JOIN (
|
||||
<include refid="selectSexDictSql"/>
|
||||
) c ON a.sex = c.dict_data_code
|
||||
LEFT JOIN(
|
||||
<include refid="selectUserRoleSql"/>
|
||||
) d ON a.user_id = d.user_id
|
||||
<where>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.username != null">
|
||||
AND a.username LIKE CONCAT('%', #{param.username}, '%')
|
||||
</if>
|
||||
<if test="param.nickname != null">
|
||||
AND a.nickname LIKE CONCAT('%', #{param.nickname}, '%')
|
||||
</if>
|
||||
<if test="param.sex != null">
|
||||
AND a.sex = #{param.sex}
|
||||
</if>
|
||||
<if test="param.phone != null">
|
||||
AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
|
||||
</if>
|
||||
<if test="param.email != null">
|
||||
AND a.email LIKE CONCAT('%', #{param.email}, '%')
|
||||
</if>
|
||||
<if test="param.emailVerified != null">
|
||||
AND a.email_verified = #{param.emailVerified}
|
||||
</if>
|
||||
<if test="param.realName != null">
|
||||
AND a.real_name LIKE CONCAT('%', #{param.realName}, '%')
|
||||
</if>
|
||||
<if test="param.idCard != null">
|
||||
AND a.id_card LIKE CONCAT('%', #{param.idCard}, '%')
|
||||
</if>
|
||||
<if test="param.birthday != null">
|
||||
AND a.birthday LIKE CONCAT('%', #{param.birthday}, '%')
|
||||
</if>
|
||||
<if test="param.organizationId != null">
|
||||
AND a.organization_id = #{param.organizationId}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.`status` = #{param.status}
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.roleId != null">
|
||||
AND a.user_id IN (SELECT user_id FROM sys_user_role WHERE role_id=#{param.roleId})
|
||||
</if>
|
||||
<if test="param.organizationName != null">
|
||||
AND b.organization_name LIKE CONCAT('%', #{param.organizationName}, '%')
|
||||
</if>
|
||||
<if test="param.sexName != null">
|
||||
AND c.dict_data_name = #{param.sexName}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (
|
||||
a.username LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.nickname LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR b.organization_name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR c.dict_data_name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR d.role_name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*,
|
||||
b.organization_name,
|
||||
c.dict_data_name sex_name
|
||||
FROM sys_user a
|
||||
LEFT JOIN sys_organization b ON a.organization_id = b.organization_id
|
||||
LEFT JOIN (
|
||||
<include refid="selectSexDictSql"/>
|
||||
) c ON a.sex = c.dict_data_code
|
||||
LEFT JOIN(
|
||||
<include refid="selectUserRoleSql"/>
|
||||
) d ON a.user_id = d.user_id
|
||||
<where>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.username != null">
|
||||
AND a.username LIKE CONCAT('%', #{param.username}, '%')
|
||||
</if>
|
||||
<if test="param.nickname != null">
|
||||
AND a.nickname LIKE CONCAT('%', #{param.nickname}, '%')
|
||||
</if>
|
||||
<if test="param.sex != null">
|
||||
AND a.sex = #{param.sex}
|
||||
</if>
|
||||
<if test="param.mobile != null">
|
||||
AND a.mobile LIKE CONCAT('%', #{param.mobile}, '%')
|
||||
</if>
|
||||
<if test="param.email != null">
|
||||
AND a.email LIKE CONCAT('%', #{param.email}, '%')
|
||||
</if>
|
||||
<if test="param.emailVerified != null">
|
||||
AND a.email_verified = #{param.emailVerified}
|
||||
</if>
|
||||
<if test="param.realName != null">
|
||||
AND a.real_name LIKE CONCAT('%', #{param.realName}, '%')
|
||||
</if>
|
||||
<if test="param.idCard != null">
|
||||
AND a.id_card LIKE CONCAT('%', #{param.idCard}, '%')
|
||||
</if>
|
||||
<if test="param.birthday != null">
|
||||
AND a.birthday LIKE CONCAT('%', #{param.birthday}, '%')
|
||||
</if>
|
||||
<if test="param.organizationId != null">
|
||||
AND a.organization_id = #{param.organizationId}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.`status` = #{param.status}
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.roleId != null">
|
||||
AND a.user_id IN (SELECT user_id FROM sys_user_role WHERE role_id=#{param.roleId})
|
||||
</if>
|
||||
<if test="param.organizationName != null">
|
||||
AND b.organization_name LIKE CONCAT('%', #{param.organizationName}, '%')
|
||||
</if>
|
||||
<if test="param.sexName != null">
|
||||
AND c.dict_data_name = #{param.sexName}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (
|
||||
a.username LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.nickname LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR b.organization_name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR c.dict_data_name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR d.role_name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.eleadmin.common.system.entity.User">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.eleadmin.common.system.entity.User">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.eleadmin.common.system.entity.User">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.eleadmin.common.system.entity.User">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 根据账号查询 -->
|
||||
<select id="selectByUsername" resultType="com.eleadmin.common.system.entity.User">
|
||||
SELECT a.* ,
|
||||
b.organization_name,
|
||||
c.dict_data_name sex_name
|
||||
FROM sys_user a
|
||||
LEFT JOIN sys_organization b ON a.organization_id = b.organization_id
|
||||
LEFT JOIN (
|
||||
<include refid="selectSexDictSql"/>
|
||||
) c ON a.sex = c.dict_data_code
|
||||
<where>
|
||||
AND a.deleted = 0
|
||||
AND a.username = #{username}
|
||||
<if test="tenantId != null">
|
||||
AND a.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="tenantId == null">
|
||||
AND a.tenant_id = 1
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<!-- 根据账号查询 -->
|
||||
<select id="selectByUsername" resultType="com.eleadmin.common.system.entity.User">
|
||||
SELECT a.* ,
|
||||
b.organization_name,
|
||||
c.dict_data_name sex_name
|
||||
FROM sys_user a
|
||||
LEFT JOIN sys_organization b ON a.organization_id = b.organization_id
|
||||
LEFT JOIN (
|
||||
<include refid="selectSexDictSql"/>
|
||||
) c ON a.sex = c.dict_data_code
|
||||
<where>
|
||||
AND a.deleted = 0
|
||||
AND a.username = #{username}
|
||||
<if test="tenantId != null">
|
||||
AND a.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="tenantId == null">
|
||||
AND a.tenant_id = 1
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 根据账号查询 -->
|
||||
<select id="selectByOpenid" resultType="com.eleadmin.common.system.entity.User">
|
||||
SELECT a.* ,
|
||||
b.organization_name,
|
||||
c.dict_data_name sex_name
|
||||
FROM sys_user a
|
||||
LEFT JOIN sys_organization b ON a.organization_id = b.organization_id
|
||||
LEFT JOIN (
|
||||
<include refid="selectSexDictSql"/>
|
||||
) c ON a.sex = c.dict_data_code
|
||||
<where>
|
||||
AND a.deleted = 0
|
||||
AND a.openid = #{openid}
|
||||
<if test="tenantId != null">
|
||||
AND a.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="tenantId == null">
|
||||
AND a.tenant_id = 1
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?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.eleadmin.common.system.mapper.UserOauthMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM sys_user_oauth a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.oauthType != null">
|
||||
AND a.oauth_type LIKE CONCAT('%', #{param.oauthType}, '%')
|
||||
</if>
|
||||
<if test="param.oauthId != null">
|
||||
AND a.oauth_id LIKE CONCAT('%', #{param.oauthId}, '%')
|
||||
</if>
|
||||
<if test="param.unionid != null">
|
||||
AND a.unionid LIKE CONCAT('%', #{param.unionid}, '%')
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.eleadmin.common.system.entity.UserOauth">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.eleadmin.common.system.entity.UserOauth">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.eleadmin.common.system.param;
|
||||
|
||||
import com.eleadmin.common.core.annotation.QueryField;
|
||||
import com.eleadmin.common.core.annotation.QueryType;
|
||||
import com.eleadmin.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 第三方用户信息表查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-09-01 16:17:28
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "WxAuth对象", description = "第三方用户信息表查询参数")
|
||||
public class AuthParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String encrypteDate;
|
||||
private String iv;
|
||||
private String sessionId;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class UserImportParam implements Serializable {
|
||||
private String nickname;
|
||||
|
||||
@Excel(name = "手机号")
|
||||
private String phone;
|
||||
private String mobile;
|
||||
|
||||
@Excel(name = "邮箱")
|
||||
private String email;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.eleadmin.common.system.param;
|
||||
|
||||
import com.eleadmin.common.core.annotation.QueryField;
|
||||
import com.eleadmin.common.core.annotation.QueryType;
|
||||
import com.eleadmin.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 第三方用户信息表查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-09-01 16:17:28
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "UserOauthParam对象", description = "第三方用户信息表查询参数")
|
||||
public class UserOauthParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "微信code")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "第三方登陆类型(MP-WEIXIN)")
|
||||
private String oauthType;
|
||||
|
||||
@ApiModelProperty(value = "第三方用户唯一标识 (uid openid)")
|
||||
private String oauthId;
|
||||
|
||||
@ApiModelProperty(value = "微信unionID")
|
||||
private String unionid;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "第三方用户信息")
|
||||
private Object userInfo;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
}
|
||||
@@ -28,6 +28,9 @@ public class UserParam extends BaseParam {
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty("微信openid")
|
||||
private String openid;
|
||||
|
||||
@ApiModelProperty("账号")
|
||||
private String username;
|
||||
|
||||
@@ -39,7 +42,7 @@ public class UserParam extends BaseParam {
|
||||
private String sex;
|
||||
|
||||
@ApiModelProperty("手机号")
|
||||
private String phone;
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty("邮箱")
|
||||
private String email;
|
||||
@@ -77,6 +80,15 @@ public class UserParam extends BaseParam {
|
||||
@TableField(exist = false)
|
||||
private String organizationName;
|
||||
|
||||
@ApiModelProperty("国家")
|
||||
private String country;
|
||||
|
||||
@ApiModelProperty("省份")
|
||||
private String province;
|
||||
|
||||
@ApiModelProperty("城市")
|
||||
private String city;
|
||||
|
||||
@ApiModelProperty("性别名称")
|
||||
@TableField(exist = false)
|
||||
private String sexName;
|
||||
@@ -85,4 +97,14 @@ public class UserParam extends BaseParam {
|
||||
@TableField(exist = false)
|
||||
private String keywords;
|
||||
|
||||
@ApiModelProperty("微信登录凭证")
|
||||
@TableField(exist = false)
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty("微信头像")
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.eleadmin.common.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.eleadmin.common.core.web.PageResult;
|
||||
import com.eleadmin.common.system.entity.UserOauth;
|
||||
import com.eleadmin.common.system.param.UserOauthParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 第三方用户信息表Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-09-01 16:17:28
|
||||
*/
|
||||
public interface UserOauthService extends IService<UserOauth> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<UserOauth>
|
||||
*/
|
||||
PageResult<UserOauth> pageRel(UserOauthParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<UserOauth>
|
||||
*/
|
||||
List<UserOauth> listRel(UserOauthParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return UserOauth
|
||||
*/
|
||||
UserOauth getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.eleadmin.common.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.eleadmin.common.core.web.ApiResult;
|
||||
import com.eleadmin.common.core.web.PageResult;
|
||||
import com.eleadmin.common.system.entity.User;
|
||||
import com.eleadmin.common.system.param.UserParam;
|
||||
import com.eleadmin.common.system.result.LoginResult;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
|
||||
import java.util.List;
|
||||
@@ -40,6 +42,22 @@ public interface UserService extends IService<User>, UserDetailsService {
|
||||
*/
|
||||
User getByIdRel(Integer userId);
|
||||
|
||||
/**
|
||||
* 根据openid查询用户
|
||||
*
|
||||
* @param openid 账号
|
||||
* @return User
|
||||
*/
|
||||
User getByOpenid(String openid);
|
||||
|
||||
/**
|
||||
* 根据openid查询用户
|
||||
*
|
||||
* @param tenantId 账号
|
||||
* @return User
|
||||
*/
|
||||
User getByOpenid(String openid, Integer tenantId);
|
||||
|
||||
/**
|
||||
* 根据账号查询用户
|
||||
*
|
||||
@@ -90,4 +108,5 @@ public interface UserService extends IService<User>, UserDetailsService {
|
||||
*/
|
||||
String encodePassword(String password);
|
||||
|
||||
String getSessionId(String code);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.eleadmin.common.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.eleadmin.common.system.mapper.UserOauthMapper;
|
||||
import com.eleadmin.common.system.service.UserOauthService;
|
||||
import com.eleadmin.common.system.entity.UserOauth;
|
||||
import com.eleadmin.common.system.param.UserOauthParam;
|
||||
import com.eleadmin.common.core.web.PageParam;
|
||||
import com.eleadmin.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 第三方用户信息表Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-09-01 16:17:28
|
||||
*/
|
||||
@Service
|
||||
public class UserOauthServiceImpl extends ServiceImpl<UserOauthMapper, UserOauth> implements UserOauthService {
|
||||
|
||||
@Override
|
||||
public PageResult<UserOauth> pageRel(UserOauthParam param) {
|
||||
PageParam<UserOauth, UserOauthParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
List<UserOauth> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserOauth> listRel(UserOauthParam param) {
|
||||
List<UserOauth> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<UserOauth, UserOauthParam> page = new PageParam<>();
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserOauth getByIdRel(Integer id) {
|
||||
UserOauthParam param = new UserOauthParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.eleadmin.common.core.web.ApiResult;
|
||||
import com.eleadmin.common.core.web.PageParam;
|
||||
import com.eleadmin.common.core.exception.BusinessException;
|
||||
import com.eleadmin.common.core.web.PageResult;
|
||||
@@ -34,148 +35,174 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
@Resource
|
||||
private RoleMenuService roleMenuService;
|
||||
@Resource
|
||||
private BCryptPasswordEncoder bCryptPasswordEncoder;
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
@Resource
|
||||
private RoleMenuService roleMenuService;
|
||||
@Resource
|
||||
private BCryptPasswordEncoder bCryptPasswordEncoder;
|
||||
|
||||
@Override
|
||||
public PageResult<User> pageRel(UserParam param) {
|
||||
PageParam<User, UserParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
List<User> list = baseMapper.selectPageRel(page, param);
|
||||
// 查询用户的角色
|
||||
selectUserRoles(list);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
@Override
|
||||
public PageResult<User> pageRel(UserParam param) {
|
||||
PageParam<User, UserParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
List<User> list = baseMapper.selectPageRel(page, param);
|
||||
// 查询用户的角色
|
||||
selectUserRoles(list);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> listRel(UserParam param) {
|
||||
List<User> list = baseMapper.selectListRel(param);
|
||||
// 查询用户的角色
|
||||
selectUserRoles(list);
|
||||
// 排序
|
||||
PageParam<User, UserParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
@Override
|
||||
public List<User> listRel(UserParam param) {
|
||||
List<User> list = baseMapper.selectListRel(param);
|
||||
// 查询用户的角色
|
||||
selectUserRoles(list);
|
||||
// 排序
|
||||
PageParam<User, UserParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getByIdRel(Integer userId) {
|
||||
UserParam param = new UserParam();
|
||||
param.setUserId(userId);
|
||||
User user = param.getOne(baseMapper.selectListRel(param));
|
||||
if (user != null) {
|
||||
user.setRoles(userRoleService.listByUserId(user.getUserId()));
|
||||
user.setAuthorities(roleMenuService.listMenuByUserId(user.getUserId(), null));
|
||||
}
|
||||
return user;
|
||||
@Override
|
||||
public User getByIdRel(Integer userId) {
|
||||
UserParam param = new UserParam();
|
||||
param.setUserId(userId);
|
||||
User user = param.getOne(baseMapper.selectListRel(param));
|
||||
if (user != null) {
|
||||
user.setRoles(userRoleService.listByUserId(user.getUserId()));
|
||||
user.setAuthorities(roleMenuService.listMenuByUserId(user.getUserId(), null));
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getByUsername(String username) {
|
||||
return getByUsername(username, null);
|
||||
}
|
||||
@Override
|
||||
public User getByOpenid(String openid) {
|
||||
return getByOpenid(openid, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getByUsername(String username, Integer tenantId) {
|
||||
if (StrUtil.isBlank(username)) {
|
||||
return null;
|
||||
}
|
||||
User user = baseMapper.selectByUsername(username, tenantId);
|
||||
if (user != null) {
|
||||
user.setRoles(userRoleService.listByUserId(user.getUserId()));
|
||||
user.setAuthorities(roleMenuService.listMenuByUserId(user.getUserId(), null));
|
||||
}
|
||||
return user;
|
||||
@Override
|
||||
public User getByOpenid(String openid, Integer tenantId) {
|
||||
if (StrUtil.isBlank(openid)) {
|
||||
return null;
|
||||
}
|
||||
User user = baseMapper.selectByOpenid(openid, tenantId);
|
||||
if (user != null) {
|
||||
user.setRoles(userRoleService.listByUserId(user.getUserId()));
|
||||
user.setAuthorities(roleMenuService.listMenuByUserId(user.getUserId(), null));
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
return getByUsername(username);
|
||||
}
|
||||
@Override
|
||||
public User getByUsername(String username) {
|
||||
return getByUsername(username, null);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = {Exception.class}, isolation = Isolation.SERIALIZABLE)
|
||||
@Override
|
||||
public boolean saveUser(User user) {
|
||||
if (StrUtil.isNotEmpty(user.getUsername()) && baseMapper.selectCount(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getUsername, user.getUsername())) > 0) {
|
||||
throw new BusinessException("账号已存在");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(user.getPhone()) && baseMapper.selectCount(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getPhone, user.getPhone())) > 0) {
|
||||
throw new BusinessException("手机号已存在");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(user.getEmail()) && baseMapper.selectCount(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getEmail, user.getEmail())) > 0) {
|
||||
throw new BusinessException("邮箱已存在");
|
||||
}
|
||||
boolean result = baseMapper.insert(user) > 0;
|
||||
if (result && user.getRoles() != null && user.getRoles().size() > 0) {
|
||||
List<Integer> roleIds = user.getRoles().stream().map(Role::getRoleId).collect(Collectors.toList());
|
||||
if (userRoleService.saveBatch(user.getUserId(), roleIds) < roleIds.size()) {
|
||||
throw new BusinessException("用户角色添加失败");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@Override
|
||||
public User getByUsername(String username, Integer tenantId) {
|
||||
if (StrUtil.isBlank(username)) {
|
||||
return null;
|
||||
}
|
||||
User user = baseMapper.selectByUsername(username, tenantId);
|
||||
if (user != null) {
|
||||
user.setRoles(userRoleService.listByUserId(user.getUserId()));
|
||||
user.setAuthorities(roleMenuService.listMenuByUserId(user.getUserId(), null));
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@Override
|
||||
public boolean updateUser(User user) {
|
||||
if (StrUtil.isNotEmpty(user.getUsername()) && baseMapper.selectCount(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getUsername, user.getUsername())
|
||||
.ne(User::getUserId, user.getUserId())) > 0) {
|
||||
throw new BusinessException("账号已存在");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(user.getPhone()) && baseMapper.selectCount(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getPhone, user.getPhone())
|
||||
.ne(User::getUserId, user.getUserId())) > 0) {
|
||||
throw new BusinessException("手机号已存在");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(user.getEmail()) && baseMapper.selectCount(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getEmail, user.getEmail())
|
||||
.ne(User::getUserId, user.getUserId())) > 0) {
|
||||
throw new BusinessException("邮箱已存在");
|
||||
}
|
||||
boolean result = baseMapper.updateById(user) > 0;
|
||||
if (result && user.getRoles() != null && user.getRoles().size() > 0) {
|
||||
userRoleService.remove(new LambdaUpdateWrapper<UserRole>().eq(UserRole::getUserId, user.getUserId()));
|
||||
List<Integer> roleIds = user.getRoles().stream().map(Role::getRoleId).collect(Collectors.toList());
|
||||
if (userRoleService.saveBatch(user.getUserId(), roleIds) < roleIds.size()) {
|
||||
throw new BusinessException("用户角色添加失败");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
return getByUsername(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String dbPassword, String inputPassword) {
|
||||
return bCryptPasswordEncoder.matches(inputPassword, dbPassword);
|
||||
@Transactional(rollbackFor = {Exception.class}, isolation = Isolation.SERIALIZABLE)
|
||||
@Override
|
||||
public boolean saveUser(User user) {
|
||||
if (StrUtil.isNotEmpty(user.getUsername()) && baseMapper.selectCount(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getUsername, user.getUsername())) > 0) {
|
||||
throw new BusinessException("账号已存在");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(user.getMobile()) && baseMapper.selectCount(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getMobile, user.getMobile())) > 0) {
|
||||
throw new BusinessException("手机号已存在");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(user.getEmail()) && baseMapper.selectCount(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getEmail, user.getEmail())) > 0) {
|
||||
throw new BusinessException("邮箱已存在");
|
||||
}
|
||||
boolean result = baseMapper.insert(user) > 0;
|
||||
if (result && user.getRoles() != null && user.getRoles().size() > 0) {
|
||||
List<Integer> roleIds = user.getRoles().stream().map(Role::getRoleId).collect(Collectors.toList());
|
||||
if (userRoleService.saveBatch(user.getUserId(), roleIds) < roleIds.size()) {
|
||||
throw new BusinessException("用户角色添加失败");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodePassword(String password) {
|
||||
return password == null ? null : bCryptPasswordEncoder.encode(password);
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@Override
|
||||
public boolean updateUser(User user) {
|
||||
if (StrUtil.isNotEmpty(user.getUsername()) && baseMapper.selectCount(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getUsername, user.getUsername())
|
||||
.ne(User::getUserId, user.getUserId())) > 0) {
|
||||
throw new BusinessException("账号已存在");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(user.getMobile()) && baseMapper.selectCount(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getMobile, user.getMobile())
|
||||
.ne(User::getUserId, user.getUserId())) > 0) {
|
||||
throw new BusinessException("手机号已存在");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(user.getEmail()) && baseMapper.selectCount(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getEmail, user.getEmail())
|
||||
.ne(User::getUserId, user.getUserId())) > 0) {
|
||||
throw new BusinessException("邮箱已存在");
|
||||
}
|
||||
boolean result = baseMapper.updateById(user) > 0;
|
||||
if (result && user.getRoles() != null && user.getRoles().size() > 0) {
|
||||
userRoleService.remove(new LambdaUpdateWrapper<UserRole>().eq(UserRole::getUserId, user.getUserId()));
|
||||
List<Integer> roleIds = user.getRoles().stream().map(Role::getRoleId).collect(Collectors.toList());
|
||||
if (userRoleService.saveBatch(user.getUserId(), roleIds) < roleIds.size()) {
|
||||
throw new BusinessException("用户角色添加失败");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询用户的角色
|
||||
*
|
||||
* @param users 用户集合
|
||||
*/
|
||||
private void selectUserRoles(List<User> users) {
|
||||
if (users != null && users.size() > 0) {
|
||||
List<Integer> userIds = users.stream().map(User::getUserId).collect(Collectors.toList());
|
||||
List<Role> userRoles = userRoleService.listByUserIds(userIds);
|
||||
for (User user : users) {
|
||||
List<Role> roles = userRoles.stream().filter(d -> user.getUserId().equals(d.getUserId()))
|
||||
.collect(Collectors.toList());
|
||||
user.setRoles(roles);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean comparePassword(String dbPassword, String inputPassword) {
|
||||
return bCryptPasswordEncoder.matches(inputPassword, dbPassword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodePassword(String password) {
|
||||
return password == null ? null : bCryptPasswordEncoder.encode(password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionId(String code) {
|
||||
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code";
|
||||
System.out.println(code);
|
||||
System.out.println(url);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询用户的角色
|
||||
*
|
||||
* @param users 用户集合
|
||||
*/
|
||||
private void selectUserRoles(List<User> users) {
|
||||
if (users != null && users.size() > 0) {
|
||||
List<Integer> userIds = users.stream().map(User::getUserId).collect(Collectors.toList());
|
||||
List<Role> userRoles = userRoleService.listByUserIds(userIds);
|
||||
for (User user : users) {
|
||||
List<Role> roles = userRoles.stream().filter(d -> user.getUserId().equals(d.getUserId()))
|
||||
.collect(Collectors.toList());
|
||||
user.setRoles(roles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(description = "收银台")
|
||||
@TableName("apps_cashier")
|
||||
@TableName("ws_cashier")
|
||||
public class Cashier implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.eleadmin.test.controller;
|
||||
|
||||
import com.eleadmin.common.core.web.BaseController;
|
||||
import com.eleadmin.test.service.TenantSettingService;
|
||||
import com.eleadmin.test.entity.TenantSetting;
|
||||
import com.eleadmin.test.param.TenantSettingParam;
|
||||
import com.eleadmin.common.core.web.ApiResult;
|
||||
import com.eleadmin.common.core.web.PageResult;
|
||||
import com.eleadmin.common.core.web.PageParam;
|
||||
import com.eleadmin.common.core.web.BatchParam;
|
||||
import com.eleadmin.common.core.annotation.OperationLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统设置表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-08-29 09:27:05
|
||||
*/
|
||||
@Api(tags = "系统设置表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/test/tenant-setting")
|
||||
public class TenantSettingController extends BaseController {
|
||||
@Resource
|
||||
private TenantSettingService tenantSettingService;
|
||||
|
||||
@PreAuthorize("hasAuthority('test:tenantSetting:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询系统设置表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<TenantSetting>> page(TenantSettingParam param) {
|
||||
PageParam<TenantSetting, TenantSettingParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
return success(tenantSettingService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(tenantSettingService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('test:tenantSetting:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部系统设置表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<TenantSetting>> list(TenantSettingParam param) {
|
||||
PageParam<TenantSetting, TenantSettingParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
return success(tenantSettingService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(tenantSettingService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('test:tenantSetting:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询系统设置表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<TenantSetting> get(@PathVariable("id") Integer id) {
|
||||
return success(tenantSettingService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(tenantSettingService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('test:tenantSetting:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加系统设置表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody TenantSetting tenantSetting) {
|
||||
if (tenantSettingService.save(tenantSetting)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('test:tenantSetting:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改系统设置表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody TenantSetting tenantSetting) {
|
||||
if (tenantSettingService.updateById(tenantSetting)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('test:tenantSetting:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除系统设置表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (tenantSettingService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('test:tenantSetting:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加系统设置表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<TenantSetting> list) {
|
||||
if (tenantSettingService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('test:tenantSetting:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改系统设置表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<TenantSetting> batchParam) {
|
||||
if (batchParam.update(tenantSettingService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('test:tenantSetting:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除系统设置表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (tenantSettingService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
56
src/main/java/com/eleadmin/test/entity/TenantSetting.java
Normal file
56
src/main/java/com/eleadmin/test/entity/TenantSetting.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.eleadmin.test.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 系统设置表
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-08-29 09:27:05
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "TenantSetting对象", description = "系统设置表")
|
||||
@TableName("sys_tenant_setting")
|
||||
public class TenantSetting implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "设置项标示")
|
||||
private String key;
|
||||
|
||||
@ApiModelProperty(value = "设置内容(json格式)")
|
||||
private String values;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.eleadmin.test.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.eleadmin.test.entity.TenantSetting;
|
||||
import com.eleadmin.test.param.TenantSettingParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统设置表Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-08-29 09:27:05
|
||||
*/
|
||||
public interface TenantSettingMapper extends BaseMapper<TenantSetting> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<TenantSetting>
|
||||
*/
|
||||
List<TenantSetting> selectPageRel(@Param("page") IPage<TenantSetting> page,
|
||||
@Param("param") TenantSettingParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<TenantSetting> selectListRel(@Param("param") TenantSettingParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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.eleadmin.test.mapper.TenantSettingMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM sys_tenant_setting a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.key != null">
|
||||
AND a.key LIKE CONCAT('%', #{param.key}, '%')
|
||||
</if>
|
||||
<if test="param.values != null">
|
||||
AND a.values LIKE CONCAT('%', #{param.values}, '%')
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.eleadmin.test.entity.TenantSetting">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.eleadmin.test.entity.TenantSetting">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.eleadmin.test.param;
|
||||
|
||||
import com.eleadmin.common.core.annotation.QueryField;
|
||||
import com.eleadmin.common.core.annotation.QueryType;
|
||||
import com.eleadmin.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 系统设置表查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-08-29 09:27:05
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "TenantSettingParam对象", description = "系统设置表查询参数")
|
||||
public class TenantSettingParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "id")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "设置项标示")
|
||||
private String key;
|
||||
|
||||
@ApiModelProperty(value = "设置内容(json格式)")
|
||||
private String values;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.eleadmin.test.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.eleadmin.common.core.web.PageResult;
|
||||
import com.eleadmin.test.entity.TenantSetting;
|
||||
import com.eleadmin.test.param.TenantSettingParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统设置表Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-08-29 09:27:05
|
||||
*/
|
||||
public interface TenantSettingService extends IService<TenantSetting> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<TenantSetting>
|
||||
*/
|
||||
PageResult<TenantSetting> pageRel(TenantSettingParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<TenantSetting>
|
||||
*/
|
||||
List<TenantSetting> listRel(TenantSettingParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id id
|
||||
* @return TenantSetting
|
||||
*/
|
||||
TenantSetting getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.eleadmin.test.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.eleadmin.test.mapper.TenantSettingMapper;
|
||||
import com.eleadmin.test.service.TenantSettingService;
|
||||
import com.eleadmin.test.entity.TenantSetting;
|
||||
import com.eleadmin.test.param.TenantSettingParam;
|
||||
import com.eleadmin.common.core.web.PageParam;
|
||||
import com.eleadmin.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统设置表Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-08-29 09:27:05
|
||||
*/
|
||||
@Service
|
||||
public class TenantSettingServiceImpl extends ServiceImpl<TenantSettingMapper, TenantSetting> implements TenantSettingService {
|
||||
|
||||
@Override
|
||||
public PageResult<TenantSetting> pageRel(TenantSettingParam param) {
|
||||
PageParam<TenantSetting, TenantSettingParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
List<TenantSetting> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TenantSetting> listRel(TenantSettingParam param) {
|
||||
List<TenantSetting> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<TenantSetting, TenantSettingParam> page = new PageParam<>();
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TenantSetting getByIdRel(Integer id) {
|
||||
TenantSettingParam param = new TenantSettingParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,9 +3,9 @@
|
||||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://47.119.165.234:3308/com_gxwebsoft_oa?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
||||
username: com_gxwebsoft_oa
|
||||
password: EZfW2R4YiWfbLHLw
|
||||
url: jdbc:mysql://42.194.212.185:3308/yunxinwei_bms?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
||||
username: yunxinwei_bms
|
||||
password: dxtfwGZN65bxeWZa
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://47.119.165.234:3308/com_gxwebsoft_oa?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
||||
username: com_gxwebsoft_oa
|
||||
password: EZfW2R4YiWfbLHLw
|
||||
url: jdbc:mysql://localhost:3308/yunxinwei_bms?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
||||
username: yunxinwei_bms
|
||||
password: dxtfwGZN65bxeWZa
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# 端口
|
||||
server:
|
||||
port: 8081
|
||||
port: 16801
|
||||
|
||||
# 多环境配置
|
||||
spring:
|
||||
profiles:
|
||||
active: prod
|
||||
active: dev
|
||||
|
||||
# 连接池配置
|
||||
datasource:
|
||||
|
||||
@@ -27,27 +27,34 @@ public class CodeGenerator {
|
||||
// 输出目录
|
||||
private static final String OUTPUT_DIR = "/src/main/java";
|
||||
// 作者名称
|
||||
private static final String AUTHOR = "EleAdmin";
|
||||
private static final String AUTHOR = "科技小王子";
|
||||
// 是否在xml中添加二级缓存配置
|
||||
private static final boolean ENABLE_CACHE = false;
|
||||
// 数据库连接配置
|
||||
private static final String DB_URL = "jdbc:mysql://localhost:3306/ele-admin-api?useUnicode=true&useSSL=false&characterEncoding=utf8";
|
||||
private static final String DB_URL = "jdbc:mysql://42.194.212.185:3308/yunxinwei_bms?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
|
||||
private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
|
||||
private static final String DB_USERNAME = "root";
|
||||
private static final String DB_PASSWORD = "123456";
|
||||
private static final String DB_USERNAME = "yunxinwei_bms";
|
||||
private static final String DB_PASSWORD = "dxtfwGZN65bxeWZa";
|
||||
// 包名
|
||||
private static final String PACKAGE_NAME = "com.eleadmin";
|
||||
private static final String PACKAGE_NAME = "com.eleadmin.common";
|
||||
// 模块名
|
||||
private static final String MODULE_NAME = "test";
|
||||
private static final String MODULE_NAME = "system";
|
||||
// 需要生成的表
|
||||
private static final String[] TABLE_NAMES = new String[]{
|
||||
"sys_user",
|
||||
"sys_role"
|
||||
"ws_order",
|
||||
"ws_order_address",
|
||||
"ws_order_delivery",
|
||||
"ws_order_delivery_goods",
|
||||
"ws_order_export",
|
||||
"ws_order_extract",
|
||||
"ws_order_goods",
|
||||
"ws_order_refund",
|
||||
"ws_order_refund_address",
|
||||
"ws_order_refund_image",
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
private static final String[] TABLE_PREFIX = new String[]{
|
||||
"sys_",
|
||||
"tb_"
|
||||
"sys_"
|
||||
};
|
||||
// 不需要作为查询参数的字段
|
||||
private static final String[] PARAM_EXCLUDE_FIELDS = new String[]{
|
||||
|
||||
Reference in New Issue
Block a user