Browse Source

小程序首页接口提交

dev_shibei_match
yinzuomei 5 years ago
parent
commit
fc0913430f
  1. 20
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/HomeTemplateFormDTO.java
  2. 2
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/ComponentListByCustomerResultDTO.java
  3. 2
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/HomeDesignByCustomerResultDTO.java
  4. 57
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerHomeTemplateController.java
  5. 28
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerHomeTemplateFormDTO.java
  6. 55
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/CustomerHomeTemplateDao.java
  7. 30
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerHomeTemplateService.java
  8. 94
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerHomeTemplateServiceImpl.java
  9. 86
      epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/CustomerHomeTemplateDao.xml

20
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/HomeTemplateFormDTO.java

@ -0,0 +1,20 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 描述一下
*
* @author yinzuomei@elink-cn.com
* @date 2020/8/24 21:59
*/
@Data
public class HomeTemplateFormDTO implements Serializable {
/**
* 0居民端1政府端
*/
private String clientType;
}

2
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/ComponentListByCustomerResultDTO.java

@ -6,7 +6,7 @@ import java.io.Serializable;
import java.util.List;
/**
* @Description 运营端-客户定制化服务-获取客户可用组件列表-返参
* @Description 运营端-客户定制化服务-获取客户可用组件列表-返参 小程序首页默认配置/oper/customize/customerhometemplate/getcomponentlist返参也用的这个DTO
* @Author yinzuomei
* @Date 2020/3/11 12:57
*/

2
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/HomeDesignByCustomerResultDTO.java

@ -7,7 +7,7 @@ import java.util.List;
import java.util.Set;
/**
* @Description 运营端-客户定制化服务-获取客户首页配置的设计稿返参
* @Description 运营端-客户定制化服务-获取客户首页配置的设计稿返参 (/oper/customize/customerhometemplate/gethometemplate接口也用的此DTO)
* @Author yang
* @Date 2020/3/16 12:57
*/

57
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerHomeTemplateController.java

@ -17,6 +17,8 @@
package com.epmet.controller;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.ValidateException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
@ -26,8 +28,11 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.dto.CustomerHomeTemplateDTO;
import com.epmet.dto.result.ComponentListByCustomerResultDTO;
import com.epmet.dto.result.HomeDesignByCustomerResultDTO;
import com.epmet.excel.CustomerHomeTemplateExcel;
import com.epmet.service.CustomerHomeTemplateService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -91,4 +96,56 @@ public class CustomerHomeTemplateController {
ExcelUtils.exportExcelToTarget(response, null, list, CustomerHomeTemplateExcel.class);
}
/**
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.ComponentListByCustomerResultDTO>
* @param params clientType 所属端0.居民端1.领导端
* @author yinzuomei
* @description 获取可用组件列表
* @Date 2020/8/24 21:15
**/
@PostMapping("getcomponentlist")
public Result<ComponentListByCustomerResultDTO> getComponetList(@RequestParam Map<String, Object> params) {
String clientType= (String) params.get("clientType");
if(StringUtils.isBlank(clientType)){
throw new ValidateException("clientType不能为空");
}
if(!NumConstant.ZERO_STR.equals(clientType)&&!NumConstant.ONE_STR.equals(clientType)){
throw new ValidateException("所属端类型0.居民端,1.政府端");
}
return new Result<ComponentListByCustomerResultDTO>().ok(customerHomeTemplateService.getComponentListByCustomer(clientType));
}
/**
* @param params clientType 所属端0.居民端1.领导端
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.HomeDesignByCustomerResultDTO>
* @author yinzuomei
* @description 获取小程序首页配置
* @Date 2020/8/24 22:06
**/
@PostMapping("gethometemplate")
public Result<HomeDesignByCustomerResultDTO> getHomeTemplate(@RequestParam Map<String, Object> params) {
String clientType = (String) params.get("clientType");
if (StringUtils.isBlank(clientType)) {
throw new ValidateException("clientType不能为空");
}
if (!NumConstant.ZERO_STR.equals(clientType) && !NumConstant.ONE_STR.equals(clientType)) {
throw new ValidateException("所属端类型0.居民端,1.政府端");
}
return new Result<HomeDesignByCustomerResultDTO>().ok(customerHomeTemplateService.getHomeTemplate(clientType));
}
/**
* @return com.epmet.commons.tools.utils.Result
* @param formDTO
* @author yinzuomei
* @description 保存小程序首页配置
* @Date 2020/8/24 22:19
**/
@PostMapping("savecustomerhometemplate")
public Result saveCustomerHomeTemplate(@RequestBody CustomerHomeTemplateFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO);
customerHomeTemplateService.saveCustomerHomeTemplate(formDTO);
return new Result();
}
}

28
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerHomeTemplateFormDTO.java

@ -0,0 +1,28 @@
package com.epmet.controller;
import com.epmet.dto.form.HomeComponentFormDTO;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* 保存小程序首页配置 入参DTO
*
* @author yinzuomei@elink-cn.com
* @date 2020/8/24 22:18
*/
@Data
public class CustomerHomeTemplateFormDTO implements Serializable {
/**
* 所属端类型 0:居民端 1:政府端
*/
@NotBlank(message = "所属端类型不能为空")
private String clientType;
/**
* 组件集合
*/
private List<HomeComponentFormDTO> componentList;
}

55
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/CustomerHomeTemplateDao.java

@ -18,11 +18,18 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.ComponentListByCustomerFormDTO;
import com.epmet.dto.result.CommonComponentDesignResultDTO;
import com.epmet.dto.result.CommonComponentResultDTO;
import com.epmet.dto.result.FunctionComponentResultDTO;
import com.epmet.entity.CustomerHomeTemplateEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 客户首页模板表
* 客户首页模板表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-10
@ -30,4 +37,50 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CustomerHomeTemplateDao extends BaseDao<CustomerHomeTemplateEntity> {
/**
* @param clientType 所属端类型0.居民端1.政府端
* @return java.util.List<com.epmet.dto.result.CommonComponentResultDTO>
* @author yinzuomei
* @description 通用组件列表
* @Date 2020/8/24 21:30
**/
List<CommonComponentResultDTO> selectListCommonComponent(String clientType);
/**
* @return java.util.List<com.epmet.dto.result.FunctionComponentResultDTO>
* @author yinzuomei
* @description 功能组件列表以功能分组
* @Date 2020/8/24 21:30
**/
List<FunctionComponentResultDTO> selectListFunction();
/**
* @param functionId
* @param clientType
* @return java.util.List<com.epmet.dto.result.CommonComponentResultDTO>
* @author yinzuomei
* @description 根据功能所属端查询功能组件列表
* @Date 2020/8/24 21:56
**/
List<CommonComponentResultDTO> selectListFunctionComponent(@Param("functionId") String functionId,
@Param("clientType") String clientType);
/**
* @return java.util.List<com.epmet.dto.result.CommonComponentDesignResultDTO>
* @param clientType 所属端0.居民端1.领导端
* @author yinzuomei
* @description 获取小程序首页配置
* @Date 2020/8/24 22:12
**/
List<CommonComponentDesignResultDTO> selectCustomerTemplate(String clientType);
/**
* @return int
* @param clientType
* @param userId
* @author yinzuomei
* @description 删除某一端的默认配置
* @Date 2020/8/24 22:35
**/
int deleteByClientType(@Param("clientType") String clientType,@Param("userId") String userId);
}

30
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerHomeTemplateService.java

@ -19,7 +19,10 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.controller.CustomerHomeTemplateFormDTO;
import com.epmet.dto.CustomerHomeTemplateDTO;
import com.epmet.dto.result.ComponentListByCustomerResultDTO;
import com.epmet.dto.result.HomeDesignByCustomerResultDTO;
import com.epmet.entity.CustomerHomeTemplateEntity;
import java.util.List;
@ -101,4 +104,31 @@ public interface CustomerHomeTemplateService extends BaseService<CustomerHomeTem
* @return java.util.List<com.epmet.dto.CustomerHomeTemplateDTO>
*/
List<CustomerHomeTemplateDTO> getTemplateByClient(Integer client);
/**
* @return com.epmet.dto.result.ComponentListByCustomerResultDTO
* @param clientType
* @author yinzuomei
* @description 获取可用组件列表
* @Date 2020/8/24 21:16
**/
ComponentListByCustomerResultDTO getComponentListByCustomer(String clientType);
/**
* @return com.epmet.dto.result.HomeDesignByCustomerResultDTO
* @param clientType 所属端0.居民端1.领导端
* @author yinzuomei
* @description
* @Date 2020/8/24 22:06
**/
HomeDesignByCustomerResultDTO getHomeTemplate(String clientType);
/**
* @return void
* @param formDTO
* @author yinzuomei
* @description 保存小程序首页配置
* @Date 2020/8/24 22:20
**/
void saveCustomerHomeTemplate(CustomerHomeTemplateFormDTO formDTO);
}

94
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerHomeTemplateServiceImpl.java

@ -21,10 +21,20 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.OperCustomizeConstant;
import com.epmet.constant.ReginConstant;
import com.epmet.controller.CustomerHomeTemplateFormDTO;
import com.epmet.dao.CustomerHomeTemplateDao;
import com.epmet.dto.CustomerHomeTemplateDTO;
import com.epmet.dto.form.HomeComponentFormDTO;
import com.epmet.dto.result.CommonComponentDesignResultDTO;
import com.epmet.dto.result.ComponentListByCustomerResultDTO;
import com.epmet.dto.result.FunctionComponentResultDTO;
import com.epmet.dto.result.HomeDesignByCustomerResultDTO;
import com.epmet.entity.CustomerHomeTemplateEntity;
import com.epmet.redis.CustomerHomeTemplateRedis;
import com.epmet.service.CustomerHomeTemplateService;
@ -33,6 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -48,7 +59,8 @@ public class CustomerHomeTemplateServiceImpl extends BaseServiceImpl<CustomerHom
@Autowired
private CustomerHomeTemplateRedis customerHomeTemplateRedis;
@Autowired
private LoginUserUtil loginUserUtil;
@Override
public PageData<CustomerHomeTemplateDTO> page(Map<String, Object> params) {
IPage<CustomerHomeTemplateEntity> page = baseDao.selectPage(
@ -108,4 +120,84 @@ public class CustomerHomeTemplateServiceImpl extends BaseServiceImpl<CustomerHom
return ConvertUtils.sourceToTarget(baseDao.selectList(wrapper), CustomerHomeTemplateDTO.class);
}
/**
* @param clientType
* @return com.epmet.dto.result.ComponentListByCustomerResultDTO
* @author yinzuomei
* @description 获取可用组件列表
* @Date 2020/8/24 21:16
**/
@Override
public ComponentListByCustomerResultDTO getComponentListByCustomer(String clientType) {
ComponentListByCustomerResultDTO resultDTO = new ComponentListByCustomerResultDTO();
resultDTO.setCommonList(baseDao.selectListCommonComponent(clientType));
List<FunctionComponentResultDTO> functionList = baseDao.selectListFunction();
for (FunctionComponentResultDTO function : functionList) {
function.setComponentList(baseDao.selectListFunctionComponent(function.getFunctionId(), clientType));
}
resultDTO.setFunctionList(functionList);
return resultDTO;
}
/**
* @param clientType 所属端0.居民端1.领导端
* @return com.epmet.dto.result.HomeDesignByCustomerResultDTO
* @author yinzuomei
* @description
* @Date 2020/8/24 22:06
**/
@Override
public HomeDesignByCustomerResultDTO getHomeTemplate(String clientType) {
HomeDesignByCustomerResultDTO resultDTO = new HomeDesignByCustomerResultDTO();
//根据客户id,所属端获取客户首页配置的设计稿
List<CommonComponentDesignResultDTO> list = baseDao.selectCustomerTemplate(clientType);
List<CommonComponentDesignResultDTO> titleList = new ArrayList<>();
List<CommonComponentDesignResultDTO> topList = new ArrayList<>();
List<CommonComponentDesignResultDTO> functionList = new ArrayList<>();
List<CommonComponentDesignResultDTO> floatingList = new ArrayList<>();
//使用过的组件集合
List<String> usedComponent = new ArrayList<>();
for (CommonComponentDesignResultDTO c : list) {
usedComponent.add(c.getComponentId());
//所属区域:0.标题区、1.置顶区、2.功能区、3.悬浮区
if (ReginConstant.TITLE_LIST.equals(c.getRegion())) {
titleList.add(c);
} else if (ReginConstant.TOP_LIST.equals(c.getRegion())) {
topList.add(c);
} else if (ReginConstant.FUNCTION_LIST.equals(c.getRegion())) {
functionList.add(c);
} else if (ReginConstant.FLOATING_LIST.equals(c.getRegion())) {
floatingList.add(c);
}
}
resultDTO.setTitleList(titleList);
resultDTO.setTopList(topList);
resultDTO.setFloatingList(floatingList);
resultDTO.setFunctionList(functionList);
resultDTO.setUsedComponentIdList(usedComponent);
return resultDTO;
}
/**
* @param formDTO
* @return void
* @author yinzuomei
* @description 保存小程序首页配置
* @Date 2020/8/24 22:20
**/
@Override
public void saveCustomerHomeTemplate(CustomerHomeTemplateFormDTO formDTO) {
int deletedNum = baseDao.deleteByClientType(formDTO.getClientType(), loginUserUtil.getLoginUserId());
for (HomeComponentFormDTO homeComponentFormDTO : formDTO.getComponentList()) {
CustomerHomeTemplateDTO customerHomeTemplateDTO = new CustomerHomeTemplateDTO();
customerHomeTemplateDTO.setComponentId(homeComponentFormDTO.getComponentId());
customerHomeTemplateDTO.setClientType(Integer.valueOf(formDTO.getClientType()));
customerHomeTemplateDTO.setRegion(homeComponentFormDTO.getRegion());
customerHomeTemplateDTO.setConfiguration(homeComponentFormDTO.getConfiguration());
customerHomeTemplateDTO.setDemoData(homeComponentFormDTO.getDemoData());
customerHomeTemplateDTO.setDisplayOrder(homeComponentFormDTO.getDisplayOrder());
save(customerHomeTemplateDTO);
}
}
}

