mapper层
MonitorApiUrlCheckMapper.xml
如下:
<?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="cn.xxxxx.monitor.server.dao.MonitorApiurlCheckMapper">
<update id="updateSmsFlag" parameterType="map">
update monitor_sms_his set smsFlag = #{smsFlag} where apiEncode = #{encodeUrl} and type = #{type} and smsFlag = 0
</update>
<update id="updateJudgeTime" parameterType="map">
update monitor_apiurl_check
set
lostResponseNum = 0,
judgeTime = #{currentDate}
where id = #{id}
</update>
<update id="updateLostNum" parameterType="map">
update monitor_apiurl_check
set
lostResponseNum = #{lostNum}
where id = #{id}
</update>
<select id="getMonitorApiSms" resultType="string">
select phoneNum from monitor_api_sms where status = 1
</select>
<select id="getMonitorSmsNum" resultType="long">
<![CDATA[
select count(*) from monitor_sms_his where createdDate >= #{currentDay} and apiEncode = #{encodeUrl} and smsFlag = 0 and type = #{type};
]]>
</select>
<select id="getMonitorSmsMaxCreateDate" resultType="java.lang.String">
select max(createdDate) from monitor_sms_his where apiEncode = #{encodeUrl} and type = #{type} and createdDate >= #{currentDay}
</select>
<!-- 增 -->
<insert id="save" parameterType="entity.BrandRecord" useGeneratedKeys="true" keyProperty="brandId">
INSERT INTO goods_source.`brand_record`(
brand_name, out_id, out_name,
state, brand_number, start_time, source_type, img_url,
goods_count, brand_state
) VALUES (
#{brandName}, #{outId}, #{outName},
#{state}, #{brandNumber}, #{startTime}, #{sourceType}, #{imgUrl},
#{goodsCount}, #{brandState}
)
</insert>
<!-- 删 -->
<delete id="delete" parameterType="Integer">
DELETE FROM goods_source.`brand_record` WHERE brand_id = #{brandId}
</delete>
<!-- 改 -->
<update id="update" parameterType="entity.BrandRecord">
UPDATE goods_source.`brand_record` SET
brand_name = #{brandName},
out_id = #{outId}, out_name = #{outName}, state = #{state},
brand_number = #{brandNumber}, start_time = #{startTime}, source_type = #{sourceType},
img_url = #{imgUrl}, goods_count = #{goodsCount}, brand_state = #{brandState}
WHERE brand_id = #{brandId}
</update>
<!-- 根据ID查,包括state状态为0 -->
<select id="findIncludeZeroById" parameterType="Integer" resultMap="BrandRecordRMap">
<include refid="selectAllField" />
FROM goods_source.`brand_record` br WHERE br.brand_id = #{brandId}
</select>
<!-- 查(paramJson参数) -->
<select id="findByParam" parameterType="com.alibaba.fastjson.JSONObject" resultMap="BrandRecordRMap">
<include refid="selectAllField" />
FROM goods_source.`brand_record` br WHERE 1 = 1
<include refid="paramCondition" />
<include refid="stateNoZeroCondition" />
ORDER BY br.brand_id DESC
<include refid="pagingCondition" />
</select>
</mapper>
dao层
如下:
public interface MonitorApiurlCheckMapper extends BaseMapper<MonitorApiurlCheck> {
/**
* 根据是否修复接口获得标志
*
* @param encodeUrl md5解析的接口地址
* @param smsFlag 是否解决接口问题
* @param type 接口检测还是接口时长检测
* @return
*/
public boolean updateSmsFlag(String encodeUrl, Integer smsFlag, Integer type);
public boolean updateJudgeTime(String id, String currentDate);
public boolean updateLostNum(String id, long lostNum);
// @DS("slave_disaster")
public List<String> getMonitorApiSms();
// @DS("slave_disaster")
public long getMonitorSmsNum(String currentDay, String encodeUrl, Integer type);
// @DS("slave_disaster")
public String getMonitorSmsMaxCreateDate(String encodeUrl, Integer type, String currentDay);
/**
* 查最新的一条
*/
BrandRecord findNewOneByParam(JSONObject paramJson);
}
server层impl调用
@Autowired
private MonitorApiurlCheckMapper mapper;