Commit 5e3e54ff authored by eddie.woo's avatar eddie.woo

1.add longi api;2.add dao;3.add filter

parent e6c04417
......@@ -192,7 +192,7 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
<version>1.11</version>
</dependency>
<dependency>
......
......@@ -25,7 +25,7 @@ public class SwaggerConfig {
@Bean
public Docket petApi() {
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
.apis(RequestHandlerSelectors.basePackage("pwc.taxtech.atms.controller"))
.apis(RequestHandlerSelectors.basePackage("pwc.taxtech.atms.controller.*"))
.paths(PathSelectors.regex("/api/.*")).build()
.globalOperationParameters(buildGlobalOperationParameters());
......
package pwc.taxtech.atms.common.util;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.TreeMap;
public class SignatureUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(SignatureUtil.class);
public static final String SIGN_NONCE_STR = "nonceStr"; //随机数
public static final String SIGN_TIMESTAMP = "timestamp"; //时间戳
public static final String SIGN_APP_ID = "appId"; //应用ID
public static final String SIGN_SIGNATURE = "signature"; //生成的签名
public static final String SIGN_API = "api"; //接口地址
public static final String SIGN_API_TOKEN = "apiToken"; //密钥
public static final String AND = "=";
public static final String SPLIT = "&";
public static final int TIME_RANGE = 120;//2分钟
/**
* 生成签名
*
* @param key 密钥
* @param api 请求地址
* @param nonceStr 随机字符串
* @param timestamp 时间戳
* @return string
*/
public static String generate(String key, String api, String nonceStr, String timestamp) {
TreeMap<String, String> paramMap = new TreeMap<>();
paramMap.put(SIGN_API_TOKEN, key);
paramMap.put(SIGN_API, api);
paramMap.put(SIGN_NONCE_STR, nonceStr);
paramMap.put(SIGN_TIMESTAMP, timestamp);
StringBuilder sb = new StringBuilder();
paramMap.forEach((k, v) -> {
sb.append(k).append(AND).append(v).append(SPLIT);
});
String tmp = sb.substring(0, sb.length() - 1);
return DigestUtils.sha1Hex(tmp);
}
/**
* 校验签名
*
* @param key 密钥
* @param api 请求地址
* @param nonceStr 随机字符串
* @param timestamp 时间戳
* @param signature 接收的签名
* @return boolean
*/
public static boolean validate(String key, String api, String nonceStr, String timestamp, String signature) {
try {
int now = (int) (System.currentTimeMillis() / 1000);
int time = Integer.valueOf(timestamp);
if (now - time <= TIME_RANGE) {
return StringUtils.equals(signature, generate(key, api, nonceStr, timestamp));
}
} catch (Exception e) {
LOGGER.error("invalid signature.", e);
}
return false;
}
}
package pwc.taxtech.atms.controller.vendor;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.controller.BaseController;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vendor.LgItemDto;
import pwc.taxtech.atms.service.vendor.LongiService;
import java.util.List;
@RestController
@RequestMapping("/vendor/api/v1/lg")
public class LongiController extends BaseController {
@Autowired
private LongiService longiService;
@ApiOperation(value = "批量更新物料信息")
@RequestMapping(value = "updateItems", method = RequestMethod.POST)
public OperationResultDto updateItems(@RequestBody List<LgItemDto> lgItemDtoList) {
return OperationResultDto.success();
}
}
package pwc.taxtech.atms.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.entitiy.InputMaterialCategory;
import pwc.taxtech.atms.entitiy.InputMaterialCategoryExample;
@Mapper
public interface InputMaterialCategoryMapper extends MyMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_category
*
* @mbg.generated
*/
long countByExample(InputMaterialCategoryExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_category
*
* @mbg.generated
*/
int deleteByExample(InputMaterialCategoryExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_category
*
* @mbg.generated
*/
int deleteByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_category
*
* @mbg.generated
*/
int insert(InputMaterialCategory record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_category
*
* @mbg.generated
*/
int insertSelective(InputMaterialCategory record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_category
*
* @mbg.generated
*/
List<InputMaterialCategory> selectByExampleWithRowbounds(InputMaterialCategoryExample example, RowBounds rowBounds);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_category
*
* @mbg.generated
*/
List<InputMaterialCategory> selectByExample(InputMaterialCategoryExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_category
*
* @mbg.generated
*/
InputMaterialCategory selectByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_category
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") InputMaterialCategory record, @Param("example") InputMaterialCategoryExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_category
*
* @mbg.generated
*/
int updateByExample(@Param("record") InputMaterialCategory record, @Param("example") InputMaterialCategoryExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_category
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(InputMaterialCategory record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_category
*
* @mbg.generated
*/
int updateByPrimaryKey(InputMaterialCategory record);
}
\ No newline at end of file
package pwc.taxtech.atms.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.entitiy.InputMaterialItemCategory;
import pwc.taxtech.atms.entitiy.InputMaterialItemCategoryExample;
@Mapper
public interface InputMaterialItemCategoryMapper extends MyMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
long countByExample(InputMaterialItemCategoryExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
int deleteByExample(InputMaterialItemCategoryExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
int deleteByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
int insert(InputMaterialItemCategory record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
int insertSelective(InputMaterialItemCategory record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
List<InputMaterialItemCategory> selectByExampleWithRowbounds(InputMaterialItemCategoryExample example, RowBounds rowBounds);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
List<InputMaterialItemCategory> selectByExample(InputMaterialItemCategoryExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
InputMaterialItemCategory selectByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") InputMaterialItemCategory record, @Param("example") InputMaterialItemCategoryExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
int updateByExample(@Param("record") InputMaterialItemCategory record, @Param("example") InputMaterialItemCategoryExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(InputMaterialItemCategory record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
int updateByPrimaryKey(InputMaterialItemCategory record);
}
\ No newline at end of file
package pwc.taxtech.atms.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.entitiy.InputMaterialItem;
import pwc.taxtech.atms.entitiy.InputMaterialItemExample;
@Mapper
public interface InputMaterialItemMapper extends MyMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item
*
* @mbg.generated
*/
long countByExample(InputMaterialItemExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item
*
* @mbg.generated
*/
int deleteByExample(InputMaterialItemExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item
*
* @mbg.generated
*/
int deleteByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item
*
* @mbg.generated
*/
int insert(InputMaterialItem record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item
*
* @mbg.generated
*/
int insertSelective(InputMaterialItem record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item
*
* @mbg.generated
*/
List<InputMaterialItem> selectByExampleWithRowbounds(InputMaterialItemExample example, RowBounds rowBounds);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item
*
* @mbg.generated
*/
List<InputMaterialItem> selectByExample(InputMaterialItemExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item
*
* @mbg.generated
*/
InputMaterialItem selectByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") InputMaterialItem record, @Param("example") InputMaterialItemExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item
*
* @mbg.generated
*/
int updateByExample(@Param("record") InputMaterialItem record, @Param("example") InputMaterialItemExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(InputMaterialItem record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item
*
* @mbg.generated
*/
int updateByPrimaryKey(InputMaterialItem record);
}
\ No newline at end of file
package pwc.taxtech.atms.dto.vendor;
import pwc.taxtech.atms.entitiy.InputMaterialCategory;
import pwc.taxtech.atms.entitiy.InputMaterialItem;
import java.util.List;
public class LgItemDto extends InputMaterialItem {
private List<InputMaterialCategory> categorySets;
public List<InputMaterialCategory> getCategorySets() {
return categorySets;
}
public void setCategorySets(List<InputMaterialCategory> categorySets) {
this.categorySets = categorySets;
}
}
package pwc.taxtech.atms.entitiy;
import java.io.Serializable;
/**
*
* This class was generated by MyBatis Generator.
* This class corresponds to the database table input_material_category
*
* @mbg.generated do_not_delete_during_merge
*/
public class InputMaterialCategory extends BaseEntity implements Serializable {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column input_material_category.id
*
* @mbg.generated
*/
private Long id;
/**
* Database Column Remarks:
* 类别集代码
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column input_material_category.category_set_code
*
* @mbg.generated
*/
private String categorySetCode;
/**
* Database Column Remarks:
* 类别集名称(ZHS)
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column input_material_category.category_set_name_zhs
*
* @mbg.generated
*/
private String categorySetNameZhs;
/**
* Database Column Remarks:
* 类别集名称(US)
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column input_material_category.category_set_name_us
*
* @mbg.generated
*/
private String categorySetNameUs;
/**
* Database Column Remarks:
* 类别值
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column input_material_category.set_value
*
* @mbg.generated
*/
private String setValue;
/**
* Database Column Remarks:
* 类别说明-ZHS
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column input_material_category.set_value_desc_zhs
*
* @mbg.generated
*/
private String setValueDescZhs;
/**
* Database Column Remarks:
* 类别说明-US
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column input_material_category.set_value_desc_us
*
* @mbg.generated
*/
private String setValueDescUs;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table input_material_category
*
* @mbg.generated
*/
private static final long serialVersionUID = 1L;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column input_material_category.id
*
* @return the value of input_material_category.id
*
* @mbg.generated
*/
public Long getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column input_material_category.id
*
* @param id the value for input_material_category.id
*
* @mbg.generated
*/
public void setId(Long id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column input_material_category.category_set_code
*
* @return the value of input_material_category.category_set_code
*
* @mbg.generated
*/
public String getCategorySetCode() {
return categorySetCode;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column input_material_category.category_set_code
*
* @param categorySetCode the value for input_material_category.category_set_code
*
* @mbg.generated
*/
public void setCategorySetCode(String categorySetCode) {
this.categorySetCode = categorySetCode == null ? null : categorySetCode.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column input_material_category.category_set_name_zhs
*
* @return the value of input_material_category.category_set_name_zhs
*
* @mbg.generated
*/
public String getCategorySetNameZhs() {
return categorySetNameZhs;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column input_material_category.category_set_name_zhs
*
* @param categorySetNameZhs the value for input_material_category.category_set_name_zhs
*
* @mbg.generated
*/
public void setCategorySetNameZhs(String categorySetNameZhs) {
this.categorySetNameZhs = categorySetNameZhs == null ? null : categorySetNameZhs.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column input_material_category.category_set_name_us
*
* @return the value of input_material_category.category_set_name_us
*
* @mbg.generated
*/
public String getCategorySetNameUs() {
return categorySetNameUs;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column input_material_category.category_set_name_us
*
* @param categorySetNameUs the value for input_material_category.category_set_name_us
*
* @mbg.generated
*/
public void setCategorySetNameUs(String categorySetNameUs) {
this.categorySetNameUs = categorySetNameUs == null ? null : categorySetNameUs.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column input_material_category.set_value
*
* @return the value of input_material_category.set_value
*
* @mbg.generated
*/
public String getSetValue() {
return setValue;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column input_material_category.set_value
*
* @param setValue the value for input_material_category.set_value
*
* @mbg.generated
*/
public void setSetValue(String setValue) {
this.setValue = setValue == null ? null : setValue.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column input_material_category.set_value_desc_zhs
*
* @return the value of input_material_category.set_value_desc_zhs
*
* @mbg.generated
*/
public String getSetValueDescZhs() {
return setValueDescZhs;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column input_material_category.set_value_desc_zhs
*
* @param setValueDescZhs the value for input_material_category.set_value_desc_zhs
*
* @mbg.generated
*/
public void setSetValueDescZhs(String setValueDescZhs) {
this.setValueDescZhs = setValueDescZhs == null ? null : setValueDescZhs.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column input_material_category.set_value_desc_us
*
* @return the value of input_material_category.set_value_desc_us
*
* @mbg.generated
*/
public String getSetValueDescUs() {
return setValueDescUs;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column input_material_category.set_value_desc_us
*
* @param setValueDescUs the value for input_material_category.set_value_desc_us
*
* @mbg.generated
*/
public void setSetValueDescUs(String setValueDescUs) {
this.setValueDescUs = setValueDescUs == null ? null : setValueDescUs.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_category
*
* @mbg.generated
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", categorySetCode=").append(categorySetCode);
sb.append(", categorySetNameZhs=").append(categorySetNameZhs);
sb.append(", categorySetNameUs=").append(categorySetNameUs);
sb.append(", setValue=").append(setValue);
sb.append(", setValueDescZhs=").append(setValueDescZhs);
sb.append(", setValueDescUs=").append(setValueDescUs);
sb.append("]");
return sb.toString();
}
}
\ No newline at end of file
package pwc.taxtech.atms.entitiy;
import java.io.Serializable;
/**
*
* This class was generated by MyBatis Generator.
* This class corresponds to the database table input_material_item_category
*
* @mbg.generated do_not_delete_during_merge
*/
public class InputMaterialItemCategory extends BaseEntity implements Serializable {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column input_material_item_category.id
*
* @mbg.generated
*/
private Long id;
/**
* Database Column Remarks:
* 物料ID
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column input_material_item_category.item_id
*
* @mbg.generated
*/
private Long itemId;
/**
* Database Column Remarks:
* 品类ID
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column input_material_item_category.category_id
*
* @mbg.generated
*/
private Long categoryId;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
private static final long serialVersionUID = 1L;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column input_material_item_category.id
*
* @return the value of input_material_item_category.id
*
* @mbg.generated
*/
public Long getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column input_material_item_category.id
*
* @param id the value for input_material_item_category.id
*
* @mbg.generated
*/
public void setId(Long id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column input_material_item_category.item_id
*
* @return the value of input_material_item_category.item_id
*
* @mbg.generated
*/
public Long getItemId() {
return itemId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column input_material_item_category.item_id
*
* @param itemId the value for input_material_item_category.item_id
*
* @mbg.generated
*/
public void setItemId(Long itemId) {
this.itemId = itemId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column input_material_item_category.category_id
*
* @return the value of input_material_item_category.category_id
*
* @mbg.generated
*/
public Long getCategoryId() {
return categoryId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column input_material_item_category.category_id
*
* @param categoryId the value for input_material_item_category.category_id
*
* @mbg.generated
*/
public void setCategoryId(Long categoryId) {
this.categoryId = categoryId;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table input_material_item_category
*
* @mbg.generated
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", itemId=").append(itemId);
sb.append(", categoryId=").append(categoryId);
sb.append("]");
return sb.toString();
}
}
\ No newline at end of file
package pwc.taxtech.atms.security.vendor;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pwc.taxtech.atms.common.util.SignatureUtil;
import pwc.taxtech.atms.dto.OperationResultDto;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Map;
public class ApiSignatureFilter implements Filter {
private static final Logger LOGGER = LoggerFactory.getLogger(ApiSignatureFilter.class);
private static String INVALID_RESULT = JSON.toJSONString(OperationResultDto.error("invalid api signature"));
private static Map<String, String> keyMap = new ImmutableMap.Builder<String, String>()
.put("longi", "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJsb25naSIsImV4cCI6MzI0ODczMDE1NjAsImlhdCI6MTUyOTkyMjM2MSwibmJmIjoxNTI5OTIxNzYxLCJqdGkiOiIyNURFRDEyRi0yRTBBLTRERDUtQjkyOS0xRjlCOTI1QzA2MjciLCJhcHBJZCI6ImxvbmdpIn0.fPddvBGXjViEXNrYA7BesndVjM5eYHA0cX_sKZprHbIasD75Sn8vWNVKb5hMDk3wk3M34k7VgkTFHnpj9BF2uw")
.build();
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
try {
HttpServletRequest request = (HttpServletRequest) servletRequest;
String appId = StringUtils.defaultString(request.getParameter(SignatureUtil.SIGN_APP_ID));
String nonceStr = StringUtils.defaultString(request.getParameter(SignatureUtil.SIGN_NONCE_STR));
String timestamp = StringUtils.defaultString(request.getParameter(SignatureUtil.SIGN_TIMESTAMP));
String signature = StringUtils.defaultString(request.getParameter(SignatureUtil.SIGN_SIGNATURE));
String api = StringUtils.defaultString(request.getParameter(SignatureUtil.SIGN_API));
if (StringUtils.isAnyBlank(appId, signature, timestamp, nonceStr, api)) {
servletResponse.getWriter().print(INVALID_RESULT);
return;
}
String key = keyMap.get(appId);
if (StringUtils.isBlank(key)) {
servletResponse.getWriter().print(INVALID_RESULT);
return;
}
if (SignatureUtil.validate(key, api, nonceStr, timestamp, signature)) {
filterChain.doFilter(servletRequest, servletResponse);
}
} catch (Exception e) {
LOGGER.error("invalid api signature: {}", JSON.toJSONString(servletRequest.getParameterMap()), e);
}
servletResponse.getWriter().print(INVALID_RESULT);
}
@Override
public void destroy() {
}
}
package pwc.taxtech.atms.service.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import pwc.taxtech.atms.common.AtmsApiSettings;
import pwc.taxtech.atms.common.AuthUserHelper;
import pwc.taxtech.atms.service.OperationLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import pwc.taxtech.atms.common.AtmsApiSettings;
import pwc.taxtech.atms.common.AuthUserHelper;
import pwc.taxtech.atms.service.OperationLogService;
public class BaseService {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
......
package pwc.taxtech.atms.service.vendor;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.ServiceException;
import pwc.taxtech.atms.dto.vendor.LgItemDto;
import pwc.taxtech.atms.service.impl.BaseService;
import java.util.List;
@Service
public class LongiService extends BaseService {
/**
* 更新物料信息
*
* @param itemDtoList list
* @throws ServiceException ex
*/
public void updateItems(List<LgItemDto> itemDtoList) throws ServiceException {
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pwc.taxtech.atms.dao.InputMaterialItemCategoryMapper">
<resultMap id="BaseResultMap" type="pwc.taxtech.atms.entitiy.InputMaterialItemCategory">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="item_id" jdbcType="BIGINT" property="itemId" />
<result column="category_id" jdbcType="BIGINT" property="categoryId" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, item_id, category_id
</sql>
<select id="selectByExample" parameterType="pwc.taxtech.atms.entitiy.InputMaterialItemCategoryExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from input_material_item_category
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from input_material_item_category
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from input_material_item_category
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="pwc.taxtech.atms.entitiy.InputMaterialItemCategoryExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from input_material_item_category
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="pwc.taxtech.atms.entitiy.InputMaterialItemCategory">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into input_material_item_category (id, item_id, category_id
)
values (#{id,jdbcType=BIGINT}, #{itemId,jdbcType=BIGINT}, #{categoryId,jdbcType=BIGINT}
)
</insert>
<insert id="insertSelective" parameterType="pwc.taxtech.atms.entitiy.InputMaterialItemCategory">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into input_material_item_category
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="itemId != null">
item_id,
</if>
<if test="categoryId != null">
category_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="itemId != null">
#{itemId,jdbcType=BIGINT},
</if>
<if test="categoryId != null">
#{categoryId,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="pwc.taxtech.atms.entitiy.InputMaterialItemCategoryExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from input_material_item_category
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update input_material_item_category
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.itemId != null">
item_id = #{record.itemId,jdbcType=BIGINT},
</if>
<if test="record.categoryId != null">
category_id = #{record.categoryId,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update input_material_item_category
set id = #{record.id,jdbcType=BIGINT},
item_id = #{record.itemId,jdbcType=BIGINT},
category_id = #{record.categoryId,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="pwc.taxtech.atms.entitiy.InputMaterialItemCategory">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update input_material_item_category
<set>
<if test="itemId != null">
item_id = #{itemId,jdbcType=BIGINT},
</if>
<if test="categoryId != null">
category_id = #{categoryId,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="pwc.taxtech.atms.entitiy.InputMaterialItemCategory">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update input_material_item_category
set item_id = #{itemId,jdbcType=BIGINT},
category_id = #{categoryId,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="selectByExampleWithRowbounds" parameterType="pwc.taxtech.atms.entitiy.InputMaterialItemCategoryExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from input_material_item_category
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -25,6 +25,10 @@
</param-value>
</context-param>
<filter>
<filter-name>apiSignatureFilter</filter-name>
<filter-class>pwc.taxtech.atms.security.vendor.ApiSignatureFilter</filter-class>
</filter>
<filter>
<filter-name>corsFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
......@@ -46,6 +50,10 @@
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>apiSignatureFilter</filter-name>
<url-pattern>/vendor/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>corsFilter</filter-name>
<url-pattern>/*</url-pattern>
......
package pwc.taxtech.atms.security;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.junit.Test;
import org.nutz.lang.Times;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.dto.vendor.LgItemDto;
import pwc.taxtech.atms.entitiy.InputMaterialCategory;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class JwtGneratorTest {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2999);
Date now = new Date();
JwtBuilder jwtBuilder = Jwts.builder();
// 设置Subject为登录用户名
jwtBuilder.setSubject("longi");
jwtBuilder.setExpiration(calendar.getTime());
jwtBuilder.setIssuedAt(now);
// 设置时钟误差偏移量,即10分钟
Date notBefore = Times.nextSecond(now, -600);
jwtBuilder.setNotBefore(notBefore);
jwtBuilder.setId(CommonUtils.getUUID());
jwtBuilder.claim("appId", "longi");
// 设置body.username为数据库用户名
jwtBuilder.signWith(SignatureAlgorithm.HS512, "TXppQjFlZFBSbnJzMHc0Tg==");
System.out.println(jwtBuilder.compact());
}
@Test
public void tt() {
LgItemDto item = new LgItemDto();
InputMaterialCategory category = new InputMaterialCategory();
List<InputMaterialCategory> list = new ArrayList<>();
list.add(category);
item.setCategorySets(list);
System.out.println(JSON.toJSONString(item, SerializerFeature.WriteNullStringAsEmpty));
}
}
......@@ -97,9 +97,21 @@
<!--<columnOverride column="is_red_invoice" javaType="java.lang.Boolean"/>-->
<!--</table>-->
<table tableName="api_cache" domainObjectName="ApiCache">
<!--<table tableName="api_cache" domainObjectName="ApiCache">-->
<!--<property name="ignoreQualifiersAtRuntime" value="true"/>-->
<!--<columnOverride column="source_type" javaType="java.lang.Integer"/>-->
<!--</table>-->
<table tableName="input_material_category" domainObjectName="InputMaterialCategory">
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
<table tableName="input_material_item" domainObjectName="InputMaterialItem">
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
<table tableName="input_material_item_category" domainObjectName="InputMaterialItemCategory">
<property name="ignoreQualifiersAtRuntime" value="true"/>
<columnOverride column="source_type" javaType="java.lang.Integer"/>
</table>
</context>
......
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