Commit 5f09a6cd by guojuxing

pmd

parent b7a2c732
......@@ -12,13 +12,6 @@ import java.util.List;
* @date 2021/7/27 10:03 AM

*/
public interface TabTableSettingFieldMapper {
/**
* 根据主键删除
*
* @param fieldId 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer fieldId);
/**
* 插入一条记录
......
......@@ -12,14 +12,6 @@ import org.apache.ibatis.annotations.Param;
*/
public interface TabTableSettingMapper {
/**
* 根据主键删除
*
* @param tableId 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer tableId);
/**
* 插入一条记录
*
* @param record 实体对象
......
......@@ -124,27 +124,7 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
validPageNumberLimit(pageType, count, isAddOperation);
//如果是有默认数据的类型(会员中心),第一条记录,即使saveType = 2,也自动变成1
if (AppletPageTypeEnum.hasDefault(pageType)) {
//查询记录
boolean isNeedSet = false;
if (pageId == null && count < 1) {
isNeedSet = true;
} else if (pageId != null && count == 1) {
isNeedSet = true;
}
if (isNeedSet) {
record.setStatus(1);
}
}
//判断,如果是会员中心/客服页面,只能发布一条记录,自定义页面可以多条
if (saveType.intValue() == 1) {
//保存并发布
if (AppletPageTypeEnum.isOnlyOneCode(pageType)) {
//把其他的数据状态改为关闭
appletCustomPageService.disableFetch(enterpriseId, appType, appId, pageType);
}
}
validPageStatus(pageId, pageType, count, saveType, record, enterpriseId, appType, appId);
//新增或者编辑
if (pageId == null) {
record.setDeleteFlag(0);
......@@ -205,6 +185,32 @@ public class AppletCustomPageApiServiceImpl implements AppletCustomPageApiServic
return ServiceResponse.success(pageId);
}
private void validPageStatus(Integer pageId, Integer pageType, Integer pageCount, Integer saveType,
TabAppletCustomPage record,
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) {
//保存并发布
if (AppletPageTypeEnum.isOnlyOneCode(pageType)) {
//把其他的数据状态改为关闭
appletCustomPageService.disableFetch(enterpriseId, appType, appId, pageType);
}
}
}
private ServiceResponse validParams(Integer enterpriseId, Integer saveType, Integer appType, String appId, String param){
//参数校验
if (enterpriseId == null) {
......
......@@ -10,6 +10,7 @@ import com.gic.enterprise.constant.Constants;
import com.gic.enterprise.dto.AppletCardDTO;
import com.gic.enterprise.dto.AppletMainCardDTO;
import com.gic.enterprise.entity.TabAppletDecorationConfig;
import com.gic.enterprise.exception.CommonException;
import com.gic.member.config.api.dto.MemberCardRelDTO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -258,19 +259,58 @@ public class AppletDecorationConfigApiServiceImpl implements AppletDecorationCon
needValidMap.put("数据资产-总积分", totalIntegral);
needValidMap.put("数据资产-卡券包", appletDataAssetArea.getCoupon());
needValidMap.put("数据资产-线下订单", order);
validParam(needValidMap, appletCardMap, totalIntegral, appletSubCardList, mainCardId, order, appletDataAssetArea);
//默认主卡
//签到
appletDataAssetArea.setSignIn(mainCardId.toString());
//会员成就
appletDataAssetArea.setMemberAchievement(mainCardId.toString());
//会员任务
appletDataAssetArea.setMemberTask(mainCardId.toString());
//关联卡组,全部的卡
dto.setOpenCardAuth(appletCardList.stream().map(e -> e.getCardConfigId().toString()).collect(Collectors.joining(",")));
Integer gpsDecisionCard = dto.getGpsDecisionCard();
if (gpsDecisionCard == null) {
//GPS智能判定卡 默认关闭
dto.setGpsDecisionCard(0);
} else {
if (gpsDecisionCard != 1 && gpsDecisionCard != 0) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "GPS智能判定卡数值非法");
}
}
//默认选中和主卡关联的店铺,不可编辑 //实时调用
ServiceResponse<ShopDTO> shopResult = getMainCardStore(appId, enterpriseId);
if (shopResult.isSuccess()) {
ShopDTO shopDTO = shopResult.getResult();
appletDataAssetArea.setMallOrder(shopDTO.getId().toString());
appletDataAssetArea.setMallOrderName(shopDTO.getName());
}
//数据资产设置
dto.setDataAssetArea(JSON.toJSONString(appletDataAssetArea));
dto.setAppletDataAssetArea(appletDataAssetArea);
return ServiceResponse.success();
}
private void validParam(Map<String, String> needValidMap, Map<String, List<AppletCardDTO>> appletCardMap,
String totalIntegral, List<String> appletSubCardList, Long mainCardId,
String order, AppletDataAssetAreaDTO appletDataAssetArea) {
ServiceResponse valueValid;
for (Map.Entry<String, String> entry : needValidMap.entrySet()) {
valueValid = validParamValue(entry.getKey(), entry.getValue(), appletCardMap);
if (!valueValid.isSuccess()) {
return ServiceResponse.failure(valueValid.getCode(), valueValid.getMessage());
throw new CommonException(valueValid.getCode(), valueValid.getMessage());
}
}
if (totalIntegral.split(Constants.COMMONSEPARATE).length > 1) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "数据资产-总积分只能选择一个");
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "数据资产-总积分只能选择一个");
}
if (!mainCardId.toString().equals(totalIntegral) && !appletSubCardList.contains(totalIntegral)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "数据资产-总积分只能选择小程序主卡或者主卡关联的平衡主卡");
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "数据资产-总积分只能选择小程序主卡或者主卡关联的平衡主卡");
}
//如果总积分选择主卡,则线下订单也是主卡,不可变更
if (mainCardId.toString().equals(totalIntegral)) {
appletDataAssetArea.setOrder(totalIntegral);
......@@ -288,39 +328,10 @@ public class AppletDecorationConfigApiServiceImpl implements AppletDecorationCon
boolean validOrder = Stream.of(order.split(","))
.anyMatch(e -> !subListSet.contains(e));
if (validOrder) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "数据资产-线下订单只能选择总积分小程序主卡关联的平衡组卡及其子卡");
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "数据资产-线下订单只能选择总积分小程序主卡关联的平衡组卡及其子卡");
}
}
}
//默认主卡
//签到
appletDataAssetArea.setSignIn(mainCardId.toString());
//会员成就
appletDataAssetArea.setMemberAchievement(mainCardId.toString());
//会员任务
appletDataAssetArea.setMemberTask(mainCardId.toString());
//关联卡组,全部的卡
dto.setOpenCardAuth(appletCardList.stream().map(e -> e.getCardConfigId().toString()).collect(Collectors.joining(",")));
Integer gpsDecisionCard = dto.getGpsDecisionCard();
if (gpsDecisionCard == null) {
//GPS智能判定卡 默认关闭
dto.setGpsDecisionCard(0);
} else {
if (gpsDecisionCard != 1 && gpsDecisionCard != 0) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "GPS智能判定卡数值非法");
}
}
//默认选中和主卡关联的店铺,不可编辑 //实时调用
ServiceResponse<ShopDTO> shopResult = getMainCardStore(appId, enterpriseId);
if (shopResult.isSuccess()) {
ShopDTO shopDTO = shopResult.getResult();
appletDataAssetArea.setMallOrder(shopDTO.getId().toString());
appletDataAssetArea.setMallOrderName(shopDTO.getName());
}
//数据资产设置
dto.setDataAssetArea(JSON.toJSONString(appletDataAssetArea));
dto.setAppletDataAssetArea(appletDataAssetArea);
return ServiceResponse.success();
}
private ServiceResponse validParamValue(String key, String value, Map<String, List<AppletCardDTO>> appletCardMap) {
......
......@@ -237,11 +237,11 @@ public class CustomSettingApiServiceImpl implements CustomSettingApiService {
private List<Criteria> getCriteriaList(Map<String, Object> map, TabTableSetting tableSetting){
List<TableSettingFieldDTO> fieldDTOS = tableSettingFieldService.listTableField(tableSetting.getTableId());
Map<String, TableSettingFieldDTO> fieldDtoMap = fieldDTOS.stream().collect(Collectors.toMap(TableSettingFieldDTO::getFieldKey, TableSettingFieldDTO -> TableSettingFieldDTO));
Map<String, TableSettingFieldDTO> fieldDtoMap = fieldDTOS.stream().collect(Collectors.toMap(TableSettingFieldDTO::getFieldKey, e -> e));
List<Criteria> criteriaList = new ArrayList<>();
map.forEach((k, v) -> {
Criteria criteria = null;
if(k.equals(PRIMARYKEY)){
if(PRIMARYKEY.equals(k)){
criteria = Criteria.where(k).eq(v);
} else {
if(fieldDtoMap.get(k).getFieldType().equals(FieldTypeEnum.STRING.getType())){
......
......@@ -8,6 +8,7 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Singleton;
import com.gic.commons.annotation.SkipNamingCheck;
import org.apache.curator.shaded.com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -32,7 +33,8 @@ public class ExecutorPoolSingleton {
executorService = new ThreadPoolExecutor(coreNum > 2 ? 2 : coreNum, maxProcessor,
60L, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>());
new SynchronousQueue<Runnable>(), new ThreadFactoryBuilder()
.setNameFormat("demo-pool-%d" + executeThreadNum ++ ).build());
}
}
......
......@@ -106,7 +106,7 @@ public class FileUtils {
out.close();//记得关闭资源
log.info("临时文件已生成 " + fileName + ".csv");
} catch (Exception e) {
e.printStackTrace();
log.info("临时文件已生成错误:{}", e.getMessage(), e);
}
}
......@@ -123,7 +123,7 @@ public class FileUtils {
try {
tmp.createNewFile();
} catch (IOException e) {
e.printStackTrace();
log.info("临时文件已生成错误:{}", e.getMessage(), e);
}
}
return tmp;
......
......@@ -21,10 +21,6 @@
from tab_table_setting_field
where field_id = #{fieldId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_table_setting_field
where field_id = #{fieldId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.enterprise.entity.TabTableSettingField">
insert into tab_table_setting_field (field_id, table_id, field_key,
field_name, field_type, create_time,
......
......@@ -35,10 +35,6 @@
from tab_table_setting
where table_id = #{tableId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_table_setting
where table_id = #{tableId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.enterprise.entity.TabTableSetting">
insert into tab_table_setting (table_id, table_name, save_ext_interface,
del_ext_interface, ext_interface, remark,
......
......@@ -6,7 +6,7 @@ import java.util.Date;
/**
* 配置
* @ClassName:
* @Description: 

* @Description: 

* @author guojuxing

* @date 2021/7/27 10:54 AM

*/
......
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