职务分类接口 表结构更新
parent
902f845543
commit
8e4d698217
@ -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 {
|
||||
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.engine.organization.mapper.post.PostMapper">
|
||||
<resultMap id="BaseResultMap" type="com.engine.organization.entity.post.po.PostPO">
|
||||
<result column="id" property="id"/>
|
||||
<result column="post_no" property="postNo"/>
|
||||
<result column="post_name" property="postName"/>
|
||||
<result column="description" property="description"/>
|
||||
<result column="creator" property="creator"/>
|
||||
<result column="creator" property="deleteType"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 表字段 -->
|
||||
<sql id="baseColumns">
|
||||
t
|
||||
.
|
||||
id
|
||||
, t.post_no
|
||||
, t.post_name
|
||||
, t.description
|
||||
, t.creator
|
||||
, t.delete_type
|
||||
, t.create_time
|
||||
, t.update_time
|
||||
</sql>
|
||||
<select id="getPostByID" parameterType="com.engine.organization.entity.post.po.PostPO"
|
||||
resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="baseColumns"/>
|
||||
from jcl_org_post t where id = #{id} AND delete_type = 0
|
||||
</select>
|
||||
|
||||
<select id="listByNo" parameterType="com.engine.organization.entity.post.po.PostPO" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="baseColumns"/>
|
||||
from jcl_org_post t where post_no = #{postNo} AND delete_type = 0
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 浏览按钮赋值、展示用 -->
|
||||
<select id="listPostsByIds" resultType="java.util.Map">
|
||||
select
|
||||
id,
|
||||
post_name as name
|
||||
from jcl_org_post t
|
||||
WHERE delete_type = 0
|
||||
AND id IN
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<update id="updatePost" parameterType="com.engine.organization.entity.post.po.PostPO">
|
||||
update jcl_org_post
|
||||
<set>
|
||||
creator=#{creator},
|
||||
update_time=#{updateTime},
|
||||
post_no=#{postNo},
|
||||
post_name=#{postName},
|
||||
description=#{description},
|
||||
</set>
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</update>
|
||||
|
||||
<insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.post.po.PostPO" keyProperty="id"
|
||||
keyColumn="id" useGeneratedKeys="true">
|
||||
INSERT INTO jcl_org_post
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="creator != null">
|
||||
creator,
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
delete_type,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="postNo != null ">
|
||||
post_no,
|
||||
</if>
|
||||
<if test="postName != null ">
|
||||
post_name,
|
||||
</if>
|
||||
<if test="description != null ">
|
||||
description,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
<if test="creator != null">
|
||||
#{creator},
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
#{deleteType},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="postNo != null ">
|
||||
#{postNo},
|
||||
</if>
|
||||
<if test="postName != null ">
|
||||
#{postName},
|
||||
</if>
|
||||
<if test="description != null ">
|
||||
#{description},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
<update id="deleteByIds">
|
||||
UPDATE jcl_org_post
|
||||
SET delete_type = 1
|
||||
WHERE delete_type = 0
|
||||
AND id IN
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -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<Long> ids);
|
||||
|
||||
/**
|
||||
* 获取新增表单
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getPostForm(Map<String, Object> params);
|
||||
|
||||
|
||||
}
|
@ -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<PostPO> 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<Long> ids) {
|
||||
OrganizationAssert.notEmpty(ids, "请选择要删除的数据");
|
||||
return getPostMapper().deleteByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPostForm(Map<String, Object> params) {
|
||||
Map<String, Object> apiDatas = new HashMap<>();
|
||||
List<SearchConditionItem> selectItems = new ArrayList<>();
|
||||
List<SearchConditionGroup> 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;
|
||||
}
|
||||
}
|
@ -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<Long> ids) {
|
||||
return getPostService(user).deleteByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新增表单
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getPostForm(Map<String, Object> params) {
|
||||
return getPostService(user).getPostForm(params);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue