这是dao方法
int insertRecord(CustmoerDownRecordDO custmoerDownRecordDO,String taskType);
}
这是xml
<insert id="insertRecord" parameterType="com.yz.api.pojo.CustmoerDownRecordDO"> insert into custmoer_down_record(task_type,customer_id,file_info_id, bucket_name,object_name,gmt_create,created_by,gmt_modify) values ( #{taskType,jdbcType=VARCHAR}, #{customerId,jdbcType=VARCHAR}, #{fileInfoId,jdbcType=BIGINT}, #{bucketName,jdbcType=VARCHAR}, #{objectName,jdbcType=VARCHAR}, #{gmtCreate,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=VARCHAR}, #{gmtModify,jdbcType=TIMESTAMP} ) </insert>
这是service
public int insertRecord(CustmoerDownRecordDO custmoerDownRecord, String taskType) {
try {
//记录客户下载文件信息
FileInfoDO fileInfoMessage = fileInfoDao.select(taskType);
custmoerDownRecord.setTaskType(taskType);
custmoerDownRecord.setCustomerId(taskType);
custmoerDownRecord.setFileInfoId(fileInfoMessage.getId());
custmoerDownRecord.setBucketName((fileInfoMessage.getBucketName()));
custmoerDownRecord.setObjectName(fileInfoMessage.getObjectName());
custmoerDownRecord.setGmtCreate(fileInfoMessage.getGmtCreate());
custmoerDownRecord.setGmtModify(fileInfoMessage.getGmtModify());
custmoerDownRecordDao.insertRecord(custmoerDownRecord, taskType);
}catch(Exception e){
logger.error("记录用户下载文件异常",e);
}
return 0;
这是contorller
@Autowired
private ApiService apiService;
@RequestMapping("/api/v1")
public ResultJson selectByType(HttpServletRequest request,
HttpServletResponse response)throws Exception{
String key = request.getHeader(ParamConstants.X_ACCESS_LKEY);
String task_type = request.getHeader(ParamConstants.TASK_TYPE);
ResultJson result = null;
result = ResultJson.ok().data(apiService.selectByType(task_type));
CustmoerDownRecordDO custmoerDownRecordDO = new CustmoerDownRecordDO();
apiService.insertRecord(custmoerDownRecordDO,task_type);
return result;
大概就是我要根据http请求头里面的tasktype来判断用户下载的是哪文件 然后把一些属性拿出来记录一下
问题是insertRecord(CustmoerDownRecordDO custmoerDownRecord, String taskType)这个方法如果不传
tasktype这个参数 没法知道是哪个文件 问题加上就一直报错