• missfresh问题记录


    一、基本信息

    1、登陆机器    ssh lina02@mjump.missfresh.net -p2222

    二、问题

    1、分页问题:job_id为空时能查询出来(笛卡尔乘积),需要加上AND res.job_id IS NOT NULL AND task.job_id IS NOT NULL AND res.job_id !='' AND task.job_id !=''

        <resultMap id="dtoMap" type="com.mryx.matrix.codeanalyzer.dto.CodeScanTaskDto">
            <id column="id" property="id" jdbcType="INTEGER"/>
            <association property="codeScanResult" javaType="com.mryx.matrix.codeanalyzer.domain.CodeScanResult">
                <id column="id" property="id" jdbcType="INTEGER"/>
                <result column="blocker" property="blocker" jdbcType="INTEGER"/>
                <result column="critical" property="critical" jdbcType="INTEGER"/>
                <result column="major" property="major" jdbcType="INTEGER"/>
                <result column="minor" property="minor" jdbcType="INTEGER"/>
                <result column="info" property="info" jdbcType="INTEGER"/>
                <result column="status" property="status" jdbcType="INTEGER"/>
                <result column="blockerResultUrl" property="blockerResultUrl" jdbcType="VARCHAR"/>
                <result column="criticalResultUrl" property="criticalResultUrl" jdbcType="VARCHAR"/>
                <result column="majorResultUrl" property="majorResultUrl" jdbcType="VARCHAR"/>
            </association>
            <association property="projectCodeScanTask" javaType="com.mryx.matrix.codeanalyzer.domain.ProjectCodeScanTask">
                <id column="id" property="id" jdbcType="INTEGER"/>
                <result column="task_name" property="taskName" jdbcType="VARCHAR"/>
                <result column="app_code" property="appCode" jdbcType="VARCHAR"/>
                <result column="mode_of_scan" property="modeOfScan" jdbcType="SMALLINT"/>
                <result column="app_branch" property="appBranch" jdbcType="VARCHAR"/>
                <result column="user_name" property="userName" jdbcType="VARCHAR"/>
                <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
            </association>
        </resultMap>
    
        <sql id="conditions">
            <if test="id != null ">and id = #{id,jdbcType=INTEGER}</if>
            <if test="taskName != null and taskName != '' ">and task_name like '%${taskName}%'</if>
            <if test="appCode != null and appCode != '' ">and app_code like '%${appCode}%'</if>
            <if test="modeOfScan != null ">and mode_of_scan = #{modeOfScan,jdbcType=INTEGER}</if>
            <if test="appBranch != null and appBranch != '' ">and app_branch = #{appBranch,jdbcType=VARCHAR}</if>
            <if test="baseVersion != null and baseVersion != '' ">and base_version = #{baseVersion,jdbcType=INTEGER}</if>
            <if test="compareVersion != null and compareVersion != '' ">and compare_version =
                #{compareVersion,jdbcType=VARCHAR}
            </if>
            <if test="timeTrigger != null and timeTrigger != '' ">and time_trigger = #{timeTrigger,jdbcType=TIMESTAMP}</if>
            <if test="userName != null and userName != '' ">and user_name = #{userName,jdbcType=VARCHAR}</if>
            <if test="createTime != null and createTime != '' ">and create_time = #{createTime,jdbcType=TIMESTAMP}</if>
            <if test="updateTime != null and updateTime != '' ">and update_time = #{updateTime,jdbcType=TIMESTAMP}</if>
        </sql>
    
        <select id="getCodeScanTask" resultMap="dtoMap"
                parameterType="com.mryx.matrix.codeanalyzer.domain.ProjectCodeScanTask">
            SELECT task.id,task.task_name,task.app_code,task.mode_of_scan,task.app_branch,task.user_name,task.update_time,
            res.blocker,res.critical,res.major,res.minor,res.info,res.status,res.blocker_result_url,res.critical_result_url,res.major_result_url
            FROM project_codescan_task AS task INNER JOIN code_scan_result AS res ON task.job_id=res.job_id
            WHERE 1=1 AND res.job_id IS NOT NULL AND task.job_id IS NOT NULL AND res.job_id !='' AND task.job_id !=''
            <include refid="conditions"/>
            ORDER BY task.id DESC
            limit #{startOfPage},#{pageSize}
        </select>
    
        <!-- 分页查询总数 -->
        <select id="pageTotal" resultType="java.lang.Integer"
                parameterType="com.mryx.matrix.codeanalyzer.domain.ProjectCodeScanTask">
            SELECT count(*)
            FROM project_codescan_task AS task INNER JOIN code_scan_result AS res ON task.job_id=res.job_id
            WHERE 1=1 AND res.job_id IS NOT NULL AND task.job_id IS NOT NULL AND res.job_id !='' AND task.job_id !=''
            <include refid="conditions"/>
        </select>
    

    2、insert数据库问题: 字段属性有NOT NULL属性,mapper文件中的sql语句没有为该字段写值,导致插入不了数据库,字段需要有DEFAULT属性

    3、实体类中的属性是驼峰命名的时候,mapper中的sql语句需要使用resultMap

        <resultMap id="sonarMap" type="com.mryx.matrix.codeanalyzer.domain.CodeScanResult">
            <id column="id" property="id" jdbcType="INTEGER"/>
            <result column="task_name" property="taskName" jdbcType="VARCHAR"/>
            <result column="app_code" property="appCode" jdbcType="VARCHAR"/>
            <result column="type_of_scan" property="typeOfScan" jdbcType="SMALLINT"/>
            <result column="mode_of_scan" property="modeOfScan" jdbcType="SMALLINT"/>
            <result column="code_branch" property="codeBranch" jdbcType="VARCHAR"/>
            <result column="user_name" property="userName" jdbcType="VARCHAR"/>
            <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
            <result column="blocker" property="blocker" jdbcType="INTEGER"/>
            <result column="critical" property="critical" jdbcType="INTEGER"/>
            <result column="major" property="major" jdbcType="INTEGER"/>
            <result column="minor" property="minor" jdbcType="INTEGER"/>
            <result column="info" property="info" jdbcType="INTEGER"/>
            <result column="status" property="status" jdbcType="INTEGER"/>
            <result column="blocker_result_url" property="blockerResultUrl" jdbcType="VARCHAR"/>
            <result column="critical_result_url" property="criticalResultUrl" jdbcType="VARCHAR"/>
            <result column="major_result_url" property="majorResultUrl" jdbcType="VARCHAR"/>
        </resultMap>
    
        <!-- 分页查询 -->
        <select id="getCodeScanTask" resultMap="sonarMap"
                resultType="com.mryx.matrix.codeanalyzer.domain.CodeScanResult">
            SELECT
            id,task_name,app_code,type_of_scan,mode_of_scan,code_branch,user_name,update_time,
            blocker,critical,major,minor,info,status,blocker_result_url,critical_result_url,major_result_url
            FROM code_scan_result WHERE manual_or_automatic != 0
            <include refid="conditions"/>
            ORDER BY id DESC
            limit #{startOfPage},#{pageSize}
        </select>
    

      发邮件:https://www.cnblogs.com/sea520/p/4565273.html

  • 相关阅读:
    A. Ivan the Fool and the Probability Theory
    关于消除“输出中最后的一个空格”问题
    半文件式输入中一种常见的输入方式
    持续输入问题
    汉诺塔问题
    给定两个正整数,求它们的最大公约数。
    第三届全国高校绿色计算机大赛(初赛题目)
    第三届全国高校绿色计算机大赛(初赛题目)
    C++中的输入及其原理简析
    流感传染
  • 原文地址:https://www.cnblogs.com/xidian2014/p/9971953.html
Copyright © 2020-2023  润新知