Commit dac969ef authored by liuchao's avatar liuchao

no message

parent 12a10d95
...@@ -53,10 +53,72 @@ public class UserController extends BaseController<Object>{ ...@@ -53,10 +53,72 @@ public class UserController extends BaseController<Object>{
@RequestMapping("/user/add") @RequestMapping("/user/add")
public ModelAndView index() throws Exception { public ModelAndView userAdd(String id) throws Exception {
ModelAndView view = new ModelAndView(); 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.setViewName("user/saveuser");
view.getModel().put("dict", dict()); view.getModel().put("dict", dict());
view.getModel().put("user", vo);
return view; return view;
} }
...@@ -65,8 +127,56 @@ public class UserController extends BaseController<Object>{ ...@@ -65,8 +127,56 @@ public class UserController extends BaseController<Object>{
public ModelAndView saveUser(UserVo userVo, HttpServletResponse response, HttpServletRequest request) throws Exception { public ModelAndView saveUser(UserVo userVo, HttpServletResponse response, HttpServletRequest request) throws Exception {
ModelAndView view = new ModelAndView(); 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 user = new User(); 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.setUserName(userVo.getMobile());
user.setName(userVo.getName()); user.setName(userVo.getName());
...@@ -95,83 +205,29 @@ public class UserController extends BaseController<Object>{ ...@@ -95,83 +205,29 @@ public class UserController extends BaseController<Object>{
user.setWeight(userVo.getWeight()); user.setWeight(userVo.getWeight());
user.setRemark(userVo.getRemark()); user.setRemark(userVo.getRemark());
user.setRole(userVo.getRole()); user.setRole(userVo.getRole());
user.setStatus(userVo.getStatus());
Contacts contacts1 = new Contacts();
contacts1.setName(userVo.getContactsName1());
contacts1.setAddr(userVo.getContactsAddr1());
contacts1.setMobile(userVo.getContactsMobile1());
contacts1.setRelation(userVo.getContactsRelation1());
contacts1.setWeixin(userVo.getContactsWeixin1());
contacts1.setQq(userVo.getContactsQQ1());
contacts1.setUpdateTime(date);
contacts1.setUser(user);
user.getContacts().add(contacts1);
Contacts contacts2 = new Contacts();
contacts2.setName(userVo.getContactsName2());
contacts2.setAddr(userVo.getContactsAddr2());
contacts2.setMobile(userVo.getContactsMobile2());
contacts2.setRelation(userVo.getContactsRelation2());
contacts2.setWeixin(userVo.getContactsWeixin2());
if (StringUtils.isEmpty(userVo.getId())) { contacts2.setQq(userVo.getContactsQQ2());
contacts2.setUpdateTime(date);
Boolean userIsExistPaperId = userService.validateUserExistByPaperId(userVo.getPaperId()); contacts2.setUser(user);
if (userIsExistPaperId) { user.getContacts().add(contacts2);
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());
contacts1.setAddr(userVo.getContactsAddr1());
contacts1.setMobile(userVo.getContactsMobile1());
contacts1.setRelation(userVo.getContactsRelation1());
contacts1.setWeixin(userVo.getContactsWeixin1());
contacts1.setQq(userVo.getContactsQQ1());
contacts1.setUpdateTime(date);
contacts1.setUser(user);
user.getContacts().add(contacts1);
Contacts contacts2 = new Contacts();
contacts2.setName(userVo.getContactsName2());
contacts2.setAddr(userVo.getContactsAddr2());
contacts2.setMobile(userVo.getContactsMobile2());
contacts2.setRelation(userVo.getContactsRelation2());
contacts2.setWeixin(userVo.getContactsWeixin2());
contacts2.setQq(userVo.getContactsQQ2());
contacts2.setUpdateTime(date);
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); userService.save(user);
return view; return view;
} }
......
...@@ -30,7 +30,7 @@ public class BaseController<Entity> extends MultiActionController { ...@@ -30,7 +30,7 @@ public class BaseController<Entity> extends MultiActionController {
@Autowired @Autowired
protected ApplicationContext ctx; protected ApplicationContext ctx;
private Integer DEFAULT_COUNT = 40; private Integer DEFAULT_COUNT = 20;
/** /**
* 获取国际化. * 获取国际化.
......
...@@ -68,6 +68,7 @@ public class User { ...@@ -68,6 +68,7 @@ public class User {
private String status; //状态 0.未采血 1.已采血 private String status; //状态 0.未采血 1.已采血
private Date createTime = new Date(); private Date createTime = new Date();
private Date updateTime = new Date();
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL}, orphanRemoval = true, mappedBy = "user") @OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL}, orphanRemoval = true, mappedBy = "user")
@JsonIgnore @JsonIgnore
...@@ -323,6 +324,12 @@ public class User { ...@@ -323,6 +324,12 @@ public class User {
public void setUserName(String userName) { public void setUserName(String userName) {
this.userName = userName; this.userName = userName;
} }
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
......
...@@ -6,6 +6,7 @@ public class UserVo { ...@@ -6,6 +6,7 @@ public class UserVo {
private String id; private String id;
private String userCode;
private String userName; //用户名 private String userName; //用户名
private String name; //姓名 private String name; //姓名
private String gender; //性别 private String gender; //性别
...@@ -351,6 +352,12 @@ public class UserVo { ...@@ -351,6 +352,12 @@ public class UserVo {
public void setContactsAddr2(String contactsAddr2) { public void setContactsAddr2(String contactsAddr2) {
this.contactsAddr2 = contactsAddr2; this.contactsAddr2 = contactsAddr2;
} }
public String getUserCode() {
return userCode;
}
public void setUserCode(String userCode) {
this.userCode = userCode;
}
......
...@@ -49,92 +49,109 @@ ...@@ -49,92 +49,109 @@
</div> </div>
</div> </div>
<table id="sample-table-1" class="table table-striped table-bordered table-hover"> <div class="pull-left">共${userPage.recordTotal}条</div>
<thead> <table id="table-data" class="table table-bordered ">
<tr> <thead>
<th class="center"> <tr class="">
<label> <th class="center">
<input type="checkbox" class="ace"> <label>
<span class="lbl"></span> <input type="checkbox" class="ace">
</label> <span class="lbl"></span>
</th> </label>
<th>姓名</th> </th>
<th>性别</th> <th>姓名</th>
<th>出生年月</th> <th>性别</th>
<th>出生年月</th>
<th>籍贯</th>
<th>证件</th>
<th>证件号</th>
<th>手机号</th>
<th>角色</th>
<th><i class="icon-time bigger-110 hidden-480"></i>注册时间</th>
<th class="hidden-480">状态</th>
<th width="100">操作</th>
</tr>
</thead>
<tbody>
<tr>
<td class="center" width=10>
<label>
<input type="checkbox" class="ace">
<span class="lbl"></span>
</label>
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>
<span class="label label-sm label-warning">未采血</span>
</td>
<td>
<div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
<button class="btn btn-xs btn-info">
<i class="icon-edit bigger-120"></i>
</button>
&nbsp;
<button class="btn btn-xs btn-danger">
<i class="icon-trash bigger-120"></i> <th>籍贯</th>
</button> <th>证件</th>
<th>证件号</th>
<th>手机号</th>
</div> <th>角色</th>
<th><i class="icon-time bigger-110 hidden-480"></i>注册时间</th>
</td> <th class="hidden-480">状态</th>
</tr>
<th width="100">操作</th>
</tr>
</thead>
<tbody>
<c:forEach var="user" items="${userPage.records}">
<tr class="tr-highlight">
</tbody> <td class="center" width=10>
</table> <label>
<input type="checkbox" class="ace">
<span class="lbl"></span>
</label>
</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" onclick="window.location.href='<webpath:path/>/user/add?id=${user.id}'">
<i class="icon-edit bigger-120"></i>
</button>
&nbsp;
<button class="btn btn-xs btn-danger">
<i class="icon-trash bigger-120"></i>
</button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<webpage:page totalCount="${userPage.recordTotal}"
pageCount="${pageCount}" currentPage="${pageNumber}"
action="/user/list"
className="pageable-div pagination"
innerStyle=" float: left; width: 100%" />
</div> </div>
</div> </div>
......
...@@ -1068,7 +1068,14 @@ input.error{ ...@@ -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 = { ...@@ -139,7 +139,9 @@ var user = {
url: '/api/user/save', url: '/api/user/save',
dataType:'json', dataType:'json',
data: { data: {
id:$('#id').val(),
role:$('#role').val(), role:$('#role').val(),
userName:$('#mobile').val(),
name:$('#name').val(), name:$('#name').val(),
gender:$('input:radio[name="gender"]:checked').val(), gender:$('input:radio[name="gender"]:checked').val(),
birthday:$('#birthday').val(), birthday:$('#birthday').val(),
...@@ -185,24 +187,65 @@ var user = { ...@@ -185,24 +187,65 @@ var user = {
bootbox.dialog({ bootbox.dialog({
message:"新增用户成功", message:"新增用户成功",
buttons:{ buttons:{
"success":{ "cancel":{
"label":"返回", "label":"返回",
"className":"btn-sm btn-primary", "className":"btn-sm btn-primary",
"callback": function () { "callback": function () {
window.location.href='<webpath:path/>/'; window.location.href = webPath + '/user/list';
} }
}, },
"success":{ "success":{
"label":"继续添加", "label":"继续添加",
"className":"btn-sm btn-primary", "className":"btn-sm btn-primary",
"callback": function () { "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