kongdeqiang
2022-12-16 daf6a95086087ec99232eea8b4648b7541881f7c
增加service
5个文件已添加
212 ■■■■■ 已修改文件
src/main/java/com/wgcloud/mapper/FailureLoggingMapper.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/service/FailureLoggingService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/service/InspectionTaskService.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/service/TaskInfoService.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mybatis/mapper/FailureLoggingMapper.xml 125 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/mapper/FailureLoggingMapper.java
New file
@@ -0,0 +1,18 @@
package com.wgcloud.mapper;
import com.wgcloud.entity.FailureLogging;
import com.wgcloud.entity.WorkLogging;
import org.springframework.stereotype.Repository;
/**
 * @author kdq
 * @version 1.0.0
 * @ClassName FailureLoggingMapper.java
 * @Description TODO
 * @createTime 2022年12月16日 17:32:00
 */
@Repository
public interface FailureLoggingMapper {
    public void save(FailureLogging failureLogging) throws Exception;
}
src/main/java/com/wgcloud/service/FailureLoggingService.java
New file
@@ -0,0 +1,14 @@
package com.wgcloud.service;
import org.springframework.stereotype.Service;
/**
 * @author kdq
 * @version 1.0.0
 * @ClassName FailureLoggingService.java
 * @Description TODO
 * @createTime 2022年12月16日 17:32:00
 */
@Service
public class FailureLoggingService {
}
src/main/java/com/wgcloud/service/InspectionTaskService.java
New file
@@ -0,0 +1,24 @@
package com.wgcloud.service;
import com.wgcloud.entity.InspectionTask;
import com.wgcloud.entity.TaskInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * @author kdq
 * @version 1.0.0
 * @ClassName InspectionTaskService.java
 * @Description TODO
 * @createTime 2022年12月16日 16:52:00
 */
@Service
public class InspectionTaskService {
    @Autowired
    private InspectionTaskService inspectionTaskService;
    public void save(InspectionTask inspectionTask) throws Exception {
        inspectionTaskService.save(inspectionTask);
    }
}
src/main/java/com/wgcloud/service/TaskInfoService.java
New file
@@ -0,0 +1,31 @@
package com.wgcloud.service;
import com.wgcloud.entity.FailureLogging;
import com.wgcloud.entity.TaskInfo;
import com.wgcloud.mapper.TaskInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * @author kdq
 * @version 1.0.0
 * @ClassName TaskInfoService.java
 * @Description TODO
 * @createTime 2022年12月16日 15:50:00
 */
