Commit f66cc25f authored by 廖旭伟's avatar 廖旭伟

Merge remote-tracking branch 'origin/master'

parents 8c1743da 6da7355c
......@@ -136,7 +136,6 @@ function handleTree(data, id, parentId, children, rootId) {
const treeData = cloneData.filter((father) => {
let branchArr = cloneData.filter((child) => {
//返回每一项的子级数组
console.log(child[parentId]);
return father[id] === child[parentId];
});
branchArr.length > 0 ? (father.children = branchArr) : "";
......
......@@ -10,8 +10,8 @@
<div class="content_box">
<div class="text_line">
<div class="text_box">
<span style="width: 160px;"> (单位) 名称:</span>
<span>{{ form.ownerName || "--" }}</span>
<span style="width: 160px;"> (单位) 名称:</span>
<span>{{ windowName || "--" }}</span>
</div>
<div class="text_box">
<span>登记年月:</span>
......@@ -301,6 +301,7 @@ export default {
},
data() {
return {
windowName: "",
// 遮罩层
loading: true,
// 弹出层标题
......@@ -324,6 +325,7 @@ export default {
},
/** 编辑 */
async edit(row) {
this.windowName = row.windowName;
// this.reset();
// this.query = { id: row.id };
this.urls.saveUrl = "check/window/workman/perform/examine";
......@@ -429,14 +431,13 @@ export default {
// this.getData();
// this.pageInfo.type = "view";
// this.title = "窗口人员考核汇总核查详细";
this.windowName = row.windowName;
this.form = row;
this.reset();
this.query = { id: row.id };
await this.$get("/window/workman/perform/info", {
id: row.recordId,
}).then((res) => {
console.log(res);
if (res.code == 1) {
this.form = res.data;
this.form.id = row.id;
......
......@@ -12,7 +12,10 @@
</div>
</div>
<div class="user-right">
<div class="n">{{ form.totalScore }}</div>
<div class="n">{{ form.otherScore }}</div>
<div class="m">{{ form.month }}月自评绩效得分</div>
<div class="n" style="margin-top: 10px;">{{ form.totalScore }}</div>
<div class="m">{{ form.month }}月得分</div>
</div>
</div>
......@@ -68,7 +71,7 @@
<Field label="评价绩效指标分数" prop="assessScore" v-model="form.assessScore" placeholder="请输入评价绩效指标分数" />
<Field label="办件绩效分数" prop="workScore" v-model="form.workScore" placeholder="请输入办件绩效分数" />
<Field label="效能绩效分数" prop="effectScore" v-model="form.effectScore" placeholder="请输入效能绩效分数" />
<Field label="其它绩效分数" prop="otherScore" v-model="form.otherScore" placeholder="请输入其它绩效分数" />
<Field label="自评绩效分数" prop="otherScore" v-model="form.otherScore" placeholder="请输入其它绩效分数" />
<Field label="累计异常分数" prop="errorScore" v-model="form.errorScore" placeholder="请输入累计异常分数" />
<Field label="当月得分数" prop="totalScore" v-model="form.totalScore" placeholder="请输入当月得分数" />
<Field label="备注" prop="remark" v-model="form.remark" type="textarea" placeholder="请输入备注" />
......
......@@ -141,7 +141,7 @@ export default {
},
{
label: "其它绩效分数",
label: "自评绩效分数",
prop: "otherScore",
},
......
<template>
<layout-view>
<el-descriptions :title="title" :column="column" :size="size" :colon="false" border>
<el-descriptions
:title="title"
:column="column"
:size="size"
:colon="false"
border
>
<template slot="title">
<i class="el-icon-tickets"></i>
基本详细信息
</template>
<template slot="extra">
<el-button type="primary" @click="$router.go(-1)" size="small">返回</el-button>
<el-button type="primary" @click="$router.go(-1)" size="small"
>返回</el-button
>
</template>
<el-descriptions-item label="人员id" label-class-name="labelClass" content-class-name="contentClass">
{{form.staffId}}
<el-descriptions-item
label="人员id"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.staffId }}
</el-descriptions-item>
<el-descriptions-item label="工号" label-class-name="labelClass" content-class-name="contentClass">
{{form.workNum}}
<el-descriptions-item
label="工号"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.workNum }}
</el-descriptions-item>
<el-descriptions-item label="人员名称" label-class-name="labelClass" content-class-name="contentClass">
{{form.staffName}}
<el-descriptions-item
label="人员名称"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.staffName }}
</el-descriptions-item>
<el-descriptions-item label="部门id号" label-class-name="labelClass" content-class-name="contentClass">
{{form.deptId}}
<el-descriptions-item
label="部门id号"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.deptId }}
</el-descriptions-item>
<el-descriptions-item label="部门名称" label-class-name="labelClass" content-class-name="contentClass">
{{form.deptName}}
<el-descriptions-item
label="部门名称"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.deptName }}
</el-descriptions-item>
<el-descriptions-item label="考勤绩效指标分数" label-class-name="labelClass" content-class-name="contentClass">
{{form.attendScore}}
<el-descriptions-item
label="考勤绩效指标分数"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.attendScore }}
</el-descriptions-item>
<el-descriptions-item label="评价绩效指标分数" label-class-name="labelClass" content-class-name="contentClass">
{{form.assessScore}}
<el-descriptions-item
label="评价绩效指标分数"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.assessScore }}
</el-descriptions-item>
<el-descriptions-item label="办件绩效分数" label-class-name="labelClass" content-class-name="contentClass">
{{form.workScore}}
<el-descriptions-item
label="办件绩效分数"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.workScore }}
</el-descriptions-item>
<el-descriptions-item label="效能绩效分数" label-class-name="labelClass" content-class-name="contentClass">
{{form.effectScore}}
<el-descriptions-item
label="效能绩效分数"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.effectScore }}
</el-descriptions-item>
<el-descriptions-item label="其它绩效分数" label-class-name="labelClass" content-class-name="contentClass">
{{form.otherScore}}
<el-descriptions-item
label="自评绩效分数"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.otherScore }}
</el-descriptions-item>
<el-descriptions-item label="累计异常分数" label-class-name="labelClass" content-class-name="contentClass">
{{form.errorScore}}
<el-descriptions-item
label="累计异常分数"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.errorScore }}
</el-descriptions-item>
<el-descriptions-item label="当月得分数" label-class-name="labelClass" content-class-name="contentClass">
{{form.totalScore}}
<el-descriptions-item
label="当月得分数"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.totalScore }}
</el-descriptions-item>
<el-descriptions-item label="备注" label-class-name="labelClass" content-class-name="contentClass">
{{form.remark}}
<el-descriptions-item
label="备注"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.remark }}
</el-descriptions-item>
<el-descriptions-item label="年" label-class-name="labelClass" content-class-name="contentClass">
{{form.year}}
<el-descriptions-item
label="年"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.year }}
</el-descriptions-item>
<el-descriptions-item label="月" label-class-name="labelClass" content-class-name="contentClass">
{{form.month}}
<el-descriptions-item
label="月"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.month }}
</el-descriptions-item>
</el-descriptions>
</layout-view>
</template>
<script>
import view from "@/assets/mixins/view";
export default {
import view from "@/assets/mixins/view";
export default {
mixins: [view],
components: {
},
methods: {
},
components: {},
methods: {},
data() {
return {
size:"small",
column:2,
toString:[
"month",
],
toArrays: [
],
toDate: [
]
}
}
}
size: "small",
column: 2,
toString: ["month"],
toArrays: [],
toDate: [],
};
},
};
</script>
<style lang="less">
.labelClass{
.labelClass {
width: 200px;
}
.el-descriptions__body{
}
.el-descriptions__body {
margin-left: 5px;
margin-right: 5px;
color: #606266;
background-color: #FFF;
}
.contentClass{
background-color: #fff;
}
.contentClass {
width: 600px;
}
}
</style>
<template>
<div class="page">
<LayoutTable :data="tableData" :config="tableConfig" notDel />
<dialog-show ref="dialogform" @ok="getData" />
<LayoutTable :data="tableData" :config="tableConfig" notDel/>
<dialog-show ref="dialogform" @ok="getData"/>
<el-dialog title="用户已分配的角色" :visible.sync="role.visible">
<el-form :model="role.form">
......@@ -10,7 +10,8 @@
v-for="item in allRoles"
:key="item.id"
:label="item.id"
>{{ item.name }}</el-checkbox
>{{ item.name }}
</el-checkbox
>
</el-checkbox-group>
</el-form>
......@@ -68,6 +69,70 @@
<el-button @click="userDeptDialog.open = false">取 消</el-button>
</div>
</el-dialog>
<el-dialog
:title="userPasswordDialog.title"
hei
:visible.sync="userPasswordDialog.open"
width="60%"
>
<el-form
ref="form"
label-width="110px"
label-position="right"
>
<el-row>
<Field
:span="20"
label="登录名称"
prop="loginName"
disabled
v-model="userPasswordDialog.data.loginName"
/>
<Field
label="登录密码"
prop="loginPwd"
v-model="userPasswordDialog.data.loginPwd"
/>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="updatePasswordConfirm">确 定</el-button>
<el-button @click="userPasswordDialog.open = false">取 消</el-button>
</div>
</el-dialog>
<el-dialog
:title="userLoginDialog.title"
hei
:visible.sync="userLoginDialog.open"
width="60%"
>
<el-form
ref="form"
label-width="110px"
label-position="right"
>
<el-row>
<Field
:span="20"
label="登录名称"
prop="loginName"
v-model="userPasswordDialog.data.loginName"
/>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="updateLoginConfirm">确 定</el-button>
<el-button @click="userLoginDialog.open = false">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
......@@ -77,10 +142,10 @@ import table from "@/assets/mixins/table";
export default {
mixins: [table],
components: { dialogShow },
components: {dialogShow},
methods: {
// 打开弹窗
async findRole({ id }) {
async findRole({id}) {
try {
this.tableData.loading = true;
this.allRoles = await this.getUserRoles(id);
......@@ -93,7 +158,7 @@ export default {
this.tableData.loading = false;
},
renderContent: function(h, { node, data, store }) {
renderContent: function (h, {node, data, store}) {
return (
<span>
<i style="font-size:16px;color:#409EFF" class={data.icon}></i>
......@@ -107,23 +172,13 @@ export default {
}
this.$get("/dept/getListByParentId", {
parentId: node.data.id,
}).then(({ data }) => {
}).then(({data}) => {
resolve(data.result);
});
},
handleNodeClick(data, node, obj) {
console.log("select node tree", data);
this.node = data;
// this.userDeptDialog.open = false;
// this.$post("/user/save", {
// deptId: data.id,
// })
// .then((res) => {
//
// })
// .catch((error) => {
// this.$message.error(error);
// });
},
userDeptConfirm(row) {
......@@ -186,7 +241,7 @@ export default {
this.$nextTick(() => {
this.$get("/dept/getListByParentId", {
parentId: 0,
}).then(({ data }) => {
}).then(({data}) => {
this.data = data.result;
this.node = {};
console.log("data", this.data);
......@@ -199,11 +254,75 @@ export default {
this.tableData.loading = false;
},
updatePassword(row) {
console.log("修改密码");
try {
this.userPasswordDialog.data = row;
this.userPasswordDialog.data.loginPwd = "";
this.userPasswordDialog.open = true;
} catch (error) {
this.$message.error(error.message);
}
},
updatePasswordConfirm() {
console.log("修改密码");
try {
this.$post("/user/save", {
"id": userPasswordDialog.data.id,
"loginPwd": userPasswordDialog.data.loginPwd,
}).then((res) => {
if (res && res.code == 1) {
this.userPasswordDialog.data = {};
this.$message.success("修改密码成功!");
} else {
this.$message.error(res.message);
}
this.userRoleDialog.open = false;
})
} catch (error) {
this.$message.error(error.message);
}
},
updateLoginName(row) {
console.log("修改登录名");
try {
this.userLoginDialog.data = row;
this.userLoginDialog.data.loginName = "";
this.userLoginDialog.open = true;
} catch (error) {
this.$message.error(error.message);
}
},
updateLoginConfirm() {
console.log("修改登录名");
try {
this.$post("/user/save", {
"id": user.data.id,
"loginName": userLoginDialog.data.loginName,
}).then((res) => {
if (res && res.code == 1) {
this.userLoginDialog.data = {};
this.$message.success("修改登录名成功!");
} else {
this.$message.error(res.message);
}
this.userLoginDialog.open = false;
})
} catch (error) {
this.$message.error(error.message);
}
},
// 获取用户角色列表
getUserRoles(id) {
return new Promise((resolve, reject) => {
this.$post("/role/roleNameByUserId", { userId: id })
.then(({ data }) => {
this.$post("/role/roleNameByUserId", {userId: id})
.then(({data}) => {
resolve(data);
})
.catch(reject);
......@@ -215,7 +334,7 @@ export default {
userId: id,
size: -1,
})
.then(({ data }) => {
.then(({data}) => {
const result = data.data
.filter((i) => i.roleId + "")
.map((i) => i.roleId + "");
......@@ -260,6 +379,22 @@ export default {
data: {},
},
userPasswordDialog: {
// 是否显示弹出层
open: false,
// 弹出层标题
title: "修改密码",
data: {},
},
userLoginDialog: {
// 是否显示弹出层
open: false,
// 弹出层标题
title: "修改登录名",
data: {},
},
treeProps: {
children: "children",
label: "label",
......@@ -272,8 +407,8 @@ export default {
config: {
isshowTabPane: true,
columns: [
{ type: "selection", reserveSelection: true, width: 60 },
{ type: "index", label: "序号", align: "center", width: 50 },
{type: "selection", reserveSelection: true, width: 60},
{type: "index", label: "序号", align: "center", width: 50},
{
prop: "loginName",
label: "登录名称",
......@@ -295,6 +430,13 @@ export default {
formatter: this.formatter,
align: "center",
},
{
prop: "customerId",
label: "所属员工",
formatter: this.formatter,
align: "center",
},
{
prop: "roleIds",
label: "所属角色",
......@@ -317,13 +459,14 @@ export default {
},
{
label: "操作",
width: 280,
width: 320,
align: "center",
formatter: (row) => {
return (
<div>
<table-buttons
noView
noDel
row={row}
onEdit={this.toEdit}
onDel={this.toDel}
......@@ -352,10 +495,20 @@ export default {
size="mini"
type="text"
icon="el-icon-share"
onClick={() => this.distributeDept(row)}
onClick={() => this.updatePassword(row)}
>
修改密码
</el-button>
<span> </span>
<el-button
size="mini"
type="text"
icon="el-icon-share"
onClick={() => this.updateLoginName(row)}
>
修改登录名
</el-button>
</div>
);
},
......@@ -393,6 +546,7 @@ export default {
background-color: rgb(255, 255, 255);
color: rgb(64, 158, 255);
}
.el-tree--highlight-current
::v-deep
.el-tree-node.is-current
......@@ -400,17 +554,21 @@ export default {
background-color: rgb(255, 255, 255);
color: rgb(64, 158, 255);
}
.el-tree > .el-tree-node:after {
border-top: none;
}
.el-tree-node {
position: relative;
padding-left: 16px;
}
//节点有间隙,隐藏掉展开按钮就好了,如果觉得空隙没事可以删掉
.el-tree-node__expand-icon.is-leaf {
display: none;
}
.el-tree-node__children {
padding-left: 16px;
}
......
......@@ -10,8 +10,8 @@
<div class="content_box">
<div class="text_line">
<div class="text_box">
<span style="width: 160px;">门 (单位) 名称:</span>
<span>{{ form.ownerName || "--" }}</span>
<span style="width: 160px;">口 (单位) 名称:</span>
<span>{{ windowName || "--" }}</span>
</div>
<div class="text_box">
<span>登记年月:</span>
......@@ -301,6 +301,7 @@ export default {
},
data() {
return {
windowName: "",
// 遮罩层
loading: true,
// 弹出层标题
......@@ -324,6 +325,7 @@ export default {
},
/** 编辑 */
async edit(row) {
this.windowName = row.windowName;
// this.reset();
// this.query = { id: row.id };
this.urls.currUrl = "check/window/workman/perform/save";
......@@ -421,6 +423,7 @@ export default {
},
/** 查看*/
async view(row) {
this.windowName = row.windowName;
// this.reset();
// this.query = { id: row.id };
// this.urls.currUrl = "check/window/workman/perform/view";
......
module.exports = {
productionSourceMap: false,
/* assetsDir: 's',
configureWebpack: {
externals: {
vue: "Vue",
vuex: "Vuex",
"vue-router": "VueRouter",
"element-ui": "ELEMENT"
},
},*/
lintOnSave:false,
devServer: {
inline: true,
......
......@@ -204,6 +204,57 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
}
}
/**
* 修改用户登录名
*
* @param userEntity
* @return
* @throws Exception
*/
@RequestMapping("reLoginName")
public String reLoginName(@RequestBody UserEntity userEntity) throws Exception {
JSONObject ret = new JSONObject();
Long id = userEntity.getId();
String loginName = userEntity.getLoginName();
Integer userType = userEntity.getUserType();
if (ObjectUtils.isEmpty(userEntity.getId())) {
throw new AppException("修改的用户id不能为空");
}
if (ObjectUtils.isEmpty(loginName)) {
throw new AppException("修改的登录名不能问空!");
}
try {
//检测修改的用户名是否存在
UserEntity entity = userService.selectOne(new UserQuery().loginName(loginName));
if (!ObjectUtils.isEmpty(entity)) {
throw new AppException("修改的用户登录名已经存在!loginName=" + loginName);
}
if (SysConstains.ADMIN_ID == id)
throw new AppException("超级管理员不允许修改!");
if (userType == UserType.SYSTEM.getValue())
throw new AppException("系统用户不允许修改!");
userService.getUserDao().update(userEntity);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "修改用户登录名成功!");
recordSysLog(request, userEntity, "修改用户登录名成功!");
return ret.toJSONString();
} catch (AppException e) {
log.error("login error ", e);
ret.put(KEY_RESULT_CODE, e.getCode());
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
} catch (Exception e) {
log.error("系统异常 error ", e);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
@RequestMapping("logout")
public void logout(HttpServletRequest request, HttpServletResponse response) throws Exception {
......
......@@ -114,6 +114,12 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> {
*/
public boolean updateUserPwd(String loginName, String oldPwd, String newPwd) throws AppException;
/**
*
* @param entity
*/
void doHandlerUser(UserEntity entity);
UserDao getUserDao();
......
......@@ -46,6 +46,7 @@ import java.util.stream.Collectors;
* <p>Description: UserServiceImpl service接口 </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
*
* @author
* @version 1.0.0
*/
......@@ -65,10 +66,12 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Value("${sms.apiId:ADsUXLrS81vZDU95}")
private String appid;
/** 短信模板ID**/
/**
* 短信模板ID
**/
private static String SMS_TPYE = "30";
private static String SMS_VERIFY_CODE_KEY ="login:sms:verify:";
private static String SMS_VERIFY_CODE_KEY = "login:sms:verify:";
@Override
protected String getExtKey(UserEntity data) {
......@@ -76,8 +79,7 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
}
private void doHandlerUser(UserEntity entity) throws AppException {
public void doHandlerUser(UserEntity entity) throws AppException {
if (StringUtils.isNotEmpty(entity.getLoginPwd())) {
try {
entity.setLoginPwd(SecurityUtil.md5DoubleEncoding(entity.getLoginPwd()));
......@@ -101,9 +103,9 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override
protected void saveAfter(UserEntity entity, Context context) throws AppException {
if(CollectionUtils.isNotEmpty(entity.getRoleIds())){
if (CollectionUtils.isNotEmpty(entity.getRoleIds())) {
List<RoleUserEntity> roleUserEntityList = new ArrayList<>();
entity.getRoleIds().stream().forEach(item->{
entity.getRoleIds().stream().forEach(item -> {
RoleUserEntity roleUserEntity = new RoleUserEntity();
roleUserEntity.setUserId(entity.getId());
roleUserEntity.setRoleId(item);
......@@ -115,7 +117,10 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override
protected void updateBefore(UserEntity entity, Context context) throws AppException {
if (entity.getId().longValue() == SysConstains.ADMIN_ID && !context.getUser().isAdmin()) {
/* if (entity.getId().longValue() == SysConstains.ADMIN_ID && !context.getUser().isAdmin()) {
throw new AppException("你没有权限执行该操作");
}*/
if (entity.getId().longValue() == SysConstains.ADMIN_ID) {
throw new AppException("你没有权限执行该操作");
}
this.doHandlerUser(entity);
......@@ -123,9 +128,9 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override
protected void updateAfter(UserEntity entity, Context context) throws AppException {
if(CollectionUtils.isNotEmpty(entity.getRoleIds())){
if (CollectionUtils.isNotEmpty(entity.getRoleIds())) {
List<RoleUserEntity> roleUserEntityList = new ArrayList<>();
entity.getRoleIds().stream().forEach(item->{
entity.getRoleIds().stream().forEach(item -> {
RoleUserEntity roleUserEntity = new RoleUserEntity();
roleUserEntity.setUserId(entity.getId());
roleUserEntity.setRoleId(item);
......@@ -156,13 +161,13 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override
protected void findAfter(UserEntity params, PageInfo pageInfo, Context context, List<UserEntity> list) throws AppException {
if(CollectionUtils.isNotEmpty(list)) {
list.stream().forEach(item->{
if (CollectionUtils.isNotEmpty(list)) {
list.stream().forEach(item -> {
RoleUserEntity query = new RoleUserEntity();
query.setUserId(item.getId());
List<RoleUserEntity> roleUserEntityList = roleUserDao.getList(query);
List<Long> roleIds = new ArrayList<>();
roleUserEntityList.stream().forEach(role->{
roleUserEntityList.stream().forEach(role -> {
roleIds.add(role.getRoleId());
});
item.setRoleIds(roleIds);
......@@ -364,64 +369,64 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override
public void sendSmsVerifyCode(String mobileNumber) throws AppException {
if(StringUtils.isEmpty(mobileNumber)){
if (StringUtils.isEmpty(mobileNumber)) {
throw new AppException("手机号不能为空");
}
if(!PhoneUtil.isPhone(mobileNumber)){
if (!PhoneUtil.isPhone(mobileNumber)) {
throw new AppException("手机号码格式不正确");
}
UserEntity user = this.selectOne(new UserQuery().mobile(mobileNumber));
if(user==null){
if (user == null) {
throw new AppException("手机号码:" + mobileNumber + "没有注册用户");
}
String verifyCode = cacheService.get(SMS_VERIFY_CODE_KEY + mobileNumber);
if(StringUtils.isNotEmpty(verifyCode)){
if (StringUtils.isNotEmpty(verifyCode)) {
throw new AppException("当前手机号码已发送验证码,请稍后重试");
}
try {
Map<String, String> params = new HashMap<>();
params.put("appid",appid);
params.put("phone",mobileNumber);
params.put("type",SMS_TPYE);
params.put("appid", appid);
params.put("phone", mobileNumber);
params.put("type", SMS_TPYE);
String[] json = new String[2];
String vCode = RandomUtil.randomNumbers(6);
json[0] = vCode;
json[1] = "1";
params.put("json", JSONObject.toJSON(json).toString());
String resp = HttpUtil.doPost(smsApiUrl,params);
String resp = HttpUtil.doPost(smsApiUrl, params);
JSONObject respJson = JSONObject.parseObject(resp);
if(respJson.getIntValue("code")==0){
if (respJson.getIntValue("code") == 0) {
throw new AppException("短信发送失败:" + respJson.getString("message"));
}
//有效期60秒
cacheService.setnx(SMS_VERIFY_CODE_KEY+mobileNumber,vCode,60);
}catch (Exception e){
log.error("短信发送异常",e);
cacheService.setnx(SMS_VERIFY_CODE_KEY + mobileNumber, vCode, 60);
} catch (Exception e) {
log.error("短信发送异常", e);
throw new AppException("短信发送异常");
}
}
@Override
public UserEntity doSmsLogin(String mobileNumber, String verifyCode, String loginIp) throws AppException {
if(StringUtils.isEmpty(mobileNumber)){
if (StringUtils.isEmpty(mobileNumber)) {
throw new AppException("手机号不能为空");
}
if(StringUtils.isEmpty(verifyCode)){
if (StringUtils.isEmpty(verifyCode)) {
throw new AppException("验证码不能为空");
}
if(!PhoneUtil.isPhone(mobileNumber)){
if (!PhoneUtil.isPhone(mobileNumber)) {
throw new AppException("手机号码格式不正确");
}
UserEntity customer = this.selectOne(new UserQuery().mobile(mobileNumber));
if(customer==null){
if (customer == null) {
throw new AppException("手机号码:" + mobileNumber + "没有注册用户");
}
String vCode = cacheService.get(SMS_VERIFY_CODE_KEY + mobileNumber);
if(StringUtils.isEmpty(vCode)){
if (StringUtils.isEmpty(vCode)) {
throw new AppException("验证码已失效");
}
if(!verifyCode.equals(vCode)){
if (!verifyCode.equals(vCode)) {
throw new AppException("验证码不正确");
}
UserEntity update = new UserEntity();
......
......@@ -19,15 +19,13 @@ import com.mortals.xhx.common.code.UserStatus;
import com.mortals.xhx.common.code.UserType;
import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.staff.service.StaffService;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -54,6 +52,9 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
@Autowired
private DeptService deptService;
@Autowired
private StaffService staffService;
public UserController() {
super.setModuleDesc("用户信息");
}
......@@ -65,6 +66,8 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
this.addDict(model, "roleIds", roleService.find(new RoleQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getName())));
this.addDict(model, "deptId", deptService.find(new DeptQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getDeptName(), (o, n) -> n)));
this.addDict(model, "customerId", staffService.getCacheList().stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getName(), (o, n) -> n)));
}
@Override
......@@ -122,6 +125,31 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
}
@RequestMapping(value = "repassword", method = RequestMethod.POST)
public String rePassword(@RequestBody UserEntity userEntity) {
JSONObject ret = new JSONObject();
try {
//查询用户是否存在
boolean existUser = service.existUser(userEntity.getLoginName(), userEntity.getId());
if(!existUser) throw new AppException("用户不存在!");
//修改密码
//service.doHandlerUser(userEntity);
service.update(userEntity,getContext());
//更新密码
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "密码修改成功!");
} catch (Exception e) {
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
}
return ret.toJSONString();
}
public static void main(String[] args) {
String token = "eyJhbGciOiJIUzI1NiJ9.eyJsb2dpbl91c2VyX2tleSI6IjIzNGE5NDA5ZDVhOTQ3MWNhMzdkYjZkYmMwY2JjZTc5In0.MWyQW40HYDxyUz7PJRf_nRsFPWx3Hr811Ime984nixs";
......
......@@ -121,64 +121,6 @@ public class ApiLoginController extends BaseJsonBodyController {
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
/*
JSONObject ret = new JSONObject();
String loginName = loginForm.getLoginName();
String password = loginForm.getPassword();
String ip = super.getRequestIP(request);
if (StringUtils.isEmpty(loginName) || StringUtils.isEmpty(password)) {
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, "未获取到用户信息,请重新登录");
return ret.toJSONString();
}
UserEntity userEntity = null;
try {
loginForm.validate();
userEntity = userService.doLogin(loginName, password, ip);
userEntity.setLastLoginAddress(ip);
recordSysLog(request, userEntity, "H5用户登录系统成功!");
String currUserName = userEntity.getRealName();
if (currUserName == null || currUserName.trim().length() == 0) {
currUserName = "管理员";
}
JSONObject data = new JSONObject();
data.put("currUserName", currUserName);
data.put("id", userEntity.getId());
data.put("userType", userEntity.getUserType());
HashSet<Integer> set = new HashSet<>();
set.add(0);
set.add(2);
set.add(3);
if (ObjectUtils.isEmpty(userEntity.getUserType()) || !set.contains(userEntity.getUserType())) {
throw new AppException("当前用户不支持H5登录!");
}
userEntity.setLoginTime(System.currentTimeMillis());
userEntity.setToken(IdUtil.fastSimpleUUID());
userEntity.setExpireTime(DateUtils.addCurrDate(3).getTime());
String token = authTokenService.createToken(userEntity);
data.put("token", token);
if (!ObjectUtils.isEmpty(loginForm.getDingCode())) {
//更新绑定钉钉
userEntity.setDingUserId(loginForm.getDingCode());
userService.getUserDao().update(userEntity);
}
ret.put(KEY_RESULT_DATA, data);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "用户登录系统成功!");
return ret.toJSONString();
} catch (Exception e) {
log.error("h5 login error ", e);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);SyncDoorsEventTaskImpl
ret.put(KEY_RESULT_MSG, super.convertException(e));SyncDoorsEventTaskImpl
return ret.toJSONString();
}*/
}
@RequestMapping("logout")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment