Commit 9e9e8faa by qwmqiuwenmin

fix

parent e9ca0c1b
......@@ -9,6 +9,8 @@ public class TemplateEnterpriseRelatedDTO implements Serializable{
private String wxEnterpriseId;
private String wxEnterpriseName;
private String applicationTemplateId;
private Integer statusFlag;
......@@ -67,4 +69,13 @@ public class TemplateEnterpriseRelatedDTO implements Serializable{
this.updateTime = updateTime;
}
public String getWxEnterpriseName() {
return wxEnterpriseName;
}
public void setWxEnterpriseName(String wxEnterpriseName) {
this.wxEnterpriseName = wxEnterpriseName;
}
}
......@@ -24,7 +24,7 @@ public interface ApplicationTemplateApiService {
void delTemplateEnterprise(String wxEnterpriseId);
List<ApplicationEnterpriseRelatedDTO> listTemplateEnterprise(String applicationTemplateId);
List<ApplicationEnterpriseRelatedDTO> listTemplateEnterprise(String applicationTemplateId, String wxEnterpriseName, String enterpriseName);
void setDefaultTemplateEnterprise(String applicationTemplateId);
......
package com.gic.haoban.manage.service.dao.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.service.entity.TabHaobanTemplateEnterpriseRelation;
......@@ -17,7 +19,11 @@ public interface TabHaobanTemplateEnterpriseRelationMapper {
int updateByPrimaryKey(TabHaobanTemplateEnterpriseRelation record);
TabHaobanTemplateEnterpriseRelation listEnterpriseByTemplateId(@Param("templateId")String templateId);
List<TabHaobanTemplateEnterpriseRelation> listEnterpriseByTemplateId(@Param("templateId")String templateId);
TabHaobanTemplateEnterpriseRelation selectByWxEnterpriseId(@Param("wxEnterpriseId")String wxEnterpriseId);
List<TabHaobanTemplateEnterpriseRelation> listEnterpriseByParams(@Param("applicationTemplateId")String applicationTemplateId, @Param("wxEnterpriseIds")List<String> wxEnterpriseIds,
@Param("wxEnterpriseName")String wxEnterpriseName);
}
\ No newline at end of file
......@@ -12,6 +12,8 @@ public class TabHaobanTemplateEnterpriseRelation implements Serializable {
private Integer statusFlag;
private String wxEnterpriseName;
private Date createTime;
private Date updateTime;
......@@ -65,4 +67,14 @@ public class TabHaobanTemplateEnterpriseRelation implements Serializable {
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getWxEnterpriseName() {
return wxEnterpriseName;
}
public void setWxEnterpriseName(String wxEnterpriseName) {
this.wxEnterpriseName = wxEnterpriseName;
}
}
\ No newline at end of file
......@@ -14,4 +14,6 @@ public interface TemplateEnterpriseRelatedService {
void update(TemplateEnterpriseRelatedDTO dto);
List<TemplateEnterpriseRelatedDTO> listEnterpriseByParams(String applicationTemplateId, List<String> wxEnterpriseIds, String wxEnterpriseName);
}
......@@ -42,4 +42,10 @@ public class TemplateEnterpriseRelatedServiceImpl implements TemplateEnterpriseR
mapper.updateByPrimaryKeySelective(EntityUtil.changeEntityByJSON(TabHaobanTemplateEnterpriseRelation.class, dto));
}
@Override
public List<TemplateEnterpriseRelatedDTO> listEnterpriseByParams(String applicationTemplateId, List<String> wxEnterpriseIds,
String wxEnterpriseName) {
return EntityUtil.changeEntityListByJSON(TemplateEnterpriseRelatedDTO.class, mapper.listEnterpriseByParams(applicationTemplateId,wxEnterpriseIds,wxEnterpriseName));
}
}
package com.gic.haoban.manage.service.service.out.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.manage.api.dto.ApplicationEnterpriseRelatedDTO;
import com.gic.haoban.manage.api.dto.ApplicationTemplateDTO;
import com.gic.haoban.manage.api.dto.EnterpriseDetailDTO;
import com.gic.haoban.manage.api.dto.TemplateEnterpriseRelatedDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.ApplicationTemplateApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.service.entity.TabHaobanTemplateApplicationRelated;
import com.gic.haoban.manage.service.service.ApplicationTemplateService;
import com.gic.haoban.manage.service.service.TemplateApplicationRelatedService;
import com.gic.haoban.manage.service.service.TemplateEnterpriseRelatedService;
import cn.hutool.core.collection.CollectionUtil;
@Service
public class ApplicationTemplateApiServiceImpl implements ApplicationTemplateApiService {
......@@ -27,6 +39,15 @@ public class ApplicationTemplateApiServiceImpl implements ApplicationTemplateApi
@Autowired
private TemplateApplicationRelatedService templateApplicationRelatedService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Override
public ApplicationTemplateDTO selectByTemplateName(String templateName) {
return applicationTemplateService.selectByTemplateName(templateName);
......@@ -84,11 +105,15 @@ public class ApplicationTemplateApiServiceImpl implements ApplicationTemplateApi
String[] wxEnterpriseIdArr = wxEnterpriseIds.split(",");
for (String wxEnterpriseId : wxEnterpriseIdArr) {
TemplateEnterpriseRelatedDTO dto = templateEnterpriseRelatedService.selectByWxEnterpriseId(wxEnterpriseId);
if(dto == null){
if(dto != null){
continue;
}
dto = new TemplateEnterpriseRelatedDTO();
dto.setWxEnterpriseId(wxEnterpriseId);
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
if(enterprise != null){
dto.setWxEnterpriseName(enterprise.getCorpName());
}
dto.setApplicationTemplateId(applicationTemplateId);
templateEnterpriseRelatedService.insert(dto);
}
......@@ -105,8 +130,22 @@ public class ApplicationTemplateApiServiceImpl implements ApplicationTemplateApi
}
@Override
public List<ApplicationEnterpriseRelatedDTO> listTemplateEnterprise(String applicationTemplateId) {
return EntityUtil.changeEntityListByJSON(ApplicationEnterpriseRelatedDTO.class, templateEnterpriseRelatedService.listEnterpriseByTemplateId(applicationTemplateId));
public List<ApplicationEnterpriseRelatedDTO> listTemplateEnterprise(String applicationTemplateId, String wxEnterpriseName, String enterpriseName) {
List<String> wxEnterpriseIds = new ArrayList<String>();
if(!StringUtils.isEmpty(enterpriseName)){
List<EnterpriseDTO> enterpriseNames = enterpriseService.getEnterpriseByName(enterpriseName);
if(CollectionUtil.isNotEmpty(enterpriseNames)){
List<String>enterpriseIds = enterpriseNames.stream().map(s->s.getEnterpriseId()).collect(Collectors.toList());
List<EnterpriseDetailDTO> wxEnterpriseIdDTOs = wxEnterpriseRelatedApiService.listEnterpriseByEnterpriseIds(enterpriseIds);
if(CollectionUtil.isNotEmpty(wxEnterpriseIdDTOs)){
wxEnterpriseIds = wxEnterpriseIdDTOs.stream().map(s->s.getWxEnterpriseId()).collect(Collectors.toList());
}
}
if(CollectionUtil.isEmpty(wxEnterpriseIds)){
wxEnterpriseIds = Arrays.asList("-9999");
}
}
return EntityUtil.changeEntityListByJSON(ApplicationEnterpriseRelatedDTO.class, templateEnterpriseRelatedService.listEnterpriseByParams(applicationTemplateId,wxEnterpriseIds,wxEnterpriseName));
}
@Override
......
......@@ -4,13 +4,14 @@
<resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabHaobanTemplateEnterpriseRelation" >
<id column="template_enterprise_relation_id" property="templateEnterpriseRelationId" jdbcType="VARCHAR" />
<result column="wx_enterprise_id" property="wxEnterpriseId" jdbcType="VARCHAR" />
<result column="wx_enterprise_name" property="wxEnterpriseName" jdbcType="VARCHAR" />
<result column="application_template_id" property="applicationTemplateId" jdbcType="VARCHAR" />
<result column="status_flag" property="statusFlag" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
template_enterprise_relation_id, wx_enterprise_id, application_template_id, status_flag,
template_enterprise_relation_id, wx_enterprise_id, application_template_id, status_flag,wx_enterprise_name
create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
......@@ -26,10 +27,10 @@
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanTemplateEnterpriseRelation" >
insert into tab_haoban_template_enterprise_relation (template_enterprise_relation_id, wx_enterprise_id,
application_template_id, status_flag, create_time,
update_time)
update_time,wx_enterprise_name)
values (#{templateEnterpriseRelationId,jdbcType=VARCHAR}, #{wxEnterpriseId,jdbcType=VARCHAR},
#{applicationTemplateId,jdbcType=VARCHAR}, #{statusFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
#{updateTime,jdbcType=TIMESTAMP},#{wxEnterpriseName,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanTemplateEnterpriseRelation" >
insert into tab_haoban_template_enterprise_relation
......@@ -40,6 +41,9 @@
<if test="wxEnterpriseId != null" >
wx_enterprise_id,
</if>
<if test="wxEnterpriseName != null" >
wx_enterprise_name,
</if>
<if test="applicationTemplateId != null" >
application_template_id,
</if>
......@@ -60,6 +64,9 @@
<if test="wxEnterpriseId != null" >
#{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="wxEnterpriseName != null" >
#{wxEnterpriseName,jdbcType=VARCHAR},
</if>
<if test="applicationTemplateId != null" >
#{applicationTemplateId,jdbcType=VARCHAR},
</if>
......@@ -80,6 +87,9 @@
<if test="wxEnterpriseId != null" >
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="wxEnterpriseName != null" >
wx_enterprise_name = #{wxEnterpriseName,jdbcType=VARCHAR},
</if>
<if test="applicationTemplateId != null" >
application_template_id = #{applicationTemplateId,jdbcType=VARCHAR},
</if>
......@@ -98,6 +108,7 @@
<update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.TabHaobanTemplateEnterpriseRelation" >
update tab_haoban_template_enterprise_relation
set wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
wx_enterprise_name = #{wxEnterpriseName,jdbcType=VARCHAR},
application_template_id = #{applicationTemplateId,jdbcType=VARCHAR},
status_flag = #{statusFlag,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
......@@ -120,4 +131,21 @@
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
and status_flag = 1
</select>
<select id="listEnterpriseByParams" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_template_enterprise_relation
where application_template_id = #{applicationTemplateId,jdbcType=VARCHAR}
and status_flag = 1
<if test="wxEnterpriseName != null and wxEnterpriseName != ''">
and wx_enterprise_name like CONCAT('%',#{wxEnterpriseName},'%')
</if>
<if test="wxEnterpriseIds != null and wxEnterpriseIds.size() > 0">
and wx_enterprise_id IN
<foreach collection="wxEnterpriseIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -85,8 +85,8 @@ public class ApplicationTemplateController extends WebBaseController{
}
@RequestMapping("view-template-enterprise")
public HaobanResponse viewTemplateEnterprise(String applicationTemplateId){
List<ApplicationEnterpriseRelatedDTO> list = applicationTemplateApiService.listTemplateEnterprise(applicationTemplateId);
public HaobanResponse viewTemplateEnterprise(String applicationTemplateId,String wxEnterpriseName,String enterpriseName){
List<ApplicationEnterpriseRelatedDTO> list = applicationTemplateApiService.listTemplateEnterprise(applicationTemplateId,wxEnterpriseName,enterpriseName);
return resultResponse(HaoBanErrCode.ERR_1,list);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment