O 乛 2021-04-02 14:59 采纳率: 20%
浏览 68

把Controller层中对数据库的操作往service层中移动出现问题

这是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这个参数 没法知道是哪个文件 问题加上就一直报错

  • 写回答

5条回答 默认 最新

  • O 乛 2021-04-02 15:00
    关注

    抱着个错误

     

    nested exception is org.apache.ibatis.binding.BindingException: Parameter 'taskType' not found. Available parameters are [custmoerDownRecordDO, task_type, param1, param2]

    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程