@Service
public class TaskInfoService {
    @Autowired
    private TaskInfoMapper taskInfoMapper;
    public void save(TaskInfo taskInfo) throws Exception {
        taskInfoMapper.save(taskInfo);
    }
    public void saveAll(List<TaskInfo> taskInfos) throws Exception {
        taskInfoMapper.insertList(taskInfos);
    }
}
src/main/resources/mybatis/mapper/FailureLoggingMapper.xml
New file
@@ -0,0 +1,125 @@
<?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="com.wgcloud.mapper.FailureLoggingMapper">
    <resultMap id="resultMap" type="com.wgcloud.entity.FailureLogging">
        <id column="ID" property="id" jdbcType="CHAR" />
        <result column="OLD_DEVICE_NAME" property="oldDeviceName" jdbcType="CHAR" />
        <result column="OLD_DEVICE_IP" property="oldDeviceIp" jdbcType="CHAR" />
        <result column="OLD_DEVICE_MODEL" property="oldDeviceModel" jdbcType="CHAR" />
        <result column="NEW_DEVICE_NAME" property="newDeviceName" jdbcType="CHAR" />
        <result column="NEW_DEVICE_IP" property="newDeviceIp" jdbcType="CHAR" />
        <result column="NEW_DEVICE_MODEL" property="newDeviceModel" jdbcType="CHAR" />
        <result column="PERSON_NAME" property="personName" jdbcType="CHAR" />
        <result column="PERSON_DATE" property="personDate" jdbcType="TIMESTAMP" />
    </resultMap>
    <sql id="tableColumnList">
        ID,OLD_DEVICE_NAME, OLD_DEVICE_IP,OLD_DEVICE_MODEL,NEW_DEVICE_NAME,NEW_DEVICE_IP,NEW_DEVICE_MODEL,PERSON_NAME,PERSON_DATE
    </sql>
    <select id="selectById" resultMap="resultMap" parameterType="java.lang.String">
        SELECT
        <include refid="tableColumnList" />
        FROM FAILURE_LOGGING
        WHERE ID=#{id}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        DELETE FROM FAILURE_LOGGING
        WHERE ID = #{id}
    </delete>
    <delete id="deleteById" parameterType="java.lang.String">
        DELETE FROM
        FAILURE_LOGGING
        WHERE ID IN
        <foreach item="item" index="index" collection="array" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>
    <insert id="save" parameterType="com.wgcloud.entity.WorkLogging">
        INSERT INTO FAILURE_LOGGING
        <trim prefix="(" suffix=")" suffixOverrides="," >
              <if test="id != null" >ID,</if>
              <if test="oldDeviceName != null" >OLD_DEVICE_NAME,</if>
              <if test="oldDeviceIp != null" >OLD_DEVICE_IP,</if>
              <if test="oldDeviceModel != null" >OLD_DEVICE_MODEL,</if>
              <if test="newDeviceName != null" >NEW_DEVICE_NAME,</if>
              <if test="newDeviceIp != null" >NEW_DEVICE_IP,</if>
              <if test="newDeviceModel != null" >NEW_DEVICE_MODEL,</if>
              <if test="personName != null" >PERSON_NAME,</if>
              <if test="personDate != null" >PERSON_DATE</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides="," >
              <if test="id != null" >#{id},</if>
              <if test="oldDeviceName != null" >#{oldDeviceName},</if>
              <if test="oldDeviceIp != null" >#{oldDeviceIp},</if>
              <if test="oldDeviceModel != null" >#{oldDeviceModel},</if>
              <if test="newDeviceName != null" >#{newDeviceName},</if>
              <if test="newDeviceIp != null" >#{newDeviceIp},</if>
              <if test="newDeviceModel != null" >#{newDeviceModel},</if>
              <if test="personName != null" >#{personName},</if>
              <if test="personDate != null" >#{personDate}</if>
        </trim>
    </insert>
    <insert id="insertList" parameterType="java.util.List" >
        <choose>
            <when test="_databaseId == 'oracle'">
                begin
                <foreach collection="list" item="item" index="index">
                    INSERT INTO FAILURE_LOGGING (ID,OLD_DEVICE_NAME, OLD_DEVICE_IP,OLD_DEVICE_MODEL,NEW_DEVICE_NAME,NEW_DEVICE_IP,NEW_DEVICE_MODEL,PERSON_NAME,PERSON_DATE)  VALUES
                    (#{item.id},#{item.oldDeviceName},#{item.oldDeviceIp},#{item.oldDeviceModel},#{item.newDeviceName},#{item.newDeviceIp},#{item.newDeviceModel},#{item.personName},#{item.personDate});
                </foreach>
                end;
            </when>
            <otherwise>
                INSERT INTO FAILURE_LOGGING (ID,OLD_DEVICE_NAME, OLD_DEVICE_IP,OLD_DEVICE_MODEL,NEW_DEVICE_NAME,NEW_DEVICE_IP,NEW_DEVICE_MODEL,PERSON_NAME,PERSON_DATE)  VALUES
                 <foreach collection="list" item="item" index="index" separator="," >
                     (#{item.id},#{item.oldDeviceName},#{item.oldDeviceIp},#{item.oldDeviceModel},#{item.newDeviceName},#{item.newDeviceIp},#{item.newDeviceModel},#{item.personName},#{item.personDate});
                </foreach>
            </otherwise>
        </choose>
    </insert>
    <select id="countByParams" parameterType="map" resultType="java.lang.Integer">
        SELECT count(*)  FROM FAILURE_LOGGING t
        <where>
            <include refid="queryByParams" />
        </where>
    </select>
    <select id="selectAllByParams" parameterType="map" resultMap="resultMap">
        SELECT
        <include refid="tableColumnList" />
        FROM FAILURE_LOGGING t
        <where>
            <include refid="queryByParams" />
        </where>
         ORDER BY ID DESC
    </select>
    <select id="selectByParams" parameterType="map" resultMap="resultMap">
        SELECT
        <include refid="tableColumnList" />
        FROM FAILURE_LOGGING
        <where>
            <include refid="queryByParams" />
        </where>
        <choose>
            <when test="orderBy !=null and orderBy != ''">
                <![CDATA[ ORDER BY ${orderBy} ${orderType}]]>
            </when>
            <otherwise>
                ORDER BY ID DESC
            </otherwise>
        </choose>
    </select>
</mapper>