diff --git a/tamguo-oms/src/main/java/com/tamguo/modules/sys/model/SysPostEntity.java b/tamguo-oms/src/main/java/com/tamguo/modules/sys/model/SysPostEntity.java index 32b43e8..a2847ea 100644 --- a/tamguo-oms/src/main/java/com/tamguo/modules/sys/model/SysPostEntity.java +++ b/tamguo-oms/src/main/java/com/tamguo/modules/sys/model/SysPostEntity.java @@ -44,8 +44,8 @@ public class SysPostEntity extends SuperEntity 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; diff --git a/tamguo-oms/src/main/java/com/tamguo/modules/sys/model/enums/SysPostTypeEnum.java b/tamguo-oms/src/main/java/com/tamguo/modules/sys/model/enums/SysPostTypeEnum.java index fb2c248..63c02e4 100644 --- a/tamguo-oms/src/main/java/com/tamguo/modules/sys/model/enums/SysPostTypeEnum.java +++ b/tamguo-oms/src/main/java/com/tamguo/modules/sys/model/enums/SysPostTypeEnum.java @@ -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; diff --git a/tamguo-oms/src/main/java/com/tamguo/modules/sys/service/IPostService.java b/tamguo-oms/src/main/java/com/tamguo/modules/sys/service/IPostService.java index 479fe6a..ab1fadd 100644 --- a/tamguo-oms/src/main/java/com/tamguo/modules/sys/service/IPostService.java +++ b/tamguo-oms/src/main/java/com/tamguo/modules/sys/service/IPostService.java @@ -7,6 +7,13 @@ import com.tamguo.modules.sys.model.condition.SysPostCondition; public interface IPostService extends IService{ + /** 查询列表*/ Page listData(SysPostCondition condition); + /** 添加数据*/ + void add(SysPostEntity post); + + /** 修改数据*/ + void update(SysPostEntity post); + } diff --git a/tamguo-oms/src/main/java/com/tamguo/modules/sys/service/impl/PostServiceImpl.java b/tamguo-oms/src/main/java/com/tamguo/modules/sys/service/impl/PostServiceImpl.java index 76cbc93..dd20e1d 100644 --- a/tamguo-oms/src/main/java/com/tamguo/modules/sys/service/impl/PostServiceImpl.java +++ b/tamguo-oms/src/main/java/com/tamguo/modules/sys/service/impl/PostServiceImpl.java @@ -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 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); + } + } diff --git a/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/PostController.java b/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/PostController.java index 2ba33aa..92ff614 100644 --- a/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/PostController.java +++ b/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/PostController.java @@ -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 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); + } + + } } diff --git a/tamguo-oms/src/main/resources/templates/modules/sys/post/detail.html b/tamguo-oms/src/main/resources/templates/modules/sys/post/detail.html index 3ed42f8..d6921a0 100644 --- a/tamguo-oms/src/main/resources/templates/modules/sys/post/detail.html +++ b/tamguo-oms/src/main/resources/templates/modules/sys/post/detail.html @@ -25,7 +25,7 @@ content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/> -
+
基本信息
@@ -34,8 +34,8 @@ content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
- - + +
@@ -44,8 +44,8 @@ content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
- - + +
@@ -91,7 +91,7 @@ content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>