Commit b08a6f35 by zhiwj

日志

parent 861a72cf
......@@ -5,6 +5,8 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.log.api.dto.SystemSetLogDTO;
import com.gic.log.api.service.LogApiService;
import com.gic.store.constant.StoreEnableOrDisAbleEnum;
import com.gic.store.constant.StoreFieldTypeEnum;
import com.gic.store.constant.StoreGroupConstant;
......@@ -22,6 +24,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -53,6 +56,8 @@ public class StoreApiServiceImpl implements StoreApiService {
private StoreStrategyService storeStrategyService;
@Autowired
private StoreFieldSelectService storeFieldSelectService;
@Autowired
private LogApiService logApiService;
@Override
@Transactional(rollbackFor = Exception.class)
......@@ -94,6 +99,14 @@ public class StoreApiServiceImpl implements StoreApiService {
delBusinessTimes = delBusinessTimeIds.stream().map(Integer::parseInt).collect(Collectors.toList());
}
storeBusinessTimeService.editStoreBusinessTime(storeDTO.getEnterpriseId(), storeDTO.getStoreId(), storeDTO.getBusinessTimeList(), delBusinessTimes);
// 写日志
SystemSetLogDTO systemSetLogDTO = new SystemSetLogDTO();
systemSetLogDTO.setEnterpriesId(storeDTO.getEnterpriseId() + "");
systemSetLogDTO.setLogTime(new Date());
systemSetLogDTO.setInterfaceName("com.gic.store.service.StoreApiService.saveOrUpdate");
systemSetLogDTO.setContent("门店信息变更");
systemSetLogDTO.setRelationId(storeDTO.getStoreId().longValue());
logApiService.saveSystemSetLog(systemSetLogDTO);
return ServiceResponse.success();
}
......
......@@ -5,6 +5,8 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GlobalInfo;
import com.gic.commons.util.PageHelperUtils;
import com.gic.log.api.dto.SystemSetLogDTO;
import com.gic.log.api.service.LogApiService;
import com.gic.store.dto.StoreBrandDTO;
import com.gic.store.entity.TabStoreBrand;
import com.gic.store.service.StoreBrandApiService;
......@@ -16,10 +18,15 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -40,8 +47,18 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService {
@Autowired
private StoreService storeService;
@Autowired
private LogApiService logApiService;
@Override
public ServiceResponse<Integer> saveOrUpdateStoreBrand(StoreBrandDTO storeBrandDTO) {
// 日志
SystemSetLogDTO systemSetLogDTO = new SystemSetLogDTO();
systemSetLogDTO.setEnterpriesId(storeBrandDTO.getEnterpriseId() + "");
systemSetLogDTO.setLogTime(new Date());
systemSetLogDTO.setInterfaceName("com.gic.store.service.StoreBrandApiService.saveOrUpdateStoreBrand");
Integer storeBrandId;
int brandCodeCount = storeBrandService.countByStoreBrandCode(storeBrandDTO.getEnterpriseId(), storeBrandDTO.getStoreBrandCode(), storeBrandDTO.getStoreBrandId());
if (brandCodeCount > 0) {
......@@ -54,15 +71,22 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService {
if (storeBrandDTO.getStoreBrandId() == null) {
// 新增
storeBrandId = storeBrandService.save(storeBrandDTO);
systemSetLogDTO.setContent("新增品牌, 品牌名:" + storeBrandDTO.getStoreBrandName());
} else {
// 编辑
storeBrandId = storeBrandDTO.getStoreBrandId();
// TabStoreBrand storeBrand = storeBrandService.getBrandById(storeBrandId);
Integer updateLine = storeBrandService.update(storeBrandDTO);
if (updateLine == 0) {
logger.warn("[storeBrandId ==> {}] 不存在", storeBrandDTO.getStoreBrandId());
return ServiceResponse.failure(ErrorCode.ERR_2.getCode(), "没找到要编辑的门店品牌");
}
}
// 写日志
systemSetLogDTO.setContent("门店信息变更");
logApiService.saveSystemSetLog(systemSetLogDTO);
return ServiceResponse.success(storeBrandId);
}
......@@ -141,4 +165,28 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService {
return ServiceResponse.success();
}
public static void main(String[] args) {
// todo 判断修改字段
HashMap<String, Object> propertyMap = new HashMap<>();
propertyMap.put("storeBrandName", "品牌名");
propertyMap.put("storeBrandCode", "品牌code");
StoreBrandDTO oldDTO = new StoreBrandDTO();
oldDTO.setStoreBrandName("123");
oldDTO.setStoreBrandCode("444");
StoreBrandDTO newDTO = new StoreBrandDTO();
newDTO.setStoreBrandName("456");
newDTO.setStoreBrandName("444");
final BeanWrapper oldDTOBean = new BeanWrapperImpl(oldDTO);
final BeanWrapper newDTOBean = new BeanWrapperImpl(newDTO);
PropertyDescriptor[] pds = oldDTOBean.getPropertyDescriptors();
for (PropertyDescriptor pd : pds) {
Object oldValue = oldDTOBean.getPropertyValue(pd.getName());
Object newValue = newDTOBean.getPropertyValue(pd.getName());
if (oldValue != null && newValue != null && !oldValue.equals(newValue)) {
System.out.println(propertyMap.get(pd.getName()) + " 从 " + oldValue + " 修改为 " + newValue);
}
}
}
}
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