25-用户注册

main
喻忠伟 4 months ago
parent 2fc9136657
commit 1614ce0094
  1. 3
      jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  2. 48
      jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDepartController.java
  3. 78
      jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
  4. 18
      jeecgboot-vue3-master/src/api/common/api.ts
  5. 9
      jeecgboot-vue3-master/src/api/sys/user.ts
  6. 169
      jeecgboot-vue3-master/src/components/Form/src/jeecg/components/JStuSelectDept.vue
  7. 122
      jeecgboot-vue3-master/src/components/Form/src/jeecg/components/modal/DeptStuSelectModal.vue
  8. 49
      jeecgboot-vue3-master/src/views/system/loginmini/MiniRegister.vue

@ -79,6 +79,8 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/sys/randomImage/**", "anon"); //登录验证码接口排除
filterChainDefinitionMap.put("/sys/checkCaptcha", "anon"); //登录验证码接口排除
filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
filterChainDefinitionMap.put("/sys/sysDepart/queryDepartStuTreeSync", "anon"); //学生部门注册接口排除
filterChainDefinitionMap.put("/sys/sysDepart/queryTreeStuList", "anon"); //学生部门注册接口排除
filterChainDefinitionMap.put("/sys/mLogin", "anon"); //登录接口排除
filterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除
filterChainDefinitionMap.put("/sys/thirdLogin/**", "anon"); //第三方登录
@ -87,6 +89,7 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/sys/phoneLogin", "anon");//手机登录
filterChainDefinitionMap.put("/sys/user/checkOnlyUser", "anon");//校验用户是否存在
filterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册
filterChainDefinitionMap.put("/sys/user/sturegister", "anon");//学生-用户注册
filterChainDefinitionMap.put("/sys/user/phoneVerification", "anon");//用户忘记密码验证手机号
filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码

@ -141,6 +141,54 @@ public class SysDepartController {
return result;
}
/**
* 学生-异步查询部门list
* @param parentId 父节点 异步加载时传递
* @param ids 前端回显是传递
* @param primaryKey 主键字段id或者orgCode
* @return
*/
@RequestMapping(value = "/queryDepartStuTreeSync", method = RequestMethod.GET)
public Result<List<SysDepartTreeModel>> queryDepartStuTreeSync(@RequestParam(name = "pid", required = false) String parentId,@RequestParam(name = "ids", required = false) String ids, @RequestParam(name = "primaryKey", required = false) String primaryKey) {
Result<List<SysDepartTreeModel>> result = new Result<>();
try {
List<SysDepartTreeModel> list = sysDepartService.queryTreeListByPid(parentId, ids, primaryKey);
result.setResult(list);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return result;
}
/**
* 学生-查询数据 查出所有部门,并以树结构数据格式响应给前端
*
* @return
*/
@RequestMapping(value = "/queryTreeStuList", method = RequestMethod.GET)
public Result<List<SysDepartTreeModel>> queryTreeStuList(@RequestParam(name = "ids", required = false) String ids) {
Result<List<SysDepartTreeModel>> result = new Result<>();
try {
// 从内存中读取
// List<SysDepartTreeModel> list =FindsDepartsChildrenUtil.getSysDepartTreeList();
// if (CollectionUtils.isEmpty(list)) {
// list = sysDepartService.queryTreeList();
// }
if(oConvertUtils.isNotEmpty(ids)){
List<SysDepartTreeModel> departList = sysDepartService.queryTreeList(ids);
result.setResult(departList);
}else{
List<SysDepartTreeModel> list = sysDepartService.queryTreeList();
result.setResult(list);
}
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}
/**
* 异步查询当前用户部门

@ -370,7 +370,7 @@ public class SysUserController {
/**
* 删除用户
*/
@RequiresPermissions("system:user:delete")
// @RequiresPermissions("system:user:delete")
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
baseCommonService.addLog("删除用户,id: " +id ,CommonConstant.LOG_TYPE_2, 3);
@ -1122,6 +1122,82 @@ public class SysUserController {
return result;
}
/**
* 用户注册接口
*
* @param jsonObject
* @param user
* @return
*/
@PostMapping("/sturegister")
public Result<JSONObject> sturUserRegister(@RequestBody JSONObject jsonObject, SysUser user) {
Result<JSONObject> result = new Result<JSONObject>();
String phone = jsonObject.getString("phone");
String smscode = jsonObject.getString("smscode");
String departmentid = jsonObject.getString("departmentid");
String realname = jsonObject.getString("realname");
//update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
String redisKey = CommonConstant.PHONE_REDIS_KEY_PRE+phone;
Object code = redisUtil.get(redisKey);
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
String username = jsonObject.getString("username");
//未设置用户名,则用手机号作为用户名
if(oConvertUtils.isEmpty(username)){
username = phone;
}
//未设置密码,则随机生成一个密码
String password = jsonObject.getString("password");
String email = jsonObject.getString("email");
SysUser sysUser1 = sysUserService.getUserByName(username);
if (sysUser1 != null) {
result.setMessage("用户名已注册");
result.setSuccess(false);
return result;
}
SysUser sysUser2 = sysUserService.getUserByPhone(phone);
if (sysUser2 != null) {
result.setMessage("该手机号已注册");
result.setSuccess(false);
return result;
}
if(null == code){
result.setMessage("验证码失效,请重新获取");
result.setSuccess(false);
return result;
}
if (!smscode.equals(code.toString())) {
result.setMessage("验证码错误!");
result.setSuccess(false);
return result;
}
if(oConvertUtils.isEmpty(realname)){
realname = username;
}
try {
user.setCreateTime(new Date());// 设置创建时间
String salt = oConvertUtils.randomGen(8);
String passwordEncode = PasswordUtil.encrypt(username, password, salt);
user.setSalt(salt);
user.setUsername(username);
user.setRealname(realname);
user.setPassword(passwordEncode);
//user.setEmail(email);
user.setPhone(phone);
user.setStatus(CommonConstant.USER_UNFREEZE);
user.setDelFlag(CommonConstant.DEL_FLAG_0);
user.setActivitiSync(CommonConstant.ACT_SYNC_0);
sysUserService.addUserWithRole(user,"1724327596426760194");
sysUserService.addUserWithDepart(user,departmentid);
result.success("注册成功");
} catch (Exception e) {
result.error500("注册失败");
}
return result;
}

@ -9,6 +9,8 @@ enum Api {
roleList = '/sys/role/list',
queryDepartTreeSync = '/sys/sysDepart/queryDepartTreeSync',
queryTreeList = '/sys/sysDepart/queryTreeList',
queryStuDepartTreeSync = '/sys/sysDepart/queryDepartStuTreeSync',
queryStuTreeList = '/sys/sysDepart/queryTreeStuList',
loadTreeData = '/sys/category/loadTreeData',
loadDictItem = '/sys/category/loadDictItem/',
getDictItems = '/sys/dict/getDictItems/',
@ -63,6 +65,20 @@ export const queryTreeList = (params?) => {
return defHttp.get({ url: Api.queryTreeList, params });
};
/**
* -
*/
export const queryStuDepartTreeSync = (params?) => {
return defHttp.get({ url: Api.queryStuDepartTreeSync, params });
};
/**
* -
*/
export const queryStuTreeList = (params?) => {
return defHttp.get({ url: Api.queryStuTreeList, params });
};
/**
*
*/
@ -164,4 +180,4 @@ export const getStudent = () => {
return defHttp.get({
url:'/annualcompetitionprojectregistration/annualCompetitionProjectRegistration/xssybsjs'
})
}
}

@ -26,6 +26,8 @@ enum Api {
getCaptcha = '/sys/sms',
//注册接口
registerApi = '/sys/user/register',
//学生_注册接口
registerStuApi = '/sys/user/sturegister',
//校验用户接口
checkOnlyUser = '/sys/user/checkOnlyUser',
//SSO登录校验
@ -127,6 +129,13 @@ export function register(params) {
return defHttp.post({ url: Api.registerApi, params }, { isReturnNativeResponse: true });
}
/**
* @description:
*/
export function registerStu(params) {
return defHttp.post({ url: Api.registerStuApi, params }, { isReturnNativeResponse: true });
}
/**
*
* @param params

@ -0,0 +1,169 @@
<!--部门选择组件-->
<template>
<div>
<JSelectBiz @handleOpen="handleOpen" :loading="loadingEcho" v-bind="attrs" @change="handleChange"/>
<DeptStuSelectModal @register="regModal" @getSelectResult="setValue" v-bind="getBindValue" />
</div>
</template>
<script lang="ts">
import DeptStuSelectModal from './modal/DeptStuSelectModal.vue';
import JSelectBiz from './base/JSelectBiz.vue';
import { defineComponent, ref, reactive, watchEffect, watch, provide, unref, toRaw } from 'vue';
import { useModal } from '/@/components/Modal';
import { propTypes } from '/@/utils/propTypes';
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
import { useAttrs } from '/@/hooks/core/useAttrs';
import { SelectValue } from 'ant-design-vue/es/select';
export default defineComponent({
name: 'JStuSelectDept',
components: {
DeptStuSelectModal,
JSelectBiz,
},
inheritAttrs: false,
props: {
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
// true
multiple: propTypes.bool.def(true),
},
emits: ['options-change', 'change', 'select', 'update:value'],
setup(props, { emit, refs }) {
const emitData = ref<any[]>();
//model
const [regModal, { openModal }] = useModal();
//
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
//
const selectOptions = ref<SelectValue>([]);
//
let selectValues = reactive<Recordable>({
value: [],
});
//
const loadingEcho = ref<boolean>(false);
// selectOptions,xxxBiz
provide('selectOptions', selectOptions);
// selectValues,xxxBiz
provide('selectValues', selectValues);
// loadingEcho,xxxBiz
provide('loadingEcho', loadingEcho);
const tag = ref(false);
const attrs = useAttrs();
/**
* 监听组件值
*/
watchEffect(() => {
props.value && initValue();
});
//update-begin-author:liusq---date:20220609--for: form ---
watch(
() => props.value,
() => {
initValue();
}
);
//update-end-author:liusq---date:20220609--for: form ---
/**
* 监听selectValues变化
*/
watch(selectValues, () => {
if (selectValues) {
state.value = selectValues.value;
}
});
/**
* 监听selectOptions变化
*/
watch(selectOptions, () => {
if (selectOptions) {
emit('select', toRaw(unref(selectOptions)), toRaw(unref(selectValues)));
}
});
/**
* 打卡弹出框
*/
function handleOpen() {
tag.value = true;
openModal(true, {
isUpdate: false,
});
}
/**
* 将字符串值转化为数组
*/
function initValue() {
let value = props.value ? props.value : [];
if (value && typeof value === 'string') {
state.value = value.split(',');
selectValues.value = value.split(',');
} else {
// VUEN-857
selectValues.value = value;
}
}
/**
* 设置下拉框的值
*/
function setValue(options, values) {
selectOptions.value = options;
//emitData.value = values.join(",");
state.value = values;
selectValues.value = values;
emit('update:value', values.join(','));
}
const getBindValue = Object.assign({}, unref(props), unref(attrs));
//update-begin---author:wangshuai ---date:20230406 forissues/397使v-model:valueJSelectDept------------
/**
* 值改变事件更新value值
* @param values
*/
function handleChange(values) {
emit('update:value', values);
}
//update-end---author:wangshuai ---date:20230406 forissues/397使v-model:valueJSelectDept------------
return {
state,
attrs,
selectOptions,
selectValues,
loadingEcho,
getBindValue,
tag,
regModal,
setValue,
handleOpen,
handleChange
};
},
});
</script>
<style lang="less" scoped>
.j-select-row {
@width: 82px;
.left {
width: calc(100% - @width - 8px);
}
.right {
width: @width;
}
.full {
width: 100%;
}
:deep(.ant-select-search__field) {
display: none !important;
}
}
</style>

