main
tamguo 7 years ago
parent 47ae24262d
commit 81026ba790

@ -44,8 +44,8 @@ public class SysPostEntity extends SuperEntity<SysPostEntity> implements Seriali
public SysPostTypeEnum getPostType() { public SysPostTypeEnum getPostType() {
return postType; return postType;
} }
public void setPostType(SysPostTypeEnum postType) { public void setPostType(String postType) {
this.postType = postType; this.postType = SysPostTypeEnum.getPostType(postType);
} }
public Integer getSorts() { public Integer getSorts() {
return sorts; return sorts;

@ -20,6 +20,19 @@ public enum SysPostTypeEnum implements IEnum {
this.desc = desc; this.desc = desc;
} }
public static SysPostTypeEnum getPostType(String postType) {
if("gaoguan".equals(postType)) {
return SysPostTypeEnum.GAOGUAN;
}else if("zhongceng".equals(postType)) {
return SysPostTypeEnum.ZHONGCENG;
}else if("jiceng".equals(postType)) {
return SysPostTypeEnum.JICENG;
}else if("qita".equals(postType)) {
return SysPostTypeEnum.QITA;
}
return null;
}
public Serializable getValue() { public Serializable getValue() {
return this.value; return this.value;
} }

@ -7,6 +7,13 @@ import com.tamguo.modules.sys.model.condition.SysPostCondition;
public interface IPostService extends IService<SysPostEntity>{ public interface IPostService extends IService<SysPostEntity>{
/** 查询列表*/
Page<SysPostEntity> listData(SysPostCondition condition); Page<SysPostEntity> listData(SysPostCondition condition);
/** 添加数据*/
void add(SysPostEntity post);
/** 修改数据*/
void update(SysPostEntity post);
} }

@ -2,6 +2,7 @@ package com.tamguo.modules.sys.service.impl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.baomidou.mybatisplus.service.impl.ServiceImpl;
@ -22,4 +23,16 @@ public class PostServiceImpl extends ServiceImpl<SysPostMapper, SysPostEntity> i
return page.setRecords(sysPostMapper.listData(condition , page)); return page.setRecords(sysPostMapper.listData(condition , page));
} }
@Transactional(readOnly=false)
@Override
public void add(SysPostEntity post) {
sysPostMapper.insert(post);
}
@Transactional(readOnly=false)
@Override
public void update(SysPostEntity post) {
sysPostMapper.updateById(post);
}
} }

@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.plugins.Page;
import com.tamguo.modules.sys.model.SysPostEntity; import com.tamguo.modules.sys.model.SysPostEntity;
import com.tamguo.modules.sys.model.condition.SysPostCondition; import com.tamguo.modules.sys.model.condition.SysPostCondition;
import com.tamguo.modules.sys.service.IPostService; import com.tamguo.modules.sys.service.IPostService;
import com.tamguo.modules.sys.utils.ExceptionSupport;
import com.tamguo.modules.sys.utils.Result; import com.tamguo.modules.sys.utils.Result;
@Controller @Controller
@ -49,4 +50,20 @@ public class PostController {
Page<SysPostEntity> page = iPostService.listData(condition); Page<SysPostEntity> page = iPostService.listData(condition);
return Result.jqGridResult(page.getRecords(), page.getTotal(), page.getSize(), page.getCurrent(), page.getPages()); return Result.jqGridResult(page.getRecords(), page.getTotal(), page.getSize(), page.getCurrent(), page.getPages());
} }
@RequestMapping(path="save",method=RequestMethod.POST)
@ResponseBody
public Result save(SysPostEntity post) {
try {
if(StringUtils.isEmpty(post.getId())) {
iPostService.add(post);
}else {
iPostService.update(post);
}
return Result.result(0, null, "操作成功");
} catch (Exception e) {
return ExceptionSupport.resolverResult("保存岗位", this.getClass(), e);
}
}
} }

@ -25,7 +25,7 @@ content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button> <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div> </div>
</div> </div>
<form id="inputForm" action="/js/a/sys/post/save" method="post" class="form-horizontal"> <form id="inputForm" th:action="${setting.domain + 'sys/post/save'}" method="post" class="form-horizontal">
<div class="box-body"> <div class="box-body">
<div class="form-unit">基本信息</div> <div class="form-unit">基本信息</div>
<div class="row"> <div class="row">
@ -34,8 +34,8 @@ content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
<label class="control-label col-sm-4" title=""> <label class="control-label col-sm-4" title="">
<span class="required ">*</span> 岗位名称:<i class="fa icon-question hide"></i></label> <span class="required ">*</span> 岗位名称:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="hidden" id="oldRoleName" name="oldRoleName" value=""/> <input type="hidden" id="id" name="id" th:value="${post.id}"/>
<input type="text" id="name" name="name" th:value="${post.name}" maxlength="100" class="form-control required " remote="/js/a/sys/post/checkPostName?oldPostName=" data-msg-remote="岗位名称已存在"/> <input type="text" id="name" name="name" th:value="${post.name}" maxlength="100" class="form-control required "/>
</div> </div>
</div> </div>
</div> </div>
@ -44,8 +44,8 @@ content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
<label class="control-label col-sm-4" title=""> <label class="control-label col-sm-4" title="">
<span class="required ">*</span> 岗位编码:<i class="fa icon-question hide"></i></label> <span class="required ">*</span> 岗位编码:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="hidden" id="isNewRecord" name="isNewRecord" value="true"/> <input type="hidden" id="isNewRecord" name="isNewRecord" value="true"/>
<input type="text" id="code" name="code" th:value="${post.code}" maxlength="64" class="form-control required abc"/> <input type="text" id="code" name="code" th:value="${post.code}" maxlength="64" class="form-control required abc"/>
</div> </div>
</div> </div>
</div> </div>
@ -118,7 +118,7 @@ $("#inputForm").validate({
submitHandler: function(form){ submitHandler: function(form){
js.ajaxSubmitForm($(form), function(data){ js.ajaxSubmitForm($(form), function(data){
js.showMessage(data.message); js.showMessage(data.message);
if(data.result == Global.TRUE){ if(data.code == 0){
js.closeCurrentTabPage(function(contentWindow){ js.closeCurrentTabPage(function(contentWindow){
contentWindow.page(); contentWindow.page();
}); });

Loading…
Cancel
Save