each用法、mybatis传递多个参数方法

来源:互联网 发布:主角创造人工智能小说 编辑:程序博客网 时间:2024/06/05 07:57

//获取当前月份

var yearMonth = date.getFullYear()+"-"+(date.getMonth()+1);

//select动态显示

var html = "<option  value='-1'>请选择</option>";
$.each(data, function(i, trObj){
html += "<option  value='"+trObj.id+"'>"+trObj.name+"</option>";
});
if(level ==2)
{
$("#entryDeptBuEdit").empty();
$('#entryDeptBuEdit').append(html);
$("#sensitive_bu").empty();
$('#sensitive_bu').append(html);
}


//多个查询条件的mybatis方法

//1.map方法

//service层

@Override
public BoleRecommend checkIdCardEffective(String idCard) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
String currentDate = format.format(new Date());
Map<String, String> map = new HashMap<String, String>();
map.put("idCard",idCard);
map.put("date",currentDate);
BoleRecommend bole = boleRecomDao.checkIdCardEffective(map);
return bole;
}

//Dao层

public BoleRecommend checkIdCardEffective(Map<String, String> map);

//mapper.xml层

<select id="checkIdCardEffective" resultMap="boleRecommendBean" parameterType ="map">
select * from bole_recommend_t where yearmonth=#{date} and ID_num = #{idCard}
</select>

//2.注解方法

@RequestMapping(value = "/getWebsiteByChannel")
public void getWebsiteByChannel(String recruitChannel,String year ,String month, HttpServletResponse response) {
JsonArray jo = channelAnalysisService.getWebsiteByChannel(recruitChannel, year, month);
try {
response.getWriter().print(jo.toString());
} catch (IOException e) {
e.printStackTrace();
}
}

@Override
public JsonArray getWebsiteByChannel(String recruitChannel, String year, String month) {
JsonArray ja = new JsonArray();
List<ChannelAnalysis> list = channelAnalysisMapper.getWebsiteByChannel(recruitChannel, year, month);
for (int i = 0; i < list.size(); i++) {
JsonObject jo = new JsonObject();
jo.addProperty("year", list.get(i).getYear());
jo.addProperty("month", list.get(i).getMonth());
jo.addProperty("recruitWebsite", list.get(i).getRecruitWebsite());
jo.addProperty("channelMonthNum", list.get(i).getChannelMonthNum());
ja.add(jo);
}
return ja;
}

public List<ChannelAnalysis> getRecruitWebsiteByCenter(@Param("recruitCenter")String recruitCenter,@Param("year")String year,@Param("month")String month);

<select id="getRecruitWebsiteByCenter" resultMap="ChannelAnalysisBean" >
select 

from  
recruite_channel_show_t 
where 
recruit_website IS null AND recruit_center=#{recruitCenter} AND year=#{year} AND month=#{month}
</select>