Commit 7414d82c by guojuxing

小程序页面装修默认数据调整

parent 0d17c7b3
......@@ -22,7 +22,7 @@ public enum AppletPageTypeEnum {
/**
* 积分服务
*/
INTEGRAL_SERVICE(4, "积分服务", 1, 0),
INTEGRAL_SERVICE(4, "积分服务", 1, 1),
/**
* 积分成就
*/
......
......@@ -43,6 +43,13 @@ public interface AppletCustomPageApiService {
ServiceResponse<Page<AppletCustomPageDTO>> page(AppletPageQO params);
/**
* 查询默认数据
* @param pageType
* @return
*/
ServiceResponse<AppletCustomPageDTO> getDefault(Integer pageType);
/**
* 页面详情
* @Title: getDetailByPageId

* @Description:
......
......@@ -94,6 +94,9 @@ public class AppletCustomPageServiceImpl implements AppletCustomPageService{
@Transactional(rollbackFor = Exception.class)
@Override
public int disableFetch(Integer enterpriseId, Integer appType, String appId, Integer pageType) {
if (enterpriseId == -1) {
return 0;
}
return tabAppletCustomPageMapper.disableFetch(enterpriseId, appType, appId, pageType);
}
......
......@@ -123,8 +123,8 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
int count = appletCustomPageService.count(enterpriseId, appType, appId, pageType);
validPageNumberLimit(pageType, count, isAddOperation);
validPageStatus(pageId, pageType, count, saveType, record, enterpriseId, appType, appId);
//发布一条的页面类型逻辑
validPageStatus(pageType, saveType, enterpriseId, appType, appId);
//新增或者编辑
if (pageId == null) {
record.setDeleteFlag(0);
......@@ -200,22 +200,8 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
}
}
private void validPageStatus(Integer pageId, Integer pageType, Integer pageCount, Integer saveType,
TabAppletCustomPage record,
private void validPageStatus(Integer pageType, Integer saveType,
Integer enterpriseId, Integer appType, String appId) {
//如果是有默认数据的类型(会员中心),第一条记录,即使saveType = 2,也自动变成1
if (AppletPageTypeEnum.hasDefault(pageType)) {
//查询记录
boolean isNeedSet = false;
if (pageId == null && pageCount < 1) {
isNeedSet = true;
} else if (pageId != null && pageCount == 1) {
isNeedSet = true;
}
if (isNeedSet) {
record.setStatus(1);
}
}
//判断,如果是会员中心/客服页面,只能发布一条记录,自定义页面可以多条
if (saveType.intValue() == 1) {
//保存并发布
......@@ -320,10 +306,9 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
List<AppletCustomPageDTO> list = resultPage.getResult();
//如果查不到数据,使用默认的数据
boolean isDefault = CollectionUtils.isEmpty(list) && params.getCurrentPage().intValue() == 1
&& params.getPageType() != null
&& AppletPageTypeEnum.MEMBER_CENTER.getCode() == params.getPageType().intValue();
&& AppletPageTypeEnum.hasDefault(params.getPageType());
if (isDefault) {
TabAppletCustomPage record = appletCustomPageService.getDefault(AppletPageTypeEnum.MEMBER_CENTER.getCode());
TabAppletCustomPage record = getDefaultPage(params.getPageType());
list = new ArrayList<>();
list.add(EntityUtil.changeEntityNew(AppletCustomPageDTO.class, record));
resultPage.setResult(list);
......@@ -334,6 +319,12 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
}
@Override
public ServiceResponse<AppletCustomPageDTO> getDefault(Integer pageType) {
TabAppletCustomPage record = getDefaultPage(pageType);
return ServiceResponse.success(EntityUtil.changeEntityNew(AppletCustomPageDTO.class, record));
}
@Override
public ServiceResponse<AppletCustomPageDTO> getDetailByPageId(Integer pageId) {
TabAppletCustomPage record = exist(pageId);
AppletCustomPageDTO dto = EntityUtil.changeEntityNew(AppletCustomPageDTO.class, record);
......@@ -368,8 +359,7 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
Integer pageId;
if (CollectionUtils.isEmpty(record) && AppletPageTypeEnum.hasDefault(pageType)) {
//如果为空,则查询默认数据
TabAppletCustomPage defaultData = appletCustomPageService
.getDefault(pageType);
TabAppletCustomPage defaultData = getDefaultPage(pageType);
dto = EntityUtil.changeEntityNew(AppletCustomPageDTO.class, defaultData);
//查询组件数据
pageId = defaultData.getPageId();
......@@ -391,13 +381,16 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
public ServiceResponse<List<AppletCustomPageDTO>> listIntegralServiceByAppId(Integer enterpriseId, Integer appType,
String appId) {
List<TabAppletCustomPage> record = getPageListByAppId(enterpriseId, appType, appId, AppletPageTypeEnum.INTEGRAL_SERVICE.getCode());
if (CollectionUtils.isEmpty(record)) {
TabAppletCustomPage defaultPage = getDefaultPage(AppletPageTypeEnum.INTEGRAL_SERVICE.getCode());
record = new ArrayList<>();
record.add(defaultPage);
}
List<AppletCustomPageDTO> list = EntityUtil.changeEntityListNew(AppletCustomPageDTO.class, record);
if (CollectionUtils.isNotEmpty(record)) {
//填充组件信息
for (AppletCustomPageDTO temp : list) {
//最多15条数据,循环可以接受
temp.setComponentStr(getComponentByPageId(temp.getPageId()));
}
//填充组件信息
for (AppletCustomPageDTO temp : list) {
//最多15条数据,循环可以接受
temp.setComponentStr(getComponentByPageId(temp.getPageId()));
}
return ServiceResponse.success(list);
}
......@@ -408,6 +401,7 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
if (!AppletPageTypeEnum.needCrowdWidget(record.getPageType())) {
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "页面种类错误,该页面没有序号");
}
validDefaultPage(record.getEnterpriseId());
boolean serialNumberLimit = serialNumber > 999;
if (serialNumberLimit) {
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "序号不能超过999");
......@@ -447,6 +441,7 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
if (record.getStatus().intValue() == 1) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "已是发布状态");
}
validDefaultPage(record.getEnterpriseId());
if (AppletPageTypeEnum.isOnlyOneCode(record.getPageType())) {
//把其他的数据状态改为关闭
appletCustomPageService.disableFetch(record.getEnterpriseId(), record.getAppType(), record.getAppId(),
......@@ -462,10 +457,7 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
if (record.getStatus().intValue() != 1) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "已是关闭状态");
}
if (AppletPageTypeEnum.isOnlyOneCode(record.getPageType())) {
//如果只有一条,则不能关闭
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "不能关闭,必须有一条是发布状态");
}
validDefaultPage(record.getEnterpriseId());
appletCustomPageService.updateStatus(pageId, 2);
return ServiceResponse.success(record.getTitle());
}
......@@ -473,6 +465,7 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
@Override
public ServiceResponse<String> delete(Integer pageId) {
TabAppletCustomPage record = exist(pageId);
validDefaultPage(record.getEnterpriseId());
if (record.getStatus().intValue() == 1) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "发布状态不能删除");
}
......@@ -492,10 +485,8 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
if (!StringUtils.isNumeric(pageId)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "页面id错误,数据格式非法");
}
TabAppletCustomPage record = appletCustomPageService.getByPageId(Integer.parseInt(pageId));
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "页面ID错误,查无数据");
}
TabAppletCustomPage record = exist(Integer.parseInt(pageId));
validDefaultPage(record.getEnterpriseId());
if (record.getStatus().intValue() == 1) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "发布状态不能删除");
}
......@@ -606,4 +597,21 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
}
}
public TabAppletCustomPage getDefaultPage(Integer pageType) {
if (!AppletPageTypeEnum.hasDefault(pageType)) {
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "该页面类型没有默认数据");
}
TabAppletCustomPage record = appletCustomPageService.getDefault(pageType);
if (pageType == null) {
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "还未配置默认数据");
}
return record;
}
public void validDefaultPage(Integer enterpriseId) {
if (enterpriseId == -1) {
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "默认数据不能操作");
}
}
}
......@@ -366,7 +366,7 @@
<include refid="Blob_Column_List" />
from tab_applet_custom_page
where status = 1
and delete_flag
and delete_flag = 0
and enterprise_id = -1
and page_type = #{pageType}
</select>
......
......@@ -5,8 +5,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.download.utils.OperationResultUtils;
import com.gic.enterprise.dto.AppletCustomPageDTO;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.web.vo.ShelfCouponVO;
import com.gic.marketing.api.service.coupon.CouponShelfApiService;
......@@ -59,7 +61,20 @@ public class CustomPageController {
public RestResponse listPage(AppletPageQO params) {
params.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
params.setOrderByStr(AppletPageOrderByEnum.getOrderBySqlByCode(params.getOrderByCode()));
return ResultControllerUtils.commonPageResult(appletCustomPageApiService.page(params), AppletPageVO.class);
ServiceResponse<Page<AppletCustomPageDTO>> response = appletCustomPageApiService.page(params);
if (AppletPageTypeEnum.hasDefault(params.getPageType())) {
Page<AppletCustomPageDTO> page = response.getResult();
if (page != null) {
List<AppletCustomPageDTO> list = page.getResult();
ServiceResponse<AppletCustomPageDTO> defaultPage = appletCustomPageApiService.getDefault(params.getPageType());
if (CollectionUtils.isNotEmpty(list)) {
list.add(defaultPage.getResult());
}
}
}
return ResultControllerUtils.commonPageResult(response, AppletPageVO.class);
}
@RequestMapping("/get-detail")
......
......@@ -14,6 +14,16 @@ public class AppletPageVO implements Serializable{
private static final long serialVersionUID = -4803325917597244314L;
/**
* 1:是 0:否
*/
private Integer defaultPage;
/**
*
*/
private Integer enterpriseId;
/**
*
*/
private Integer pageId;
......@@ -120,6 +130,27 @@ public class AppletPageVO implements Serializable{
return this;
}
public Integer getDefaultPage() {
if (enterpriseId == -1) {
return 1;
}
return 0;
}
public AppletPageVO setDefaultPage(Integer defaultPage) {
this.defaultPage = defaultPage;
return this;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public AppletPageVO setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
return this;
}
@Override
public String toString() {
return "AppletPageVO{" +
......@@ -131,6 +162,7 @@ public class AppletPageVO implements Serializable{
", crowdWidgetId=" + crowdWidgetId +
", serialNumber=" + serialNumber +
", crowdWidgetType=" + crowdWidgetType +
", defaultPage=" + defaultPage +
'}';
}
}
package com.gic.operation.web.controller;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.service.AppletCustomPageApiService;
import com.gic.enterprise.utils.ResultControllerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/custom-page")
public class AppletCustomPageController {
@Autowired
private AppletCustomPageApiService appletCustomPageApiService;
@RequestMapping("/save-default-page")
public RestResponse saveDefaultPage(String param, Integer pageId, Integer saveType, Integer appType, String appId) {
Integer enterpriseId = -1;
return ResultControllerUtils.commonResult(
appletCustomPageApiService.saveOrUpdate(param, pageId, enterpriseId, saveType, appType, appId));
}
}
......@@ -99,4 +99,7 @@
<dubbo:reference interface="com.gic.enterprise.service.TableSettingApiService" id="tableSettingApiService" timeout="6000" />
<dubbo:reference interface="com.gic.enterprise.service.CustomSettingApiService" id="customSettingApiService" timeout="6000" />
<dubbo:reference interface="com.gic.enterprise.service.SmsTemplateInitApiService" id="smsTemplateInitApiService" timeout="6000" />
<!--自定义页面装修-->
<dubbo:reference interface="com.gic.enterprise.service.AppletCustomPageApiService" id="appletCustomPageApiService" timeout="6000" />
</beans>
\ No newline at end of file
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