Commit 03ed8a21 by 陶光胜

加log

parent f3a37a8e
......@@ -101,6 +101,14 @@ public interface StoreDictApiService {
*/
ServiceResponse saveStoreField(Integer enterpriseId, String value, int type, Integer userId);
/** @Description: 列表筛选字段配置
* @author taogs
* @Date 18:16 2020/3/11
* @Param
* @return
*/
ServiceResponse saveStoreField(Integer enterpriseId, String values, Integer userId);
/**
* 查询列表/筛选属性光支持 列表数据
* @param enterpriseId
......
......@@ -22,8 +22,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service("storeDictApiService")
public class StoreDictApiServiceImpl implements StoreDictApiService {
......@@ -162,35 +165,46 @@ public class StoreDictApiServiceImpl implements StoreDictApiService {
String key = StoreRedisKeyUtils.getStoreFieldKey(enterpriseId, Integer.valueOf(value));
String keyc = StoreRedisKeyUtils.getStoreFieldKeyC(enterpriseId, "");
if(type == 1){ //新增
TabStoreField tabStoreField = this.storeFieldService.getStoreFieldById(Integer.valueOf(value));
}else {
}
return ServiceResponse.success();
}
@Override
public ServiceResponse saveStoreField(Integer enterpriseId, String values, Integer userId) {
String keyc = StoreRedisKeyUtils.getStoreFieldKeyC(enterpriseId, "");
List<String> existList = this.storeDictService.listStoreField(enterpriseId);
List<String> newList = Arrays.asList(values.split(","));
List<String> add = newList.stream().filter(s -> !existList.contains(s)).collect(Collectors.toList());
List<String> del = existList.stream().filter(s -> !newList.contains(s)).collect(Collectors.toList());
add.forEach(s -> {
TabStoreField tabStoreField = this.storeFieldService.getStoreFieldById(Integer.valueOf(s));
if(tabStoreField.getStoreFieldType() != null && tabStoreField.getStoreFieldType().intValue() == 1){
return EnterpriseServiceResponse.failure(ErrorCode.NOT_SUPPORT);
}
List<String> list = this.storeDictService.listStoreField(enterpriseId);
for(String s : list){
if(s.equals(value)){
return ServiceResponse.failure(ErrorCode.DATA_EXISTS.getCode(), ErrorCode.DATA_EXISTS.getMsg());
}
return;
}
TabStoreDict tabStoreDict = new TabStoreDict();
tabStoreDict.setEnterpriseId(enterpriseId);
tabStoreDict.setCreateTime(new Date());
tabStoreDict.setValue(value);
tabStoreDict.setValue(s);
this.storeDictService.saveStoreField(tabStoreDict);
String key = StoreRedisKeyUtils.getStoreFieldKey(enterpriseId, Integer.valueOf(s));
Object existObj = RedisUtil.getCache(key);
if(existObj == null){
for(int i=1; i<=10; i++){
Object obj = RedisUtil.getCache(keyc+"c"+i);
if(obj == null){
RedisUtil.setCache(keyc+"c"+i, value);
RedisUtil.setCache(keyc+"c"+i, s);
RedisUtil.setCache(key, "c"+i);
break;
}
}
}
}else {
this.storeDictService.deleteStoreField(enterpriseId, value);
});
del.forEach(s -> {
String key = StoreRedisKeyUtils.getStoreFieldKey(enterpriseId, Integer.valueOf(s));
this.storeDictService.deleteStoreField(enterpriseId, s);
Object c = RedisUtil.getCache(key);
String storeListSourceKey = StoreRedisKeyUtils.getStoreListSourceKey(enterpriseId, userId);
if(c != null){
......@@ -211,10 +225,19 @@ public class StoreDictApiServiceImpl implements StoreDictApiService {
}
}
RedisUtil.delCache(key);
}
});
return ServiceResponse.success();
}
public static void main(String[] args){
List<String> existList = Arrays.asList("1","2", "3");
List<String> newList = Arrays.asList("2", "3", "4");
List<String> add = newList.stream().filter(s -> !existList.contains(s)).collect(Collectors.toList());
List<String> del = existList.stream().filter(s -> !newList.contains(s)).collect(Collectors.toList());
System.out.println(add);
System.out.println(del);
}
@Override
public ServiceResponse<List<String>> listStoreFieldDictValue(Integer enterpriseId) {
return ServiceResponse.success(this.storeDictService.listStoreField(enterpriseId));
......
......@@ -137,15 +137,22 @@ public class StoreDictController {
}
}
/** @Description: 列表筛选支持配置
* @author taogs
* @Date 18:15 2020/3/11
* @Param
* @return
*/
@RequestMapping("relevance-storefield")
@ResponseBody
public RestResponse setStoreField(String value, int type){
public RestResponse setStoreField(String values){
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
Integer userId = UserDetailUtils.getUserDetail().getUserId();
if(StringUtils.isBlank(value)){
if(StringUtils.isBlank(values)){
return EnterpriseRestResponse.failure(com.gic.enterprise.error.ErrorCode.MISS_PARAMETER);
}
ServiceResponse serviceResponse = this.storeDictApiService.saveStoreField(enterpriseId, value, type, userId);
ServiceResponse serviceResponse = this.storeDictApiService.saveStoreField(enterpriseId, values, userId);
if(serviceResponse.isSuccess()){
LogUtils.createLog("自定义字段列表支持筛选配置", "自定义字段");
return RestResponse.success();
......
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