main
tamguo 7 years ago
parent 47ae24262d
commit 81026ba790

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

@ -19,6 +19,19 @@ public enum SysPostTypeEnum implements IEnum {
this.value = value;
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() {
return this.value;

@ -7,6 +7,13 @@ import com.tamguo.modules.sys.model.condition.SysPostCondition;
public interface IPostService extends IService<SysPostEntity>{
/** 查询列表*/
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.plugins.Page;
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));
}
@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.condition.SysPostCondition;
import com.tamguo.modules.sys.service.IPostService;
import com.tamguo.modules.sys.utils.ExceptionSupport;
import com.tamguo.modules.sys.utils.Result;
@Controller
@ -49,4 +50,20 @@ public class PostController {
Page<SysPostEntity> page = iPostService.listData(condition);
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>
</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="form-unit">基本信息</div>
<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="">
<span class="required ">*</span> 岗位名称:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="hidden" id="oldRoleName" name="oldRoleName" value=""/>
<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="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 "/>
</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="">
<span class="required ">*</span> 岗位编码:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<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="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"/>
</div>
</div>
</div>
@ -91,7 +91,7 @@ content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
<div class="box-footer">
<div class="row">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>&nbsp;
<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>&nbsp;
<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> 关 闭</button>
</div>
</div>
@ -118,7 +118,7 @@ $("#inputForm").validate({
submitHandler: function(form){
js.ajaxSubmitForm($(form), function(data){
js.showMessage(data.message);
if(data.result == Global.TRUE){
if(data.code == 0){
js.closeCurrentTabPage(function(contentWindow){
contentWindow.page();
});

Loading…
Cancel
Save