创建用户,不允许相同帐号,且不允许修改帐号
This commit is contained in:
parent
ea9afdb02b
commit
0b16ae4d4b
|
@ -10,5 +10,6 @@ import com.zheng.upms.dao.model.UpmsUserExample;
|
|||
*/
|
||||
public interface UpmsUserService extends BaseService<UpmsUser, UpmsUserExample> {
|
||||
|
||||
UpmsUser insert2(UpmsUser upmsUser);
|
||||
UpmsUser createUser(UpmsUser upmsUser);
|
||||
|
||||
}
|
|
@ -12,7 +12,8 @@ import com.zheng.upms.dao.model.UpmsUserExample;
|
|||
public class UpmsUserServiceMock extends BaseServiceMock<UpmsUserMapper, UpmsUser, UpmsUserExample> implements UpmsUserService {
|
||||
|
||||
@Override
|
||||
public UpmsUser insert2(UpmsUser upmsUser) {
|
||||
public UpmsUser createUser(UpmsUser upmsUser) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,8 +27,16 @@ public class UpmsUserServiceImpl extends BaseServiceImpl<UpmsUserMapper, UpmsUse
|
|||
UpmsUserMapper upmsUserMapper;
|
||||
|
||||
@Override
|
||||
public UpmsUser insert2(UpmsUser upmsUser) {
|
||||
public UpmsUser createUser(UpmsUser upmsUser) {
|
||||
UpmsUserExample upmsUserExample = new UpmsUserExample();
|
||||
upmsUserExample.createCriteria()
|
||||
.andUsernameEqualTo(upmsUser.getUsername());
|
||||
long count = upmsUserMapper.countByExample(upmsUserExample);
|
||||
if (count > 0) {
|
||||
return null;
|
||||
}
|
||||
upmsUserMapper.insert(upmsUser);
|
||||
return upmsUser;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package com.zheng.upms.server.controller.manage;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baidu.unbiz.fluentvalidator.ComplexResult;
|
||||
import com.baidu.unbiz.fluentvalidator.FluentValidator;
|
||||
import com.baidu.unbiz.fluentvalidator.ResultCollectors;
|
||||
|
@ -16,7 +15,6 @@ import com.zheng.upms.rpc.api.*;
|
|||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -26,7 +24,10 @@ import org.springframework.ui.ModelMap;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 用户controller
|
||||
|
@ -189,10 +190,12 @@ public class UpmsUserController extends BaseController {
|
|||
upmsUser.setSalt(salt);
|
||||
upmsUser.setPassword(MD5Util.MD5(upmsUser.getPassword() + upmsUser.getSalt()));
|
||||
upmsUser.setCtime(time);
|
||||
int count = upmsUserService.insertSelective(upmsUser);
|
||||
//upmsUser = upmsUserService.insert2(upmsUser);
|
||||
//_log.info("新增用户,主键:userId={}", upmsUser.getUserId());
|
||||
return new UpmsResult(UpmsResultConstant.SUCCESS, count);
|
||||
upmsUser = upmsUserService.createUser(upmsUser);
|
||||
if (null == upmsUser) {
|
||||
return new UpmsResult(UpmsResultConstant.FAILED, "帐号名已存在!");
|
||||
}
|
||||
_log.info("新增用户,主键:userId={}", upmsUser.getUserId());
|
||||
return new UpmsResult(UpmsResultConstant.SUCCESS, 1);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除用户")
|
||||
|
|
|
@ -96,7 +96,7 @@ function createSubmit() {
|
|||
animation: 'rotateX',
|
||||
closeAnimation: 'rotateX',
|
||||
title: false,
|
||||
content: result.data.errorMsg,
|
||||
content: result.data.errorMsg || result.data,
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: '确认',
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<form id="updateForm" method="post">
|
||||
<div class="form-group">
|
||||
<label for="username">帐号</label>
|
||||
<input id="username" type="text" class="form-control" name="username" maxlength="20" value="${user.username}">
|
||||
<input id="username" type="text" class="form-control" name="username" maxlength="20" value="${user.username}" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="realname">姓名</label>
|
||||
|
|
Loading…
Reference in New Issue