@ -0,0 +1,122 @@
<!--部门选择框-->
<template>
<div>
<BasicModal v-bind="$attrs" @register="register" :title="modalTitle" width="500px" @ok="handleOk" destroyOnClose @visible-change="visibleChange">
<BasicTree
ref="treeRef"
:treeData="treeData"
:load-data="sync == false ? null : onLoadData"
v-bind="getBindValue"
@select="onSelect"
@check="onCheck"
:fieldNames="fieldNames"
:checkedKeys="checkedKeys"
:checkStrictly="getCheckStrictly"
/>
<!--树操作部分-->
<template #insertFooter>
<a-dropdown placement="top">
<template #overlay>
<a-menu>
<!-- <a-menu-item v-if="multiple" key="1" @click="checkALL(true)">全部勾选</a-menu-item>-->
<!-- <a-menu-item v-if="multiple" key="2" @click="checkALL(false)">取消全选</a-menu-item>-->
<a-menu-item key="3" @click="expandAll(true)">展开全部</a-menu-item>
<a-menu-item key="4" @click="expandAll(false)">折叠全部</a-menu-item>
</a-menu>
</template>
<a-button style="float: left"> 树操作 <Icon icon="ant-design:up-outlined" /> </a-button>
</a-dropdown>
</template>
</BasicModal>
</div>
</template>
<script lang="ts">
import { defineComponent, ref, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { queryStuDepartTreeSync, queryStuTreeList } from '/@/api/common/api';
import { useAttrs } from '/@/hooks/core/useAttrs';
import { treeProps } from '/@/components/Form/src/jeecg/props/props';
import { BasicTree, TreeActionType } from '/@/components/Tree';
import { useTreeBiz } from '/@/components/Form/src/jeecg/hooks/useTreeBiz';
import {propTypes} from "/@/utils/propTypes";
export default defineComponent({
name: 'DeptStuSelectModal',
components: {
BasicModal,
BasicTree,
},
props: {
...treeProps,
//
modalTitle: {
type: String,
default: '院系选择',
},
value: propTypes.oneOfType([propTypes.string, propTypes.array])
},
emits: ['register', 'getSelectResult'],
setup(props, { emit, refs }) {
//
const [register, { closeModal }] = useModalInner();
const attrs = useAttrs();
const treeRef = ref<Nullable<TreeActionType>>(null);
//update-begin-author:taoyan date:2022-10-28 for:
let propValue = props.value === ''?[]:props.value;
//update-begin-author:liusq date:2023-05-26 for: [issues/538]JSelectDept dynamicDisabled
const getBindValue = Object.assign({}, unref(props), unref(attrs), {value: propValue},{disabled: false});
//update-end-author:liusq date:2023-05-26 for: [issues/538]JSelectDept dynamicDisabled
//update-end-author:taoyan date:2022-10-28 for:
const queryUrl = getQueryUrl();
const [{ visibleChange, checkedKeys, getCheckStrictly, getSelectTreeData, onCheck, onLoadData, treeData, checkALL, expandAll, onSelect }] =
useTreeBiz(treeRef, queryUrl, getBindValue);
const searchInfo = ref(props.params);
const tree = ref([]);
//treeNodekeytreeData
const fieldNames = {
key: props.rowKey,
};
// {children:'children', title:'title', key:'key' }
/**
* 确定选择
*/
function handleOk() {
getSelectTreeData((options, values) => {
//
emit('getSelectResult', options, values);
//
closeModal();
});
}
/** 获取查询数据方法 */
function getQueryUrl() {
let queryFn = props.sync ? queryStuDepartTreeSync : queryStuTreeList;
//update-begin-author:taoyan date:2022-7-4 for: issues/I5F3P4 online
return (params) => queryFn(Object.assign({}, params, { primaryKey: props.rowKey }));
//update-end-author:taoyan date:2022-7-4 for: issues/I5F3P4 online
}
return {
tree,
handleOk,
searchInfo,
treeRef,
treeData,
onCheck,
onSelect,
checkALL,
expandAll,
fieldNames,
checkedKeys,
register,
getBindValue,
getCheckStrictly,
visibleChange,
onLoadData,
};
},
});
</script>

@ -24,21 +24,21 @@
<a-form-item>
<div class="aui-input-line">
<Icon class="aui-icon" icon="ant-design:mobile-outlined" />
<a-input class="fix-auto-fill" type="text" :placeholder="t('sys.login.name')" v-model:value="formData.name" />
<a-input class="fix-auto-fill" type="text" :placeholder="t('sys.login.name')" v-model:value="formData.realname" />
</div>
</a-form-item>
<a-form-item>
<div class="aui-input-line">
<Icon class="aui-icon" icon="ant-design:mobile-outlined" />
<a-input class="fix-auto-fill" type="text" :placeholder="t('sys.login.department')" v-model:value="formData.department" />
<!-- <DeptSelectModal rowKey="id" @register="registerSelModal" @getSelectResult="onSelectOk"/> -->
<!-- <a-input class="fix-auto-fill" type="text" :placeholder="t('sys.login.department')" />-->
<JStuSelectDept v-model:value="formData.department" :multiple="false" />
</div>
</a-form-item>
<a-form-item>
<div class="aui-input-line">
<Icon class="aui-icon" icon="ant-design:mobile-outlined" />
<a-input class="fix-auto-fill" type="text" :placeholder="t('sys.login.name')" v-model:value="formData.name" />
<a-input class="fix-auto-fill" type="text" :placeholder="t('sys.login.mobile')" v-model:value="formData.mobile" />
</div>
</a-form-item>
<!-- <a-form-item>
@ -79,16 +79,16 @@
</div>
</div>
</a-form-item>
<a-form-item name="policy">
<div class="aui-flex">
<div class="aui-flex-box">
<div class="aui-choice">
<a-checkbox v-model:checked="formData.policy" />
<span style="color: #1b90ff; margin-left: 4px">{{ t('sys.login.policy') }}</span>
</div>
</div>
</div>
</a-form-item>
<!-- <a-form-item name="policy">-->
<!-- <div class="aui-flex">-->
<!-- <div class="aui-flex-box">-->
<!-- <div class="aui-choice">-->
<!-- <a-checkbox v-model:checked="formData.policy" />-->
<!-- <span style="color: #1b90ff; margin-left: 4px">{{ t('sys.login.policy') }}</span>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </a-form-item>-->
</div>
</div>
<div class="aui-formButton">
@ -109,13 +109,14 @@
<script lang="ts" setup name="mini-register">
import { ref, reactive, unref, toRaw } from 'vue';
import { getCaptcha, register } from '/@/api/sys/user';
import { getCaptcha, registerStu } from '/@/api/sys/user';
import { SmsEnum } from '/@/views/sys/login/useLogin';
import { useMessage } from '/@/hooks/web/useMessage';
import logoImg from '/@/assets/loginmini/icon/jeecg_logo.png';
import jeecgAdTextImg from '/@/assets/loginmini/icon/jeecg_ad_text.png';
import eyeKImg from '/@/assets/loginmini/icon/icon-eye-k.png';
import eyeGImg from '/@/assets/loginmini/icon/icon-eye-g.png';
import JStuSelectDept from '/@/components/Form/src/jeecg/components/JStuSelectDept.vue';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
@ -128,8 +129,8 @@
smscode: '',
password: '',
confirmPassword: '',
policy: false,
name: '',
// policy: false,
realname: '',
department: '',
});
@ -205,10 +206,10 @@
createMessage.warn(t('sys.login.diffPwd'));
return;
}
if (!formData.policy) {
createMessage.warn(t('sys.login.policyPlaceholder'));
return;
}
// if (!formData.policy) {
// createMessage.warn(t('sys.login.policyPlaceholder'));
// return;
// }
registerAccount();
}
@ -217,9 +218,11 @@
*/
async function registerAccount() {
try {
const resultInfo = await register(
const resultInfo = await registerStu(
toRaw({
username: formData.username,
departmentid: formData.department,
realname: formData.realname,
password: formData.password,
phone: formData.mobile,
smscode: formData.smscode,
@ -252,7 +255,7 @@
* 初始化表单
*/
function initForm() {
Object.assign(formData, { username: '', mobile: '', smscode: '', password: '', confirmPassword: '', policy: false });
Object.assign(formData, { username: '', mobile: '', realname: '', department: '', smscode: '', password: '', confirmPassword: ''/*, policy: false*/ });
if (!unref(timer)) {
showInterval.value = true;
clearInterval(unref(timer));

Loading…
Cancel
Save