嗨森逛服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hai-server/hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java

71 lines
2.2 KiB

package com.hai.service.impl;
import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.WxUtils;
import com.hai.dao.SecConfigMapper;
import com.hai.entity.SecConfig;
import com.hai.entity.SecConfigExample;
import com.hai.entity.SecDictionary;
import com.hai.entity.SecDictionaryExample;
import com.hai.service.ApiMerchantsService;
import com.hai.service.SecConfigService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
@Service("secConfigServiceImpl")
public class SecConfigServiceImpl implements SecConfigService {
@Resource
private SecConfigMapper secConfigMapper;
@Resource
private ApiMerchantsService apiMerchantsService;
@Override
public SecConfig findById(Integer id) {
return secConfigMapper.selectByPrimaryKey(id);
}
@Override
public void insertSecConfig(SecConfig secConfig) {
secConfigMapper.insert(secConfig);
}
@Override
public void updateSecConfig(SecConfig secConfig) {
secConfigMapper.updateByPrimaryKeySelective(secConfig);
}
@Override
public SecConfig findByCodeType(String codeType) {
SecConfigExample example = new SecConfigExample();
example.createCriteria().andCodeTypeEqualTo(codeType);
List<SecConfig> list = secConfigMapper.selectByExample(example);
if (list.size() > 0) {
return secConfigMapper.selectByExample(example).get(0);
}
return null;
}
@Override
public Boolean isConfig(String codeType, String codeValue) {
SecConfigExample example = new SecConfigExample();
example.createCriteria().andCodeTypeEqualTo(codeType).andCodeValueEqualTo(codeValue);
List<SecConfig> list = secConfigMapper.selectByExample(example);
return list.size() > 0;
}
@Override
public Boolean isSignVerify(Map<String, Object> map, String sign) throws Exception {
String signPost = WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5);
return signPost.equals(sign);
}
}