Commit dac969ef authored by liuchao's avatar liuchao

no message

parent 12a10d95
......@@ -53,10 +53,72 @@ public class UserController extends BaseController<Object>{
@RequestMapping("/user/add")
public ModelAndView index() throws Exception {
public ModelAndView userAdd(String id) throws Exception {
ModelAndView view = new ModelAndView();
UserVo vo = new UserVo();
if(StringUtils.isNotBlank(id)) {
User user = userService.findById(id);
vo.setId(user.getId());
vo.setUserName(user.getMobile());
vo.setUserCode(user.getUserCode());
vo.setName(user.getName());
vo.setGender(user.getGender());
vo.setBirthday(user.getBirthday());
vo.setPaperType(user.getPaperType());
vo.setPaperId(user.getPaperId());
vo.setNation(user.getNation());
vo.setNativePlace(user.getNativePlace());
vo.setNationality(user.getNationality());
vo.setEducation(user.getEducation());
vo.setDomicilePlace(user.getDomicilePlace());
vo.setAddr(user.getAddr());
vo.setUnit(user.getUnit());
vo.setUnitAddr(user.getUnitAddr());
vo.setUnitTel(user.getUnitTel());
vo.setProfession(user.getProfession());
vo.setMobile(user.getMobile());
vo.setEmail(user.getEmail());
vo.setTel(user.getTel());
vo.setQq(user.getQq());
vo.setWeixin(user.getWeixin());
vo.setDonateBloodCount(user.getDonateBloodCount());
vo.setBloodType(user.getBloodType());
vo.setHeight(user.getHeight());
vo.setWeight(user.getWeight());
vo.setRemark(user.getRemark());
vo.setRole(user.getRole());
Set<Contacts> contacts = user.getContacts();
Iterator<Contacts> its = contacts.iterator();
Integer count = 0;
while (its.hasNext()) {
Contacts c = its.next();
if (count == 0) {
vo.setContactsAddr1(c.getAddr());
vo.setContactsName1(c.getName());
vo.setContactsMobile1(c.getMobile());
vo.setContactsRelation1(c.getRelation());
vo.setContactsWeixin1(c.getWeixin());
vo.setContactsQQ1(c.getQq());
count ++;
} else {
vo.setContactsAddr2(c.getAddr());
vo.setContactsName2(c.getName());
vo.setContactsMobile2(c.getMobile());
vo.setContactsRelation2(c.getRelation());
vo.setContactsWeixin2(c.getWeixin());
vo.setContactsQQ2(c.getQq());
}
}
}
view.setViewName("user/saveuser");
view.getModel().put("dict", dict());
view.getModel().put("user", vo);
return view;
}
......@@ -67,6 +129,54 @@ public class UserController extends BaseController<Object>{
ModelAndView view = new ModelAndView();
User user = new User();
Date date = new Date();
if (StringUtils.isEmpty(userVo.getId())) {
Boolean userIsExistPaperId = userService.validateUserExistByPaperId(userVo.getPaperId());
if (userIsExistPaperId) {
view.getModelMap().put("status", 0);
view.getModel().put("message", "userIsExist_paperId");
return view;
}
Boolean userIsExistUserName = userService.validateUserExistByUserName(userVo.getUserName());
if (userIsExistUserName) {
view.getModelMap().put("status", 0);
view.getModel().put("message", "userIsExist_userName");
return view;
}
user.setCreateTime(date);
user.setStatus("0");
view.getModelMap().put("status", 1);
} else {
user = userService.findById(userVo.getId());
if (StringUtils.isNotBlank(userVo.getPaperId()) && !userVo.getPaperId().equals(user.getPaperId())) {
Boolean userIsExistPaperId = userService.validateUserExistByPaperId(userVo.getPaperId());
if (userIsExistPaperId) {
view.getModelMap().put("status", 0);
view.getModel().put("message", "userIsExist_paperId");
return view;
}
}
if (StringUtils.isNotBlank(userVo.getUserName()) && !userVo.getUserName().equals(user.getUserName())) {
Boolean userIsExistUserName = userService.validateUserExistByUserName(userVo.getUserName());
if (userIsExistUserName) {
view.getModelMap().put("status", 0);
view.getModel().put("message", "userIsExist_userName");
return view;
}
}
user.setUpdateTime(date);
user.getContacts().clear();
view.getModelMap().put("status", 2);
}
user.setUserName(userVo.getMobile());
user.setName(userVo.getName());
......@@ -95,32 +205,6 @@ public class UserController extends BaseController<Object>{
user.setWeight(userVo.getWeight());
user.setRemark(userVo.getRemark());
user.setRole(userVo.getRole());
user.setStatus(userVo.getStatus());
if (StringUtils.isEmpty(userVo.getId())) {
Boolean userIsExistPaperId = userService.validateUserExistByPaperId(userVo.getPaperId());
if (userIsExistPaperId) {
view.getModel().put("message", "userIsExist_paperId");
return view;
}
Boolean userIsExistUserName = userService.validateUserExistByUserName(userVo.getUserName());
if (userIsExistUserName) {
view.getModel().put("message", "userIsExist_teamName");
return view;
}
Date date = new Date();
user.setCreateTime(date);
Contacts contacts1 = new Contacts();
contacts1.setName(userVo.getContactsName1());
......@@ -144,34 +228,6 @@ public class UserController extends BaseController<Object>{
contacts2.setUser(user);
user.getContacts().add(contacts2);
view.getModelMap().put("status", 1);
} else {
if(userVo.getChangePassword()!=null&&userVo.getChangePassword()){
Boolean validatePwd = userService.validatePwd(userVo.getId(), userVo.getOldpwd());
if (!validatePwd) {
view.getModel().put("message", "oldPwdError");
return view;
}
}
user = userService.findById(userVo.getId());
if (StringUtils.isNotBlank(userVo.getUserName())) {
Boolean userIsExistUserName = userService.validateUserExistByUserName(userVo.getUserName());
if (userIsExistUserName) {
view.getModel().put("message", "userIsExist_teamName");
return view;
}
}
if(userVo.getChangePassword()!=null && userVo.getChangePassword()){
user.setPwd(MD5.digest(userVo.getPwd()));
}
user.setEmail(userVo.getEmail());
}
userService.save(user);
return view;
}
......
......@@ -30,7 +30,7 @@ public class BaseController<Entity> extends MultiActionController {
@Autowired
protected ApplicationContext ctx;
private Integer DEFAULT_COUNT = 40;
private Integer DEFAULT_COUNT = 20;
/**
* 获取国际化.
......
......@@ -68,6 +68,7 @@ public class User {
private String status; //状态 0.未采血 1.已采血
private Date createTime = new Date();
private Date updateTime = new Date();
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL}, orphanRemoval = true, mappedBy = "user")
@JsonIgnore
......@@ -323,6 +324,12 @@ public class User {
public void setUserName(String userName) {
this.userName = userName;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
......
......@@ -6,6 +6,7 @@ public class UserVo {
private String id;
private String userCode;
private String userName; //用户名
private String name; //姓名
private String gender; //性别
......@@ -351,6 +352,12 @@ public class UserVo {
public void setContactsAddr2(String contactsAddr2) {
this.contactsAddr2 = contactsAddr2;
}
public String getUserCode() {
return userCode;
}
public void setUserCode(String userCode) {
this.userCode = userCode;
}
......
......@@ -49,9 +49,10 @@
</div>
</div>
<table id="sample-table-1" class="table table-striped table-bordered table-hover">
<div class="pull-left">共${userPage.recordTotal}条</div>
<table id="table-data" class="table table-bordered ">
<thead>
<tr>
<tr class="">
<th class="center">
<label>
<input type="checkbox" class="ace">
......@@ -78,8 +79,8 @@
<tbody>
<tr>
<c:forEach var="user" items="${userPage.records}">
<tr class="tr-highlight">
<td class="center" width=10>
<label>
<input type="checkbox" class="ace">
......@@ -87,26 +88,38 @@
</label>
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td title="${user.name}">${user.name} </td>
<td title="${user.gender}">${user.gender}</td>
<td title="${user.birthday}">${user.birthday} </td>
<td title="${user.nativePlace}">${user.nativePlace} </td>
<td title="${user.paperType}">${user.paperType} </td>
<td title="${user.paperId}">${user.paperId} </td>
<td title="${user.mobile}">${user.mobile} </td>
<td >
<c:if test="${user.role==1}">
管理员
</c:if>
<c:if test="${user.role==2}">
普通用户
</c:if>
</td>
<td title="${user.createTime}">${user.createTime} </td>
<td>
<c:if test="${user.status==0 || user.status==null}">
<span class="label label-sm label-warning">未采血</span>
</c:if>
<c:if test="${user.status==1}">
<span class="label label-sm label-success">已采血</span>
</c:if>
</td>
<td>
<div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
<button class="btn btn-xs btn-info">
<button class="btn btn-xs btn-info" onclick="window.location.href='<webpath:path/>/user/add?id=${user.id}'">
<i class="icon-edit bigger-120"></i>
</button>
&nbsp;
......@@ -121,7 +134,7 @@
</td>
</tr>
</c:forEach>
......@@ -134,7 +147,11 @@
<webpage:page totalCount="${userPage.recordTotal}"
pageCount="${pageCount}" currentPage="${pageNumber}"
action="/user/list"
className="pageable-div pagination"
innerStyle=" float: left; width: 100%" />
</div>
</div>
......
......@@ -1068,7 +1068,14 @@ input.error{
}
.table thead > tr > th, .table tbody > tr > th, .table tfoot > tr > th, .table thead > tr > td, .table tbody > tr > td, .table tfoot > tr > td {
padding-left:3px;
padding-right:3px;
}
.table thead > tr.tr-highlight:hover, .table tbody > tr.tr-highlight:hover{
background: rgba(173, 216, 230, 1);
}
......
......@@ -139,7 +139,9 @@ var user = {
url: '/api/user/save',
dataType:'json',
data: {
id:$('#id').val(),
role:$('#role').val(),
userName:$('#mobile').val(),
name:$('#name').val(),
gender:$('input:radio[name="gender"]:checked').val(),
birthday:$('#birthday').val(),
......@@ -185,23 +187,64 @@ var user = {
bootbox.dialog({
message:"新增用户成功",
buttons:{
"success":{
"cancel":{
"label":"返回",
"className":"btn-sm btn-primary",
"callback": function () {
window.location.href='<webpath:path/>/';
window.location.href = webPath + '/user/list';
}
},
"success":{
"label":"继续添加",
"className":"btn-sm btn-primary",
"callback": function () {
window.location.href='<webpath:path/>/';
window.location.href = webPath + '/user/add';
}
}
}
});
} else if (status == 0){
isSubmit = true;
var message=data.message;
if(message=="userIsExist_userName"){
bootbox.dialog({
message:"手机号已存在,新增失败!",
buttons:{
"success":{
"label":"OK",
"className":"btn-sm btn-primary"
}
}
});
}else if(message=="userIsExist_paperId"){
bootbox.dialog({
message:"证件号已存在,添加失败!",
buttons:{
"success":{
"label":"OK",
"className":"btn-sm btn-primary"
}
}
});
}
} else if (status == 2){
isSubmit = true;
bootbox.dialog({
message:"修改用户成功",
buttons:{
"success":{
"label":"确定",
"className":"btn-sm btn-primary",
"callback": function () {
}
}
}
});
}
......
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