注册功能及页面

This commit is contained in:
donqi 2023-07-01 19:34:25 +08:00
parent bb5f136025
commit 9cd69109f9
9 changed files with 174 additions and 102 deletions

View File

@ -26,7 +26,7 @@ import com.ghy.system.service.ISysDeptService;
/** /**
* 部门信息 * 部门信息
* *
* @author clunt * @author clunt
*/ */
@Controller @Controller
@ -45,7 +45,7 @@ public class SysDeptController extends BaseController
return prefix + "/dept"; return prefix + "/dept";
} }
@RequiresPermissions("system:dept:list") // @RequiresPermissions("system:dept:list")
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public List<SysDept> list(SysDept dept) public List<SysDept> list(SysDept dept)
@ -160,7 +160,7 @@ public class SysDeptController extends BaseController
/** /**
* 选择部门树 * 选择部门树
* *
* @param deptId 部门ID * @param deptId 部门ID
* @param excludeId 排除ID * @param excludeId 排除ID
*/ */

View File

@ -1,5 +1,6 @@
package com.ghy.web.controller.system; package com.ghy.web.controller.system;
import com.ghy.common.core.domain.dto.SysUserAddDTO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -12,9 +13,11 @@ import com.ghy.common.utils.StringUtils;
import com.ghy.framework.shiro.service.SysRegisterService; import com.ghy.framework.shiro.service.SysRegisterService;
import com.ghy.system.service.ISysConfigService; import com.ghy.system.service.ISysConfigService;
import javax.validation.Valid;
/** /**
* 注册验证 * 注册验证
* *
* @author clunt * @author clunt
*/ */
@Controller @Controller
@ -34,13 +37,13 @@ public class SysRegisterController extends BaseController
@PostMapping("/register") @PostMapping("/register")
@ResponseBody @ResponseBody
public AjaxResult ajaxRegister(SysUser user) public AjaxResult ajaxRegister(@Valid SysUserAddDTO userAddDTO)
{ {
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) // if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
{ // {
return error("当前系统没有开启注册功能!"); // return error("当前系统没有开启注册功能!");
} // }
String msg = registerService.register(user); String msg = registerService.register(userAddDTO);
return StringUtils.isEmpty(msg) ? success() : error(msg); return StringUtils.isEmpty(msg) ? success() : error(msg);
} }
} }

View File