86
epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/CustomerHomeTemplateDao.xml

@ -18,5 +18,91 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<!-- 通用组件列表查询 -->
<select id="selectListCommonComponent" parameterType="java.lang.String"
resultType="com.epmet.dto.result.CommonComponentResultDTO">
SELECT
hc.id AS component_id,
hc.COMPONENT_NAME,
hc.COMPONENT_FRONT_ID,
hc.CONFIGURATION,
hc.DEMO_DATA,
hc.CONFIGURATION_DESCRIPTION,
hc.REGION
FROM
home_component hc
WHERE
hc.DEL_FLAG = '0'
AND hc.CONPONENT_TYPE = '0'
<if test='clientType != "" and clientType != null'>
AND hc.CLIENT_TYPE = #{clientType}
</if>
ORDER BY
CONVERT ( hc.COMPONENT_NAME USING gbk ) ASC
</select>
<!-- 功能组件列表查询 -->
<select id="selectListFunction" resultType="com.epmet.dto.result.FunctionComponentResultDTO">
SELECT
f.id as FUNCTION_ID,
f.FUNCTION_NAME
FROM
`FUNCTION` f
where f.DEL_FLAG='0'
ORDER BY CONVERT ( F.FUNCTION_NAME USING gbk ) ASC
</select>
<!-- 根据功能,所属端,查询功能组件列表 -->
<select id="selectListFunctionComponent" parameterType="map" resultType="com.epmet.dto.result.CommonComponentResultDTO">
SELECT
hc.id AS component_id,
hc.COMPONENT_NAME,
hc.COMPONENT_FRONT_ID,
hc.CONFIGURATION,
hc.DEMO_DATA,
hc.CONFIGURATION_DESCRIPTION,
hc.REGION
FROM
home_component hc
WHERE
hc.DEL_FLAG = '0'
AND hc.CONPONENT_TYPE = '1'
<if test='clientType != "" and clientType != null'>
AND hc.CLIENT_TYPE = #{clientType}
</if>
<if test='functionId != "" and functionId != null'>
and hc.FUNCTION_ID=#{functionId}
</if>
ORDER BY
CONVERT ( hc.COMPONENT_NAME USING gbk ) ASC
</select>
<!-- 获取小程序首页配置 -->
<select id="selectCustomerTemplate" parameterType="java.lang.String" resultType="com.epmet.dto.result.CommonComponentDesignResultDTO">
SELECT
cht.COMPONENT_ID,
hc.COMPONENT_NAME,
hc.COMPONENT_FRONT_ID,
hc.CONFIGURATION_DESCRIPTION,
cht.REGION,
cht.CONFIGURATION,
cht.DEMO_DATA,
cht.DISPLAY_ORDER
FROM
customer_home_template cht
LEFT JOIN home_component hc ON ( cht.COMPONENT_ID = hc.id )
WHERE
cht.DEL_FLAG = '0'
AND cht.CLIENT_TYPE =#{clientType}
ORDER BY cht.REGION DESC,cht.DISPLAY_ORDER ASC
</select>
<delete id="deleteByClientType" parameterType="map">
UPDATE customer_home_template
SET DEL_FLAG = '1',
UPDATED_BY = #{userId},
UPDATED_TIME = NOW()
WHERE
CLIENT_TYPE = #{clientType}
</delete>
</mapper>
Loading…
Cancel
Save