diff --git a/docs/表结构SQL/MySQL.sql b/docs/表结构SQL/MySQL.sql index 05a41bd3..8165de28 100644 --- a/docs/表结构SQL/MySQL.sql +++ b/docs/表结构SQL/MySQL.sql @@ -59,7 +59,7 @@ CREATE TABLE JCL_ORG_SEQUENCE ( -- JCL_ORG_POST CREATE TABLE JCL_ORG_POST ( id int auto_increment NOT NULL, - post_no int null, + post_no varchar(100) null, post_name varchar(100) NULL, description text NULL, creator int null, @@ -72,12 +72,12 @@ CREATE TABLE JCL_ORG_POST ( -- JCL_ORG_POST_INFO CREATE TABLE JCL_ORG_POST_INFO ( id int auto_increment NOT NULL, - post_info_no int null, + post_info_no varchar(100) null, post_info_name varchar(100) NULL, post_info_authority text null, post_info_duty text null, post_info_qualification text null, - post_type int null, + post_id int null, description text NULL, creator int null, delete_type int null, diff --git a/docs/表结构SQL/Oracle.sql b/docs/表结构SQL/Oracle.sql index 5a867e60..863e56b9 100644 --- a/docs/表结构SQL/Oracle.sql +++ b/docs/表结构SQL/Oracle.sql @@ -61,7 +61,7 @@ CREATE TABLE JCL_ORG_SEQUENCE ( -- JCL_ORG_POST CREATE TABLE JCL_ORG_POST ( ID NUMBER NOT NULL, - POST_NO NUMBER NULL, + POST_NO NVARCHAR2(100) NULL, POST_NAME NVARCHAR2(100) NULL, DESCRIPTION NVARCHAR2(1000) NULL, CREATOR NUMBER NULL, @@ -74,12 +74,12 @@ CREATE TABLE JCL_ORG_POST ( -- JCL_ORG_POST_INFO CREATE TABLE JCL_ORG_POST_INFO ( ID NUMBER NOT NULL, - POST_INFO_NO NUMBER NULL, + POST_INFO_NO NVARCHAR2(100) NULL, POST_INFO_NAME NVARCHAR2(100) NULL, POST_INFO_AUTHORITY NVARCHAR2(1000) NULL, POST_INFO_DUTY NVARCHAR2(1000) NULL, POST_INFO_QUALIFICATION NVARCHAR2(1000) NULL, - POST_TYPE NUMBER NULL, + POST_ID NUMBER NULL, DESCRIPTION NVARCHAR2(1000) NULL, CREATOR NUMBER NULL, DELETE_TYPE NUMBER NULL, diff --git a/docs/表结构SQL/SqlServer.sql b/docs/表结构SQL/SqlServer.sql index 001c8821..47722348 100644 --- a/docs/表结构SQL/SqlServer.sql +++ b/docs/表结构SQL/SqlServer.sql @@ -59,7 +59,7 @@ CREATE TABLE JCL_ORG_SEQUENCE ( -- JCL_ORG_POST CREATE TABLE JCL_ORG_POST ( id int IDENTITY(1,1) NOT NULL, - post_no int null, + post_no varchar(100) COLLATE Chinese_PRC_CI_AS NULL, post_name varchar(100) COLLATE Chinese_PRC_CI_AS NULL, description text COLLATE Chinese_PRC_CI_AS NULL, creator int null, @@ -72,12 +72,12 @@ CREATE TABLE JCL_ORG_POST ( -- JCL_ORG_POST_INFO CREATE TABLE JCL_ORG_POST_INFO ( id int IDENTITY(1,1) NOT NULL, - post_info_no int null, + post_info_no varchar(100) COLLATE Chinese_PRC_CI_AS NULL, post_info_name varchar(100) COLLATE Chinese_PRC_CI_AS NULL, post_info_authority text null, post_info_duty text null, post_info_qualification text null, - post_type int null, + post_id int null, description text COLLATE Chinese_PRC_CI_AS NULL, creator int null, delete_type int null, diff --git a/src/com/api/organization/web/PostController.java b/src/com/api/organization/web/PostController.java new file mode 100644 index 00000000..195a23b8 --- /dev/null +++ b/src/com/api/organization/web/PostController.java @@ -0,0 +1,15 @@ +package com.api.organization.web; + +import javax.ws.rs.Path; + +/** + * + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/13 + * @version: 1.0 + */ +@Path("/bs/hrmorganization/post") +public class PostController extends com.engine.organization.web.PostController { + +} diff --git a/src/com/engine/organization/entity/post/dto/PostDTO.java b/src/com/engine/organization/entity/post/dto/PostDTO.java new file mode 100644 index 00000000..1285763b --- /dev/null +++ b/src/com/engine/organization/entity/post/dto/PostDTO.java @@ -0,0 +1,30 @@ +package com.engine.organization.entity.post.dto; + +import com.engine.organization.entity.post.po.PostPO; + +import java.util.Date; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/13 + * @version: 1.0 + */ +public class PostDTO { + public static PostPO convertPO(PostPO postPO, long employeeId) { + if (postPO == null) { + return null; + } + return PostPO.builder() + .id(postPO.getId() == null ? 0 : postPO.getId()) + .postNo(postPO.getPostNo() == null ? null : postPO.getPostNo()) + .postName(postPO.getPostName() == null ? null : postPO.getPostName()) + .description(postPO.getDescription() == null ? null : postPO.getDescription()) + .deleteType(0) + .createTime(new Date()) + .updateTime(new Date()) + .creator(employeeId) + .build(); + } + +} diff --git a/src/com/engine/organization/entity/post/po/PostPO.java b/src/com/engine/organization/entity/post/po/PostPO.java new file mode 100644 index 00000000..91120587 --- /dev/null +++ b/src/com/engine/organization/entity/post/po/PostPO.java @@ -0,0 +1,42 @@ +package com.engine.organization.entity.post.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/13 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class PostPO { + /** + * 主键 + */ + private Long id; + /** + * 编号 + */ + private String postNo; + /** + * 名称 + */ + private String postName; + /** + * 说明 + */ + private String description; + private Long creator; + private int deleteType; + private Date createTime; + private Date updateTime; + +} diff --git a/src/com/engine/organization/mapper/post/PostMapper.java b/src/com/engine/organization/mapper/post/PostMapper.java new file mode 100644 index 00000000..d118e2cf --- /dev/null +++ b/src/com/engine/organization/mapper/post/PostMapper.java @@ -0,0 +1,69 @@ +package com.engine.organization.mapper.post; + + +import com.engine.organization.entity.post.po.PostPO; +import org.apache.ibatis.annotations.MapKey; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * @Author dxfeng + * @Description: TODO + * @Date 2022/5/13 + * @Version V1.0 + **/ +public interface PostMapper { + + /** + * 根据No查询职务分类 + * + * @param postNo + * @return + */ + List listByNo(@Param("postNo") String postNo); + + /** + * 获取职务分类根据ID + * + * @param id + * @return + */ + PostPO getPostByID(@Param("id") long id); + + /** + * 根据ID查询职务分类列表 + * 浏览按钮赋值、展示用 + * + * @param ids + * @return + */ + @MapKey("id") + List> listPostsByIds(@Param("ids") Collection ids); + + /** + * 插入职务分类 + * + * @param postPO + * @return + */ + int insertIgnoreNull(PostPO postPO); + + /** + * 修改,修改所有字段 + * + * @param postPO + * @return + */ + int updatePost(PostPO postPO); + + /** + * 批量删除职务分类方案 + * + * @param ids + */ + int deleteByIds(@Param("ids") Collection ids); + +} diff --git a/src/com/engine/organization/mapper/post/PostMapper.xml b/src/com/engine/organization/mapper/post/PostMapper.xml new file mode 100644 index 00000000..0a0e4e18 --- /dev/null +++ b/src/com/engine/organization/mapper/post/PostMapper.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + t + . + id + , t.post_no + , t.post_name + , t.description + , t.creator + , t.delete_type + , t.create_time + , t.update_time + + + + + + + + + + + update jcl_org_post + + creator=#{creator}, + update_time=#{updateTime}, + post_no=#{postNo}, + post_name=#{postName}, + description=#{description}, + + WHERE id = #{id} AND delete_type = 0 + + + + INSERT INTO jcl_org_post + + + creator, + + + delete_type, + + + create_time, + + + update_time, + + + post_no, + + + post_name, + + + description, + + + + + #{creator}, + + + #{deleteType}, + + + #{createTime}, + + + #{updateTime}, + + + #{postNo}, + + + #{postName}, + + + #{description}, + + + + + + + + UPDATE jcl_org_post + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + \ No newline at end of file diff --git a/src/com/engine/organization/service/PostService.java b/src/com/engine/organization/service/PostService.java new file mode 100644 index 00000000..b92013a6 --- /dev/null +++ b/src/com/engine/organization/service/PostService.java @@ -0,0 +1,47 @@ +package com.engine.organization.service; + +import com.engine.organization.entity.post.po.PostPO; + +import java.util.Collection; +import java.util.Map; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/13 + * @version: 1.0 + */ +public interface PostService { + + /** + * 新增职务分类 + * @param postPO + * @return + */ + int savePost(PostPO postPO); + + /** + * 更新职务分类信息 + * + * @param postPO + * @return + */ + int updatePost(PostPO postPO); + + /** + * 根据ID批量删除 + * + * @param ids + */ + int deleteByIds(Collection ids); + + /** + * 获取新增表单 + * + * @param params + * @return + */ + Map getPostForm(Map params); + + +} diff --git a/src/com/engine/organization/service/impl/PostServiceImpl.java b/src/com/engine/organization/service/impl/PostServiceImpl.java new file mode 100644 index 00000000..4d5cf882 --- /dev/null +++ b/src/com/engine/organization/service/impl/PostServiceImpl.java @@ -0,0 +1,78 @@ +package com.engine.organization.service.impl; + +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.engine.core.impl.Service; +import com.engine.organization.entity.post.dto.PostDTO; +import com.engine.organization.entity.post.po.PostPO; +import com.engine.organization.mapper.post.PostMapper; +import com.engine.organization.service.PostService; +import com.engine.organization.util.OrganizationAssert; +import com.engine.organization.util.OrganizationFormItemUtil; +import com.engine.organization.util.db.MapperProxyFactory; +import weaver.general.StringUtil; +import weaver.general.Util; + +import java.util.*; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/13 + * @version: 1.0 + */ +public class PostServiceImpl extends Service implements PostService { + + private PostMapper getPostMapper() { + return MapperProxyFactory.getProxy(PostMapper.class); + } + + @Override + public int savePost(PostPO postPO) { + List list = getPostMapper().listByNo(Util.null2String(postPO.getPostNo())); + OrganizationAssert.isEmpty(list, "编号不允许重复"); + return getPostMapper().insertIgnoreNull(PostDTO.convertPO(postPO,user.getUID())); + } + + @Override + public int updatePost(PostPO postPO) { + return getPostMapper().updatePost(PostDTO.convertPO(postPO,user.getUID())); + } + + @Override + public int deleteByIds(Collection ids) { + OrganizationAssert.notEmpty(ids, "请选择要删除的数据"); + return getPostMapper().deleteByIds(ids); + } + + @Override + public Map getPostForm(Map params) { + Map apiDatas = new HashMap<>(); + List selectItems = new ArrayList<>(); + List addGroups = new ArrayList<>(); + SearchConditionItem postNameItem = OrganizationFormItemUtil.inputItem(user, 2, 17, 3, 50, "名称", "postName"); + postNameItem.setRules("required|string"); + SearchConditionItem postNoItem = OrganizationFormItemUtil.inputItem(user, 2, 17, 3, 50, "编号", "postNo"); + postNoItem.setRules("required|string"); + SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 17, true, 2, 60, "描述说明", "description"); + + // 编辑状态下赋值操作 + String id = Util.null2String(params.get("id")); + if (!StringUtil.isEmpty(id)) { + PostPO postPO = getPostMapper().getPostByID(Integer.parseInt(id)); + OrganizationAssert.notNull(postPO, "选择的数据不存在,或数据已删除"); + + postNameItem.setValue(postPO.getPostName()); + postNoItem.setValue(postPO.getPostNo()); + descriptionItem.setValue(postPO.getDescription()); + + } + + selectItems.add(postNoItem); + selectItems.add(postNameItem); + selectItems.add(descriptionItem); + addGroups.add(new SearchConditionGroup("基本信息", true, selectItems)); + apiDatas.put("condition", addGroups); + return apiDatas; + } +} diff --git a/src/com/engine/organization/web/PostController.java b/src/com/engine/organization/web/PostController.java new file mode 100644 index 00000000..fb049a45 --- /dev/null +++ b/src/com/engine/organization/web/PostController.java @@ -0,0 +1,117 @@ +package com.engine.organization.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.organization.entity.QueryParam; +import com.engine.organization.entity.post.po.PostPO; +import com.engine.organization.util.response.ReturnResult; +import com.engine.organization.wrapper.PostWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/13 + * @version: 1.0 + */ +public class PostController { + public PostWrapper getPostWrapper(User user) { + return ServiceUtil.getService(PostWrapper.class, user); + } + + + /** + * 添加职务分类 + * + * @param request + * @param response + * @param postPO + * @return + */ + @POST + @Path("/savePost") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult savePost(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody PostPO postPO) { + try { + User user = HrmUserVarify.getUser(request, response); + return ReturnResult.successed(getPostWrapper(user).savePost(postPO)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + + /** + * 更新职务分类,修改所有字段 + * + * @param request + * @param response + * @param postPO + * @return + */ + @POST + @Path("/updatePost") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult updatePost(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody PostPO postPO) { + try { + User user = HrmUserVarify.getUser(request, response); + return ReturnResult.successed(getPostWrapper(user).updatePost(postPO)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + + + /** + * 根据ID批量删除数据 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/deleteByIds") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult deleteByIds(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody QueryParam param) { + try { + User user = HrmUserVarify.getUser(request, response); + return ReturnResult.successed(getPostWrapper(user).deleteByIds(param.getIds())); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + + + /** + * 新增、编辑表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getPostForm") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getPostForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + return ReturnResult.successed(getPostWrapper(user).getPostForm(map)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + +} diff --git a/src/com/engine/organization/web/SequenceController.java b/src/com/engine/organization/web/SequenceController.java index 63c76adb..faf2b8b0 100644 --- a/src/com/engine/organization/web/SequenceController.java +++ b/src/com/engine/organization/web/SequenceController.java @@ -62,12 +62,12 @@ public class SequenceController { @Path("/saveSequence") @Produces(MediaType.APPLICATION_JSON) public ReturnResult saveSequence(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SequenceSearchParam param) { - //try { + try { User user = HrmUserVarify.getUser(request, response); return ReturnResult.successed(getSequenceWrapper(user).saveSequence(param)); - //} catch (Exception e) { - // return ReturnResult.exceptionHandle(e.getMessage()); - //} + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } } /** diff --git a/src/com/engine/organization/wrapper/PostWrapper.java b/src/com/engine/organization/wrapper/PostWrapper.java new file mode 100644 index 00000000..c0ef2cc9 --- /dev/null +++ b/src/com/engine/organization/wrapper/PostWrapper.java @@ -0,0 +1,64 @@ +package com.engine.organization.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.organization.entity.post.po.PostPO; +import com.engine.organization.service.PostService; +import com.engine.organization.service.impl.PostServiceImpl; +import org.apache.ibatis.annotations.Param; +import weaver.hrm.User; + +import java.util.Collection; +import java.util.Map; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/13 + * @version: 1.0 + */ +public class PostWrapper extends Service { + private PostService getPostService(User user) { + return ServiceUtil.getService(PostServiceImpl.class, user); + } + + /** + * 新增职务分类 + * + * @param postPO + * @return + */ + public int savePost(PostPO postPO) { + return getPostService(user).savePost(postPO); + } + + /** + * 更新职务分类 + * + * @param postPO + * @return + */ + public int updatePost(PostPO postPO) { + return getPostService(user).updatePost(postPO); + } + + /** + * 根据ID批量删除 + * + * @param ids + */ + public int deleteByIds(@Param("ids") Collection ids) { + return getPostService(user).deleteByIds(ids); + } + + /** + * 获取新增表单 + * + * @param params + * @return + */ + public Map getPostForm(Map params) { + return getPostService(user).getPostForm(params); + } + +}