@ -5,6 +5,41 @@ $(function() {
var url = ctx + "captcha/captchaImage?type=" + captchaType + "&s=" + Math.random(); var url = ctx + "captcha/captchaImage?type=" + captchaType + "&s=" + Math.random();
$(".imgcode").attr("src", url); $(".imgcode").attr("src", url);
}); });
$.ajax({
type: "POST",
dataType:"json",
url: ctx + "system/dept/list",
data: { parentId: 100 },
success: function (data) {
$.each(data, function (index, value) {
$('#deptId').append("<option value=" + value.deptId + ">" + value.deptName + "</option>");
});
}
})
// $('#deptId').select2({
// placeholder: '请选择公司编码',
// minimumResultsForSearch: -1,
// ajax: {
// type: "POST",
// dataType:"json",
// url: ctx + "system/dept/list",
// data: { parentId: 100 },
// processResults: function (data) {
// var processedData = [];
// $.each(data, function (index, value) {
// processedData.push({
// id: value.deptId,
// text: value.deptName
// })
// });
// return {
// results: processedData
// };
// },
// cache: true
// }
// });
}); });
$.validator.setDefaults({ $.validator.setDefaults({
@ -16,6 +51,8 @@ $.validator.setDefaults({
function register() { function register() {
$.modal.loading($("#btnSubmit").data("loading")); $.modal.loading($("#btnSubmit").data("loading"));
var username = $.common.trim($("input[name='username']").val()); var username = $.common.trim($("input[name='username']").val());
var phonenumber = $.common.trim($("input[name='phonenumber']").val());
var deptId = $.common.trim($('#deptId').val());
var password = $.common.trim($("input[name='password']").val()); var password = $.common.trim($("input[name='password']").val());
var validateCode = $("input[name='validateCode']").val(); var validateCode = $("input[name='validateCode']").val();
$.ajax({ $.ajax({
@ -23,6 +60,8 @@ function register() {
url: ctx + "register", url: ctx + "register",
data: { data: {
"loginName": username, "loginName": username,
"phonenumber": phonenumber,
"deptId": deptId,
"password": password, "password": password,
"validateCode": validateCode "validateCode": validateCode
}, },
@ -49,15 +88,23 @@ function register() {
function validateRule() { function validateRule() {
var icon = "<i class='fa fa-times-circle'></i> "; var icon = "<i class='fa fa-times-circle'></i> ";
$.validator.addMethod("checkPhone",function(value,element,params){
var regex = /^1[345678]\d{9}$/;
return regex.test(value);
}, "请输入正确的手机号码");
$("#registerForm").validate({ $("#registerForm").validate({
rules: { rules: {
username: { username: {
required: true, required: true,
minlength: 2 rangelength: [2,20]
},
phonenumber: {
required: true,
checkPhone: true
}, },
password: { password: {
required: true, required: true,
minlength: 5 rangelength: [5,20]
}, },
confirmPassword: { confirmPassword: {
required: true, required: true,
@ -66,15 +113,18 @@ function validateRule() {
}, },
messages: { messages: {
username: { username: {
required: icon + "请输入您的用户名", required: icon + "请输入用户名",
minlength: icon + "用户名不能小于2个字符" rangelength: icon + "账户长度必须在2到20个字符之间"
},
phonenumber: {
required: icon + "请输入手机号码"
}, },
password: { password: {
required: icon + "请输入您的密码", required: icon + "请输入密码",
minlength: icon + "密码不能小于5个字符", rangelength: icon + "密码长度必须在5到20个字符之间"
}, },
confirmPassword: { confirmPassword: {
required: icon + "请再次输入您的密码", required: icon + "请再次输入密码",
equalTo: icon + "两次密码输入不一致" equalTo: icon + "两次密码输入不一致"
} }
} }

View File

@ -36,7 +36,8 @@
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 在你需要的时候</li> <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 在你需要的时候</li>
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 总在您身边</li> <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 总在您身边</li>
</ul> </ul>
<strong th:if="${isAllowRegister}">还没有账号? <a th:href="@{/register}">立即注册&raquo;</a></strong> <!-- <strong th:if="${isAllowRegister}">还没有账号? <a th:href="@{/register}">立即注册&raquo;</a></strong>-->
<strong>还没有账号? <a th:href="@{/register}">立即注册&raquo;</a></strong>
</div> </div>
</div> </div>
<div class="col-sm-5"> <div class="col-sm-5">

View File

@ -15,25 +15,22 @@
<!-- 避免IE使用兼容模式 --> <!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" href="../static/favicon.ico" th:href="@{favicon.ico}"/> <link rel="shortcut icon" href="../static/favicon.ico" th:href="@{favicon.ico}"/>
<style type="text/css">label.error { position:inherit; }</style> <style type="text/css">
label.error { position:inherit; }
#registerForm input,
#registerForm select {
color: black
}
</style>
<th:block th:include="include :: select2-css" />
</head> </head>
<body class="signin"> <body class="signin">
<div class="signinpanel"> <div class="signinpanel">
<div class="row"> <div class="row">
<div class="col-sm-7"> <div class="col-sm-7">
<div class="signin-info"> <div class="signin-info">
<div class="logopanel m-b">
<h1><img alt="[ 工圈子 ]" src="../static/ruoyi.png" th:src="@{/ruoyi.png}"></h1>
</div>
<div class="m-b"></div> <div class="m-b"></div>
<h4>欢迎使用 <strong>工圈子 后台管理系统</strong></h4> <h4>欢迎使用 <strong>工圈子 后台管理系统</strong></h4>
<ul class="m-b">
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> SpringBoot</li>
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Mybatis</li>
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Shiro</li>
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Thymeleaf</li>
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Bootstrap</li>
</ul>
<strong>已经注册过? <a th:href="@{/login}">直接登录&raquo;</a></strong> <strong>已经注册过? <a th:href="@{/login}">直接登录&raquo;</a></strong>
</div> </div>
</div> </div>
@ -41,9 +38,13 @@
<form id="registerForm" autocomplete="off"> <form id="registerForm" autocomplete="off">
<h4 class="no-margins">注册:</h4> <h4 class="no-margins">注册:</h4>
<p class="m-t-md">你若不离不弃,我必生死相依</p> <p class="m-t-md">你若不离不弃,我必生死相依</p>
<input type="text" name="username" class="form-control uname" placeholder="用户名" maxlength="20" /> <input type="text" name="username" class="form-control username" placeholder="用户名"/>
<input type="password" name="password" class="form-control pword" placeholder="密码" maxlength="20" /> <input type="text" name="phonenumber" class="form-control phonenumber" placeholder="手机号"/>
<input type="password" name="confirmPassword" class="form-control pword" placeholder="确认密码" maxlength="20" /> <select id="deptId" class="form-control" name="deptId">
<option value="" selected>请选择公司编码</option>
</select>
<input type="password" name="password" class="form-control pword" placeholder="密码"/>
<input type="password" name="confirmPassword" class="form-control pword" placeholder="确认密码"/>
<div class="row m-t" th:if="${captchaEnabled==true}"> <div class="row m-t" th:if="${captchaEnabled==true}">
<div class="col-xs-6"> <div class="col-xs-6">
<input type="text" name="validateCode" class="form-control code" placeholder="验证码" maxlength="5" > <input type="text" name="validateCode" class="form-control code" placeholder="验证码" maxlength="5" >
@ -54,17 +55,18 @@
</a> </a>
</div> </div>
</div> </div>
<div class="checkbox-custom" th:classappend="${captchaEnabled==false} ? 'm-t'"> <!-- <div class="checkbox-custom" th:classappend="${captchaEnabled==false} ? 'm-t'">-->
<input type="checkbox" id="acceptTerm" name="acceptTerm"> <label for="acceptTerm">我已阅读并同意</label> <!-- <input type="checkbox" id="acceptTerm" name="acceptTerm"> <label for="acceptTerm">我已阅读并同意</label>-->
<a href="https://gitee.com/y_project/RuoYi/blob/master/README.md" target="_blank">使用条款</a> <!-- <a href="https://gitee.com/y_project/RuoYi/blob/master/README.md" target="_blank">使用条款</a>-->
</div> <!-- </div>-->
<button class="btn btn-success btn-block" id="btnSubmit" data-loading="正在验证注册,请稍候...">注册</button> <button class="btn btn-success btn-block" id="btnSubmit" data-loading="正在验证注册,请稍候...">注册</button>
</form> </form>
</div> </div>
</div> </div>
<div class="signup-footer"> <div class="signup-footer">
<div class="pull-left"> <div class="pull-left">
&copy; 2018-2021 All Rights Reserved. RuoYi <br> Copyright © 2018-2021 opsoul.com All Rights Reserved. <br>
备案号 粤ICP备2021044349号-1
</div> </div>
</div> </div>
</div> </div>
@ -76,5 +78,6 @@
<script src="../static/ajax/libs/blockUI/jquery.blockUI.js" th:src="@{/ajax/libs/blockUI/jquery.blockUI.js}"></script> <script src="../static/ajax/libs/blockUI/jquery.blockUI.js" th:src="@{/ajax/libs/blockUI/jquery.blockUI.js}"></script>
<script src="../static/ruoyi/js/ry-ui.js" th:src="@{/ruoyi/js/ry-ui.js?v=4.7.2}"></script> <script src="../static/ruoyi/js/ry-ui.js" th:src="@{/ruoyi/js/ry-ui.js?v=4.7.2}"></script>
<script src="../static/ruoyi/register.js" th:src="@{/ruoyi/register.js}"></script> <script src="../static/ruoyi/register.js" th:src="@{/ruoyi/register.js}"></script>
<th:block th:include="include :: select2-js" />
</body> </body>
</html> </html>

View File

@ -0,0 +1,32 @@
package com.ghy.common.core.domain.dto;
import com.ghy.common.core.domain.BaseEntity;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/**
* @description:
* @author: yangdanqi
* @date: 2023/7/1
*/
@Data
public class SysUserAddDTO extends BaseEntity {
@NotNull(message = "公司编码不能为空")
private Long deptId;
@NotBlank(message = "账号不能为空")
@Length(min = 2, max = 20, message = "账户长度必须在2到20个字符之间")
private String loginName;
@NotBlank(message = "手机号码不能为空")
@Pattern(regexp = "^1[345678]\\d{9}$", message = "手机号码格式不正确")
private String phonenumber;
@NotBlank(message = "密码不能为空")
@Length(min = 5, max = 20, message = "密码长度必须在5到20个字符之间")
private String password;
}

View File

@ -287,6 +287,7 @@ public class ShiroConfig
filterChainDefinitionMap.put("/tool/**", "anon"); filterChainDefinitionMap.put("/tool/**", "anon");
filterChainDefinitionMap.put("/adapay/**", "anon"); filterChainDefinitionMap.put("/adapay/**", "anon");
filterChainDefinitionMap.put("/system/area/**", "anon"); filterChainDefinitionMap.put("/system/area/**", "anon");
filterChainDefinitionMap.put("/system/dept/list", "anon");
filterChainDefinitionMap.put("/customer/address/**", "anon"); filterChainDefinitionMap.put("/customer/address/**", "anon");
filterChainDefinitionMap.put("/customer/place/app/**", "anon"); filterChainDefinitionMap.put("/customer/place/app/**", "anon");
filterChainDefinitionMap.put("/customer/selection/app/**", "anon"); filterChainDefinitionMap.put("/customer/selection/app/**", "anon");

View File

@ -1,5 +1,7 @@
package com.ghy.framework.shiro.service; package com.ghy.framework.shiro.service;
import com.ghy.common.core.domain.dto.SysUserAddDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.ghy.common.constant.Constants; import com.ghy.common.constant.Constants;
@ -10,14 +12,14 @@ import com.ghy.common.utils.DateUtils;
import com.ghy.common.utils.MessageUtils; import com.ghy.common.utils.MessageUtils;
import com.ghy.common.utils.ServletUtils; import com.ghy.common.utils.ServletUtils;
import com.ghy.common.utils.ShiroUtils; import com.ghy.common.utils.ShiroUtils;
import com.ghy.common.utils.StringUtils;
import com.ghy.framework.manager.AsyncManager; import com.ghy.framework.manager.AsyncManager;
import com.ghy.framework.manager.factory.AsyncFactory; import com.ghy.framework.manager.factory.AsyncFactory;
import com.ghy.system.service.ISysUserService; import com.ghy.system.service.ISysUserService;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 注册校验方法 * 注册校验方法
* *
* @author clunt * @author clunt
*/ */
@Component @Component
@ -32,50 +34,30 @@ public class SysRegisterService
/** /**
* 注册 * 注册
*/ */
public String register(SysUser user) @Transactional(rollbackFor = Exception.class)
{ public String register(SysUserAddDTO userAddDTO) {
String msg = "", loginName = user.getLoginName(), password = user.getPassword(); String msg = "";
SysUser sysUser = new SysUser();
BeanUtils.copyProperties(userAddDTO, sysUser);
if (ShiroConstants.CAPTCHA_ERROR.equals(ServletUtils.getRequest().getAttribute(ShiroConstants.CURRENT_CAPTCHA))) if (ShiroConstants.CAPTCHA_ERROR.equals(ServletUtils.getRequest().getAttribute(ShiroConstants.CURRENT_CAPTCHA))) {
{
msg = "验证码错误"; msg = "验证码错误";
} } else if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(sysUser.getLoginName()))) {
else if (StringUtils.isEmpty(loginName)) msg = "保存用户'" + userAddDTO.getLoginName() + "'失败,注册账号已存在";
{ } else if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkPhoneUnique(sysUser))) {
msg = "用户名不能为空"; msg = "保存手机号码'" + userAddDTO.getPhonenumber() + "'失败,该手机号码已被注册";
} } else {
else if (StringUtils.isEmpty(password)) sysUser.setPwdUpdateDate(DateUtils.getNowDate());
{ sysUser.setUserName(userAddDTO.getLoginName());
msg = "用户密码不能为空"; sysUser.setSalt(ShiroUtils.randomSalt());
} sysUser.setPassword(passwordService.encryptPassword(sysUser.getLoginName(), sysUser.getPassword(), sysUser.getSalt()));
else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH boolean regFlag = userService.registerUser(sysUser);
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH) SysUser registeredUserInfo = userService.selectUserByLoginName(sysUser.getLoginName());
{ userService.insertUserAuth(registeredUserInfo.getUserId(), new Long[]{101l});
msg = "密码长度必须在5到20个字符之间"; if (!regFlag) {
}
else if (loginName.length() < UserConstants.USERNAME_MIN_LENGTH
|| loginName.length() > UserConstants.USERNAME_MAX_LENGTH)
{
msg = "账户长度必须在2到20个字符之间";
}
else if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(loginName)))
{
msg = "保存用户'" + loginName + "'失败,注册账号已存在";
}
else
{
user.setPwdUpdateDate(DateUtils.getNowDate());
user.setUserName(loginName);
user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
boolean regFlag = userService.registerUser(user);
if (!regFlag)
{
msg = "注册失败,请联系系统管理人员"; msg = "注册失败,请联系系统管理人员";
} } else {
else AsyncManager.me().execute(AsyncFactory.recordLogininfor(userAddDTO.getLoginName(), Constants.REGISTER, MessageUtils.message("user.register.success")));
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, Constants.REGISTER, MessageUtils.message("user.register.success")));
} }
} }
return msg; return msg;

View File

@ -29,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult" /> <association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" /> <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap> </resultMap>
<resultMap id="deptResult" type="SysDept"> <resultMap id="deptResult" type="SysDept">
<id property="deptId" column="dept_id" /> <id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" /> <result property="parentId" column="parent_id" />
@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="leader" column="leader" /> <result property="leader" column="leader" />
<result property="status" column="dept_status" /> <result property="status" column="dept_status" />
</resultMap> </resultMap>
<resultMap id="RoleResult" type="SysRole"> <resultMap id="RoleResult" type="SysRole">
<id property="roleId" column="role_id" /> <id property="roleId" column="role_id" />
<result property="roleName" column="role_name" /> <result property="roleName" column="role_name" />
@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="dataScope" column="data_scope" /> <result property="dataScope" column="data_scope" />
<result property="status" column="role_status" /> <result property="status" column="role_status" />
</resultMap> </resultMap>
<sql id="selectUserVo"> <sql id="selectUserVo">
select u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.sex, u.password, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.pwd_update_date, u.create_time, u.remark, select u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.sex, u.password, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.pwd_update_date, u.create_time, u.remark,
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status, d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
@ -57,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_user_role ur on u.user_id = ur.user_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 left join sys_role r on r.role_id = ur.role_id
</sql> </sql>
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.salt, 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 select u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.salt, 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 left join sys_dept d on u.dept_id = d.dept_id
@ -86,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 数据范围过滤 --> <!-- 数据范围过滤 -->
${params.dataScope} ${params.dataScope}
</select> </select>
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult"> <select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time select distinct u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time
from sys_user u from sys_user u
@ -103,7 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 数据范围过滤 --> <!-- 数据范围过滤 -->
${params.dataScope} ${params.dataScope}
</select> </select>
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult"> <select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time select distinct u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time
from sys_user u from sys_user u
@ -121,50 +121,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 数据范围过滤 --> <!-- 数据范围过滤 -->
${params.dataScope} ${params.dataScope}
</select> </select>
<select id="selectUserByLoginName" parameterType="String" resultMap="SysUserResult"> <select id="selectUserByLoginName" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/> <include refid="selectUserVo"/>
where u.login_name = #{userName} where u.login_name = #{userName}
</select> </select>
<select id="selectUserByPhoneNumber" parameterType="String" resultMap="SysUserResult"> <select id="selectUserByPhoneNumber" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/> <include refid="selectUserVo"/>
where u.phonenumber = #{phonenumber} where u.phonenumber = #{phonenumber}
</select> </select>
<select id="selectUserByEmail" parameterType="String" resultMap="SysUserResult"> <select id="selectUserByEmail" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/> <include refid="selectUserVo"/>
where u.email = #{email} where u.email = #{email}
</select> </select>
<select id="checkLoginNameUnique" parameterType="String" resultType="int"> <select id="checkLoginNameUnique" parameterType="String" resultType="int">
select count(1) from sys_user where login_name=#{loginName} limit 1 select count(1) from sys_user where login_name=#{loginName} and del_flag = 0 limit 1
</select> </select>
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult"> <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
select user_id, phonenumber from sys_user where phonenumber=#{phonenumber} limit 1 select user_id, phonenumber from sys_user where phonenumber=#{phonenumber} and del_flag = 0 limit 1
</select> </select>
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult"> <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
select user_id, email from sys_user where email=#{email} limit 1 select user_id, email from sys_user where email=#{email} limit 1
</select> </select>
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult"> <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
<include refid="selectUserVo"/> <include refid="selectUserVo"/>
where u.user_id = #{userId} where u.user_id = #{userId}
</select> </select>
<delete id="deleteUserById" parameterType="Long"> <delete id="deleteUserById" parameterType="Long">
update sys_user set del_flag = '2' where user_id = #{userId} update sys_user set del_flag = '2' where user_id = #{userId}
</delete> </delete>
<delete id="deleteUserByIds" parameterType="Long"> <delete id="deleteUserByIds" parameterType="Long">
update sys_user set del_flag = '2' where user_id in update sys_user set del_flag = '2' where user_id in
<foreach collection="array" item="userId" open="(" separator="," close=")"> <foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId} #{userId}
</foreach> </foreach>
</delete> </delete>
<update id="updateUser" parameterType="SysUser"> <update id="updateUser" parameterType="SysUser">
update sys_user update sys_user
<set> <set>
@ -188,7 +188,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</set> </set>
where user_id = #{userId} where user_id = #{userId}
</update> </update>
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user( insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if> <if test="userId != null and userId != 0">user_id,</if>
@ -226,5 +226,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sysdate() sysdate()
) )
</insert> </insert>
</mapper> </mapper>