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) { ...@@ -136,7 +136,6 @@ function handleTree(data, id, parentId, children, rootId) {
const treeData = cloneData.filter((father) => { const treeData = cloneData.filter((father) => {
let branchArr = cloneData.filter((child) => { let branchArr = cloneData.filter((child) => {
//返回每一项的子级数组 //返回每一项的子级数组
console.log(child[parentId]);
return father[id] === child[parentId]; return father[id] === child[parentId];
}); });
branchArr.length > 0 ? (father.children = branchArr) : ""; branchArr.length > 0 ? (father.children = branchArr) : "";
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
<div class="content_box"> <div class="content_box">
<div class="text_line"> <div class="text_line">
<div class="text_box"> <div class="text_box">
<span style="width: 160px;"> (单位) 名称:</span> <span style="width: 160px;"> (单位) 名称:</span>
<span>{{ form.ownerName || "--" }}</span> <span>{{ windowName || "--" }}</span>
</div> </div>
<div class="text_box"> <div class="text_box">
<span>登记年月:</span> <span>登记年月:</span>
...@@ -301,6 +301,7 @@ export default { ...@@ -301,6 +301,7 @@ export default {
}, },
data() { data() {
return { return {
windowName: "",
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 弹出层标题 // 弹出层标题
...@@ -324,6 +325,7 @@ export default { ...@@ -324,6 +325,7 @@ export default {
}, },
/** 编辑 */ /** 编辑 */
async edit(row) { async edit(row) {
this.windowName = row.windowName;
// this.reset(); // this.reset();
// this.query = { id: row.id }; // this.query = { id: row.id };
this.urls.saveUrl = "check/window/workman/perform/examine"; this.urls.saveUrl = "check/window/workman/perform/examine";
...@@ -429,14 +431,13 @@ export default { ...@@ -429,14 +431,13 @@ export default {
// this.getData(); // this.getData();
// this.pageInfo.type = "view"; // this.pageInfo.type = "view";
// this.title = "窗口人员考核汇总核查详细"; // this.title = "窗口人员考核汇总核查详细";
this.windowName = row.windowName;
this.form = row; this.form = row;
this.reset(); this.reset();
this.query = { id: row.id }; this.query = { id: row.id };
await this.$get("/window/workman/perform/info", { await this.$get("/window/workman/perform/info", {
id: row.recordId, id: row.recordId,
}).then((res) => { }).then((res) => {
console.log(res);
if (res.code == 1) { if (res.code == 1) {
this.form = res.data; this.form = res.data;
this.form.id = row.id; this.form.id = row.id;
......
...@@ -12,7 +12,10 @@ ...@@ -12,7 +12,10 @@
</div> </div>
</div> </div>
<div class="user-right"> <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 class="m">{{ form.month }}月得分</div>
</div> </div>
</div> </div>
...@@ -68,7 +71,7 @@ ...@@ -68,7 +71,7 @@
<Field label="评价绩效指标分数" prop="assessScore" v-model="form.assessScore" placeholder="请输入评价绩效指标分数" /> <Field label="评价绩效指标分数" prop="assessScore" v-model="form.assessScore" placeholder="请输入评价绩效指标分数" />
<Field label="办件绩效分数" prop="workScore" v-model="form.workScore" placeholder="请输入办件绩效分数" /> <Field label="办件绩效分数" prop="workScore" v-model="form.workScore" placeholder="请输入办件绩效分数" />
<Field label="效能绩效分数" prop="effectScore" v-model="form.effectScore" 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="errorScore" v-model="form.errorScore" placeholder="请输入累计异常分数" />
<Field label="当月得分数" prop="totalScore" v-model="form.totalScore" placeholder="请输入当月得分数" /> <Field label="当月得分数" prop="totalScore" v-model="form.totalScore" placeholder="请输入当月得分数" />
<Field label="备注" prop="remark" v-model="form.remark" type="textarea" placeholder="请输入备注" /> <Field label="备注" prop="remark" v-model="form.remark" type="textarea" placeholder="请输入备注" />
......
...@@ -141,7 +141,7 @@ export default { ...@@ -141,7 +141,7 @@ export default {
}, },
{ {
label: "其它绩效分数", label: "自评绩效分数",
prop: "otherScore", prop: "otherScore",
}, },
......
<template> <template>
<layout-view> <layout-view>
<el-descriptions :title="title" :column="column" :size="size" :colon="false" border> <el-descriptions
<template slot="title"> :title="title"
<i class="el-icon-tickets"></i> :column="column"
基本详细信息 :size="size"
</template> :colon="false"
<template slot="extra"> border
<el-button type="primary" @click="$router.go(-1)" size="small">返回</el-button> >
</template> <template slot="title">
<el-descriptions-item label="人员id" label-class-name="labelClass" content-class-name="contentClass"> <i class="el-icon-tickets"></i>
{{form.staffId}} 基本详细信息
</el-descriptions-item> </template>
<el-descriptions-item label="工号" label-class-name="labelClass" content-class-name="contentClass"> <template slot="extra">
{{form.workNum}} <el-button type="primary" @click="$router.go(-1)" size="small"
</el-descriptions-item> >返回</el-button
<el-descriptions-item label="人员名称" label-class-name="labelClass" content-class-name="contentClass"> >
{{form.staffName}} </template>
</el-descriptions-item> <el-descriptions-item
<el-descriptions-item label="部门id号" label-class-name="labelClass" content-class-name="contentClass"> label="人员id"
{{form.deptId}} label-class-name="labelClass"
</el-descriptions-item> content-class-name="contentClass"
<el-descriptions-item label="部门名称" label-class-name="labelClass" content-class-name="contentClass"> >
{{form.deptName}} {{ form.staffId }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="考勤绩效指标分数" label-class-name="labelClass" content-class-name="contentClass"> <el-descriptions-item
{{form.attendScore}} label="工号"
</el-descriptions-item> label-class-name="labelClass"
<el-descriptions-item label="评价绩效指标分数" label-class-name="labelClass" content-class-name="contentClass"> content-class-name="contentClass"
{{form.assessScore}} >
</el-descriptions-item> {{ form.workNum }}
<el-descriptions-item label="办件绩效分数" label-class-name="labelClass" content-class-name="contentClass"> </el-descriptions-item>
{{form.workScore}} <el-descriptions-item
</el-descriptions-item> label="人员名称"
<el-descriptions-item label="效能绩效分数" label-class-name="labelClass" content-class-name="contentClass"> label-class-name="labelClass"
{{form.effectScore}} content-class-name="contentClass"
</el-descriptions-item> >
<el-descriptions-item label="其它绩效分数" label-class-name="labelClass" content-class-name="contentClass"> {{ form.staffName }}
{{form.otherScore}} </el-descriptions-item>
</el-descriptions-item> <el-descriptions-item
<el-descriptions-item label="累计异常分数" label-class-name="labelClass" content-class-name="contentClass"> label="部门id号"
{{form.errorScore}} label-class-name="labelClass"
</el-descriptions-item> content-class-name="contentClass"
<el-descriptions-item label="当月得分数" label-class-name="labelClass" content-class-name="contentClass"> >
{{form.totalScore}} {{ form.deptId }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="备注" label-class-name="labelClass" content-class-name="contentClass"> <el-descriptions-item
{{form.remark}} label="部门名称"
</el-descriptions-item> label-class-name="labelClass"
<el-descriptions-item label="年" label-class-name="labelClass" content-class-name="contentClass"> content-class-name="contentClass"
{{form.year}} >
</el-descriptions-item> {{ form.deptName }}
<el-descriptions-item label="月" label-class-name="labelClass" content-class-name="contentClass"> </el-descriptions-item>
{{form.month}} <el-descriptions-item
</el-descriptions-item> label="考勤绩效指标分数"
</el-descriptions> label-class-name="labelClass"
content-class-name="contentClass"
</layout-view> >
{{ form.attendScore }}
</el-descriptions-item>
<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>
<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>
<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>
<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>
<el-descriptions-item
label="月"
label-class-name="labelClass"
content-class-name="contentClass"
>
{{ form.month }}
</el-descriptions-item>
</el-descriptions>
</layout-view>
</template> </template>
<script> <script>
import view from "@/assets/mixins/view"; import view from "@/assets/mixins/view";
export default { export default {
mixins: [view], mixins: [view],
components: { components: {},
}, methods: {},
methods: { data() {
return {
}, size: "small",
data() { column: 2,
return { toString: ["month"],
size:"small", toArrays: [],
column:2, toDate: [],
toString:[ };
"month", },
], };
toArrays: [
],
toDate: [
]
}
}
}
</script> </script>
<style lang="less"> <style lang="less">
.labelClass{ .labelClass {
width: 200px; width: 200px;
} }
.el-descriptions__body{ .el-descriptions__body {
margin-left: 5px; margin-left: 5px;
margin-right: 5px; margin-right: 5px;
color: #606266; color: #606266;
background-color: #FFF; background-color: #fff;
} }
.contentClass{ .contentClass {
width: 600px; width: 600px;
} }
</style> </style>
\ No newline at end of file
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
<div class="content_box"> <div class="content_box">
<div class="text_line"> <div class="text_line">
<div class="text_box"> <div class="text_box">
<span style="width: 160px;">门 (单位) 名称:</span> <span style="width: 160px;">口 (单位) 名称:</span>
<span>{{ form.ownerName || "--" }}</span> <span>{{ windowName || "--" }}</span>
</div> </div>
<div class="text_box"> <div class="text_box">
<span>登记年月:</span> <span>登记年月:</span>
...@@ -301,6 +301,7 @@ export default { ...@@ -301,6 +301,7 @@ export default {
}, },
data() { data() {
return { return {
windowName: "",
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 弹出层标题 // 弹出层标题
...@@ -324,6 +325,7 @@ export default { ...@@ -324,6 +325,7 @@ export default {
}, },
/** 编辑 */ /** 编辑 */
async edit(row) { async edit(row) {
this.windowName = row.windowName;
// this.reset(); // this.reset();
// this.query = { id: row.id }; // this.query = { id: row.id };
this.urls.currUrl = "check/window/workman/perform/save"; this.urls.currUrl = "check/window/workman/perform/save";
...@@ -421,6 +423,7 @@ export default { ...@@ -421,6 +423,7 @@ export default {
}, },
/** 查看*/ /** 查看*/
async view(row) { async view(row) {
this.windowName = row.windowName;
// this.reset(); // this.reset();
// this.query = { id: row.id }; // this.query = { id: row.id };
// this.urls.currUrl = "check/window/workman/perform/view"; // this.urls.currUrl = "check/window/workman/perform/view";
......
module.exports = { module.exports = {
productionSourceMap: false, productionSourceMap: false,
/* assetsDir: 's',
configureWebpack: {
externals: {
vue: "Vue",
vuex: "Vuex",
"vue-router": "VueRouter",
"element-ui": "ELEMENT"
},
},*/
lintOnSave:false, lintOnSave:false,
devServer: { devServer: {
inline: true, inline: true,
......
...@@ -204,6 +204,57 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi ...@@ -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") @RequestMapping("logout")
public void logout(HttpServletRequest request, HttpServletResponse response) throws Exception { public void logout(HttpServletRequest request, HttpServletResponse response) throws Exception {
......
...@@ -114,6 +114,12 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> { ...@@ -114,6 +114,12 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> {
*/ */
public boolean updateUserPwd(String loginName, String oldPwd, String newPwd) throws AppException; public boolean updateUserPwd(String loginName, String oldPwd, String newPwd) throws AppException;
/**
*
* @param entity
*/
void doHandlerUser(UserEntity entity);
UserDao getUserDao(); UserDao getUserDao();
......
...@@ -46,6 +46,7 @@ import java.util.stream.Collectors; ...@@ -46,6 +46,7 @@ import java.util.stream.Collectors;
* <p>Description: UserServiceImpl service接口 </p> * <p>Description: UserServiceImpl service接口 </p>
* <p>Copyright: Copyright &reg; </p> * <p>Copyright: Copyright &reg; </p>
* <p>Company: </p> * <p>Company: </p>
*
* @author * @author
* @version 1.0.0 * @version 1.0.0
*/ */
...@@ -65,10 +66,12 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -65,10 +66,12 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Value("${sms.apiId:ADsUXLrS81vZDU95}") @Value("${sms.apiId:ADsUXLrS81vZDU95}")
private String appid; private String appid;
/** 短信模板ID**/ /**
* 短信模板ID
**/
private static String SMS_TPYE = "30"; 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 @Override
protected String getExtKey(UserEntity data) { protected String getExtKey(UserEntity data) {
...@@ -76,8 +79,7 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -76,8 +79,7 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
} }
public void doHandlerUser(UserEntity entity) throws AppException {
private void doHandlerUser(UserEntity entity) throws AppException {
if (StringUtils.isNotEmpty(entity.getLoginPwd())) { if (StringUtils.isNotEmpty(entity.getLoginPwd())) {
try { try {
entity.setLoginPwd(SecurityUtil.md5DoubleEncoding(entity.getLoginPwd())); entity.setLoginPwd(SecurityUtil.md5DoubleEncoding(entity.getLoginPwd()));
...@@ -101,9 +103,9 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -101,9 +103,9 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override @Override
protected void saveAfter(UserEntity entity, Context context) throws AppException { protected void saveAfter(UserEntity entity, Context context) throws AppException {
if(CollectionUtils.isNotEmpty(entity.getRoleIds())){ if (CollectionUtils.isNotEmpty(entity.getRoleIds())) {
List<RoleUserEntity> roleUserEntityList = new ArrayList<>(); List<RoleUserEntity> roleUserEntityList = new ArrayList<>();
entity.getRoleIds().stream().forEach(item->{ entity.getRoleIds().stream().forEach(item -> {
RoleUserEntity roleUserEntity = new RoleUserEntity(); RoleUserEntity roleUserEntity = new RoleUserEntity();
roleUserEntity.setUserId(entity.getId()); roleUserEntity.setUserId(entity.getId());
roleUserEntity.setRoleId(item); roleUserEntity.setRoleId(item);
...@@ -115,7 +117,10 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -115,7 +117,10 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override @Override
protected void updateBefore(UserEntity entity, Context context) throws AppException { 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("你没有权限执行该操作"); throw new AppException("你没有权限执行该操作");
} }
this.doHandlerUser(entity); this.doHandlerUser(entity);
...@@ -123,9 +128,9 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -123,9 +128,9 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override @Override
protected void updateAfter(UserEntity entity, Context context) throws AppException { protected void updateAfter(UserEntity entity, Context context) throws AppException {
if(CollectionUtils.isNotEmpty(entity.getRoleIds())){ if (CollectionUtils.isNotEmpty(entity.getRoleIds())) {
List<RoleUserEntity> roleUserEntityList = new ArrayList<>(); List<RoleUserEntity> roleUserEntityList = new ArrayList<>();
entity.getRoleIds().stream().forEach(item->{ entity.getRoleIds().stream().forEach(item -> {
RoleUserEntity roleUserEntity = new RoleUserEntity(); RoleUserEntity roleUserEntity = new RoleUserEntity();
roleUserEntity.setUserId(entity.getId()); roleUserEntity.setUserId(entity.getId());
roleUserEntity.setRoleId(item); roleUserEntity.setRoleId(item);
...@@ -156,13 +161,13 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -156,13 +161,13 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override @Override
protected void findAfter(UserEntity params, PageInfo pageInfo, Context context, List<UserEntity> list) throws AppException { protected void findAfter(UserEntity params, PageInfo pageInfo, Context context, List<UserEntity> list) throws AppException {
if(CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
list.stream().forEach(item->{ list.stream().forEach(item -> {
RoleUserEntity query = new RoleUserEntity(); RoleUserEntity query = new RoleUserEntity();
query.setUserId(item.getId()); query.setUserId(item.getId());
List<RoleUserEntity> roleUserEntityList = roleUserDao.getList(query); List<RoleUserEntity> roleUserEntityList = roleUserDao.getList(query);
List<Long> roleIds = new ArrayList<>(); List<Long> roleIds = new ArrayList<>();
roleUserEntityList.stream().forEach(role->{ roleUserEntityList.stream().forEach(role -> {
roleIds.add(role.getRoleId()); roleIds.add(role.getRoleId());
}); });
item.setRoleIds(roleIds); item.setRoleIds(roleIds);
...@@ -364,64 +369,64 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -364,64 +369,64 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override @Override
public void sendSmsVerifyCode(String mobileNumber) throws AppException { public void sendSmsVerifyCode(String mobileNumber) throws AppException {
if(StringUtils.isEmpty(mobileNumber)){ if (StringUtils.isEmpty(mobileNumber)) {
throw new AppException("手机号不能为空"); throw new AppException("手机号不能为空");
} }
if(!PhoneUtil.isPhone(mobileNumber)){ if (!PhoneUtil.isPhone(mobileNumber)) {
throw new AppException("手机号码格式不正确"); throw new AppException("手机号码格式不正确");
} }
UserEntity user = this.selectOne(new UserQuery().mobile(mobileNumber)); UserEntity user = this.selectOne(new UserQuery().mobile(mobileNumber));
if(user==null){ if (user == null) {
throw new AppException("手机号码:" + mobileNumber + "没有注册用户"); throw new AppException("手机号码:" + mobileNumber + "没有注册用户");
} }
String verifyCode = cacheService.get(SMS_VERIFY_CODE_KEY + mobileNumber); String verifyCode = cacheService.get(SMS_VERIFY_CODE_KEY + mobileNumber);
if(StringUtils.isNotEmpty(verifyCode)){ if (StringUtils.isNotEmpty(verifyCode)) {
throw new AppException("当前手机号码已发送验证码,请稍后重试"); throw new AppException("当前手机号码已发送验证码,请稍后重试");
} }
try { try {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put("appid",appid); params.put("appid", appid);
params.put("phone",mobileNumber); params.put("phone", mobileNumber);
params.put("type",SMS_TPYE); params.put("type", SMS_TPYE);
String[] json = new String[2]; String[] json = new String[2];
String vCode = RandomUtil.randomNumbers(6); String vCode = RandomUtil.randomNumbers(6);
json[0] = vCode; json[0] = vCode;
json[1] = "1"; json[1] = "1";
params.put("json", JSONObject.toJSON(json).toString()); params.put("json", JSONObject.toJSON(json).toString());
String resp = HttpUtil.doPost(smsApiUrl,params); String resp = HttpUtil.doPost(smsApiUrl, params);
JSONObject respJson = JSONObject.parseObject(resp); JSONObject respJson = JSONObject.parseObject(resp);
if(respJson.getIntValue("code")==0){ if (respJson.getIntValue("code") == 0) {
throw new AppException("短信发送失败:" + respJson.getString("message")); throw new AppException("短信发送失败:" + respJson.getString("message"));
} }
//有效期60秒 //有效期60秒
cacheService.setnx(SMS_VERIFY_CODE_KEY+mobileNumber,vCode,60); cacheService.setnx(SMS_VERIFY_CODE_KEY + mobileNumber, vCode, 60);
}catch (Exception e){ } catch (Exception e) {
log.error("短信发送异常",e); log.error("短信发送异常", e);
throw new AppException("短信发送异常"); throw new AppException("短信发送异常");
} }
} }
@Override @Override
public UserEntity doSmsLogin(String mobileNumber, String verifyCode, String loginIp) throws AppException { public UserEntity doSmsLogin(String mobileNumber, String verifyCode, String loginIp) throws AppException {
if(StringUtils.isEmpty(mobileNumber)){ if (StringUtils.isEmpty(mobileNumber)) {
throw new AppException("手机号不能为空"); throw new AppException("手机号不能为空");
} }
if(StringUtils.isEmpty(verifyCode)){ if (StringUtils.isEmpty(verifyCode)) {
throw new AppException("验证码不能为空"); throw new AppException("验证码不能为空");
} }
if(!PhoneUtil.isPhone(mobileNumber)){ if (!PhoneUtil.isPhone(mobileNumber)) {
throw new AppException("手机号码格式不正确"); throw new AppException("手机号码格式不正确");
} }
UserEntity customer = this.selectOne(new UserQuery().mobile(mobileNumber)); UserEntity customer = this.selectOne(new UserQuery().mobile(mobileNumber));
if(customer==null){ if (customer == null) {
throw new AppException("手机号码:" + mobileNumber + "没有注册用户"); throw new AppException("手机号码:" + mobileNumber + "没有注册用户");
} }
String vCode = cacheService.get(SMS_VERIFY_CODE_KEY + mobileNumber); String vCode = cacheService.get(SMS_VERIFY_CODE_KEY + mobileNumber);
if(StringUtils.isEmpty(vCode)){ if (StringUtils.isEmpty(vCode)) {
throw new AppException("验证码已失效"); throw new AppException("验证码已失效");
} }
if(!verifyCode.equals(vCode)){ if (!verifyCode.equals(vCode)) {
throw new AppException("验证码不正确"); throw new AppException("验证码不正确");
} }
UserEntity update = new UserEntity(); UserEntity update = new UserEntity();
......
...@@ -19,15 +19,13 @@ import com.mortals.xhx.common.code.UserStatus; ...@@ -19,15 +19,13 @@ import com.mortals.xhx.common.code.UserStatus;
import com.mortals.xhx.common.code.UserType; import com.mortals.xhx.common.code.UserType;
import com.mortals.xhx.module.dept.model.DeptQuery; import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService; import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.staff.service.StaffService;
import io.jsonwebtoken.Claims; import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts; import io.jsonwebtoken.Jwts;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -54,6 +52,9 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic ...@@ -54,6 +52,9 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
@Autowired @Autowired
private DeptService deptService; private DeptService deptService;
@Autowired
private StaffService staffService;
public UserController() { public UserController() {
super.setModuleDesc("用户信息"); super.setModuleDesc("用户信息");
} }
...@@ -65,6 +66,8 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic ...@@ -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, "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, "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 @Override
...@@ -122,6 +125,31 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic ...@@ -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) { public static void main(String[] args) {
String token = "eyJhbGciOiJIUzI1NiJ9.eyJsb2dpbl91c2VyX2tleSI6IjIzNGE5NDA5ZDVhOTQ3MWNhMzdkYjZkYmMwY2JjZTc5In0.MWyQW40HYDxyUz7PJRf_nRsFPWx3Hr811Ime984nixs"; String token = "eyJhbGciOiJIUzI1NiJ9.eyJsb2dpbl91c2VyX2tleSI6IjIzNGE5NDA5ZDVhOTQ3MWNhMzdkYjZkYmMwY2JjZTc5In0.MWyQW40HYDxyUz7PJRf_nRsFPWx3Hr811Ime984nixs";
......
...@@ -121,64 +121,6 @@ public class ApiLoginController extends BaseJsonBodyController { ...@@ -121,64 +121,6 @@ public class ApiLoginController extends BaseJsonBodyController {
ret.put(KEY_RESULT_MSG, super.convertException(e)); ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString(); 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") @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