分组维护 新建分组
This commit is contained in:
parent
d809107c48
commit
b4b54fa1e1
|
|
@ -0,0 +1,24 @@
|
|||
package com.engine.organization.entity.extend.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/06/15
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ExtendTitleSaveParam {
|
||||
private String data;
|
||||
private Long groupType;
|
||||
|
||||
private String groupName;
|
||||
private String isShow;
|
||||
|
||||
}
|
||||
|
|
@ -20,5 +20,35 @@ public interface ExtendTitleMapper {
|
|||
*/
|
||||
List<ExtendTitlePO> getTitlesByGroupID(@Param("groupId") Long groupId);
|
||||
|
||||
/**
|
||||
* 根据ID查询数据
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<ExtendTitlePO> getTitlesByIds(@Param("ids") Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param extendTitle
|
||||
* @return
|
||||
*/
|
||||
int insertIgnoreNull(ExtendTitlePO extendTitle);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param extendTitle
|
||||
* @return
|
||||
*/
|
||||
int updateExtendTitle(ExtendTitlePO extendTitle);
|
||||
|
||||
/**
|
||||
* 根据ID批量删除数据
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
int deleteExtendTitleByIds(@Param("ids") Collection<Long> ids);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,92 @@
|
|||
id
|
||||
, t.group_id
|
||||
, t.title
|
||||
, show_order
|
||||
, is_show
|
||||
, t.show_order
|
||||
, t.is_show
|
||||
, t.creator
|
||||
, t.delete_type
|
||||
, t.create_time
|
||||
, t.update_time
|
||||
</sql>
|
||||
<insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.extend.po.ExtendTitlePO"
|
||||
keyProperty="id"
|
||||
keyColumn="id" useGeneratedKeys="true">
|
||||
INSERT INTO jcl_field_extendtitle
|
||||
<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="groupId != null ">
|
||||
group_id,
|
||||
</if>
|
||||
<if test="title != null ">
|
||||
title,
|
||||
</if>
|
||||
<if test="showOrder != null ">
|
||||
show_order,
|
||||
</if>
|
||||
<if test="isShow != null ">
|
||||
is_show,
|
||||
</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="groupId != null ">
|
||||
#{groupId},
|
||||
</if>
|
||||
<if test="title != null ">
|
||||
#{title},
|
||||
</if>
|
||||
|
||||
<if test="showOrder != null ">
|
||||
#{showOrder},
|
||||
</if>
|
||||
<if test="isShow != null ">
|
||||
#{isShow},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateExtendTitle" parameterType="com.engine.organization.entity.extend.po.ExtendTitlePO">
|
||||
update jcl_field_extendtitle
|
||||
<set>
|
||||
update_time=#{updateTime},
|
||||
group_id=#{groupId},
|
||||
title=#{title},
|
||||
show_order=#{showOrder},
|
||||
is_show=#{isShow},
|
||||
</set>
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</update>
|
||||
<delete id="deleteExtendTitleByIds">
|
||||
UPDATE jcl_field_extendtitle
|
||||
SET delete_type = 1
|
||||
WHERE delete_type = 0
|
||||
AND id IN
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getTitlesByGroupID" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.engine.organization.service;
|
||||
|
||||
import com.engine.organization.entity.extend.param.ExtendTitleSaveParam;
|
||||
import com.engine.organization.entity.fieldset.vo.TypeTreeVO;
|
||||
import com.engine.organization.enums.ModuleTypeEnum;
|
||||
|
||||
|
|
@ -33,4 +34,20 @@ public interface FieldDefinedService {
|
|||
*/
|
||||
int saveFields(String data);
|
||||
|
||||
/**
|
||||
* 分组维护
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> saveGroup(ExtendTitleSaveParam param);
|
||||
|
||||
/**
|
||||
* 新建分组
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> saveTitle(ExtendTitleSaveParam param);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ public class ExtServiceImpl extends Service implements ExtService {
|
|||
OrganizationAssert.notNull(groupId, "请选择对应的拓展页");
|
||||
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, groupId, tableName, ExtendInfoOperateType.EDIT.getValue());
|
||||
String fields = infoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(","));
|
||||
if (StringUtils.isEmpty(fields)) {
|
||||
return conditionItems;
|
||||
}
|
||||
Map<String, Object> compExtMap = getExtMapper().listExt(tableName, fields, id);
|
||||
List<String> readOnlyFieldList = Arrays.asList(readOnlyFields);
|
||||
// 组装拓展页内容
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
package com.engine.organization.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.entity.extend.bo.ExtendGroupBO;
|
||||
import com.engine.organization.entity.extend.param.ExtendTitleSaveParam;
|
||||
import com.engine.organization.entity.extend.po.ExtendGroupPO;
|
||||
import com.engine.organization.entity.extend.po.ExtendTitlePO;
|
||||
import com.engine.organization.entity.fieldset.vo.TypeTreeVO;
|
||||
|
|
@ -14,13 +16,12 @@ import com.engine.organization.mapper.extend.ExtendTitleMapper;
|
|||
import com.engine.organization.service.FieldDefinedService;
|
||||
import com.engine.organization.util.OrganizationAssert;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import com.weaver.general.Util;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
|
|
@ -59,7 +60,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
|
|||
tab.put("isShow", extendTitle.getIsShow());
|
||||
tab.put("groupid", extendTitle.getGroupId());
|
||||
tab.put("viewAttr", extendTitle.getGroupId() < 0 ? 1 : 2);
|
||||
tab.put("editable", editTable(extendTitle.getId()));
|
||||
tab.put("editable", getExtendInfoMapper().countFieldsByGroupId(extendTitle.getId()) > 0);
|
||||
tabs.add(tab);
|
||||
}
|
||||
datas.put("status", "1");
|
||||
|
|
@ -78,13 +79,69 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断该分组下是否有字段
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private boolean editTable(Long id) {
|
||||
return getExtendInfoMapper().countFieldsByGroupId(id) > 0;
|
||||
@Override
|
||||
public Map<String, Object> saveGroup(ExtendTitleSaveParam param) {
|
||||
Map<String, Object> datas = new HashMap<>();
|
||||
Long groupType = param.getGroupType();
|
||||
Set<Long> lsDelGroupId = new HashSet<>();
|
||||
List<ExtendTitlePO> extendTitleList = getExtendTitleMapper().getTitlesByGroupID(groupType);
|
||||
extendTitleList.forEach(item -> lsDelGroupId.add(item.getId()));
|
||||
String data = param.getData();
|
||||
JSONObject jsonObject = JSON.parseObject(data);
|
||||
Set<Long> ids = new HashSet<>();
|
||||
JSONArray records = (JSONArray) jsonObject.get("records");
|
||||
for (int i = 0; i < records.size(); i++) {
|
||||
ExtendTitlePO extendTitle = new ExtendTitlePO();
|
||||
JSONObject object = (JSONObject) records.get(i);
|
||||
extendTitle.setId(object.getLong("id"));
|
||||
extendTitle.setGroupId(groupType);
|
||||
extendTitle.setIsShow(object.getString("isShow"));
|
||||
extendTitle.setTitle(object.getString("groupName"));
|
||||
extendTitle.setShowOrder(i + 1);
|
||||
|
||||
if (null != extendTitle.getId()) {
|
||||
lsDelGroupId.remove(extendTitle.getId());
|
||||
}
|
||||
|
||||
if (null == extendTitle.getId()) {
|
||||
extendTitle.setCreator(user.getUID());
|
||||
extendTitle.setCreateTime(new Date());
|
||||
extendTitle.setDeleteType(0);
|
||||
getExtendTitleMapper().insertIgnoreNull(extendTitle);
|
||||
} else {
|
||||
extendTitle.setUpdateTime(new Date());
|
||||
getExtendTitleMapper().updateExtendTitle(extendTitle);
|
||||
}
|
||||
ids.add(extendTitle.getId());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(lsDelGroupId)) {
|
||||
getExtendTitleMapper().deleteExtendTitleByIds(lsDelGroupId);
|
||||
}
|
||||
datas.put("groupid", StringUtils.join(ids, ","));
|
||||
datas.put("status", "1");
|
||||
return datas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> saveTitle(ExtendTitleSaveParam param) {
|
||||
Map<String, Object> datas = new HashMap<>();
|
||||
|
||||
List<ExtendTitlePO> titlesByGroupID = getExtendTitleMapper().getTitlesByGroupID(param.getGroupType());
|
||||
ExtendTitlePO extendTitlePO = titlesByGroupID.stream().max(Comparator.comparing(ExtendTitlePO::getShowOrder)).get();
|
||||
Set<Long> ids = titlesByGroupID.stream().map(ExtendTitlePO::getId).collect(Collectors.toSet());
|
||||
ExtendTitlePO extendTitle = new ExtendTitlePO();
|
||||
extendTitle.setGroupId(param.getGroupType());
|
||||
extendTitle.setIsShow(param.getIsShow());
|
||||
extendTitle.setTitle(param.getGroupName());
|
||||
extendTitle.setShowOrder(null == extendTitlePO ? 0 : extendTitlePO.getShowOrder() + 1);
|
||||
extendTitle.setCreator(user.getUID());
|
||||
extendTitle.setCreateTime(new Date());
|
||||
extendTitle.setDeleteType(0);
|
||||
getExtendTitleMapper().insertIgnoreNull(extendTitle);
|
||||
ids.add(extendTitle.getId());
|
||||
|
||||
datas.put("groupid", StringUtils.join(ids, ","));
|
||||
datas.put("status", "1");
|
||||
return datas;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,18 +2,17 @@ package com.engine.organization.web;
|
|||
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.organization.entity.extend.param.ExtendTitleSaveParam;
|
||||
import com.engine.organization.enums.ModuleTypeEnum;
|
||||
import com.engine.organization.util.response.ReturnResult;
|
||||
import com.engine.organization.wrapper.FieldDefinedWrapper;
|
||||
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.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.Map;
|
||||
|
|
@ -56,4 +55,44 @@ public class FieldDefinedController {
|
|||
return ReturnResult.exceptionHandle(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组维护
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@POST
|
||||
@Path("/saveGroup")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult saveGroup(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExtendTitleSaveParam param) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ReturnResult.successed(getFieldDefinedWrapper(user).saveGroup(param));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建分组
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@POST
|
||||
@Path("/saveTitle")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult saveTitle(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExtendTitleSaveParam param) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ReturnResult.successed(getFieldDefinedWrapper(user).saveTitle(param));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.engine.organization.wrapper;
|
|||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.entity.extend.param.ExtendTitleSaveParam;
|
||||
import com.engine.organization.entity.fieldset.vo.TypeTreeVO;
|
||||
import com.engine.organization.enums.ModuleTypeEnum;
|
||||
import com.engine.organization.service.FieldDefinedService;
|
||||
|
|
@ -39,4 +40,24 @@ public class FieldDefinedWrapper extends Service {
|
|||
public Map<String, Object> getTabInfo(String groupType) {
|
||||
return getFieldDefinedService(user).getTabInfo(groupType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组维护
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> saveGroup(ExtendTitleSaveParam param) {
|
||||
return getFieldDefinedService(user).saveGroup(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建分组
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> saveTitle(ExtendTitleSaveParam param) {
|
||||
return getFieldDefinedService(user).saveTitle(param);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue