1,所需功能:
实现添加一个推广管理的功能,并获取用户登录名,用户真实姓名,推广时间等信息。可以通过后台管理页面查询按钮查询到相关用户信息,并且可以选择推广时间区间,以此来查找该区间内的用户信息。(第一个文本框的时间应早于第二个文本框的时间)
2,具体实现:
一、后台管理模块
【1】首先在后台登录超级管理员账号,利用超级管理员的权限在菜单管理中添加新的管理菜单——推广管理。并填写表单名称,URL地址,是否显示,是否系统菜单 ,是否列维护,是否查询,是否验证等信息。
【2】在按钮管理中选择推广管理添加查询(点击方法:h2y_search),刷新(点击方法:h2y_refresh)按钮。
【3】在菜单列维护中添加新表,填写列标题,列名,宽度,单位,对齐方式,数据类型,支持排序,是否显示,序号等信息。(其中填写列名填写的是sql中查找的对象名)
二、代码编写模块
【1】首先创造一个DeliverManMarket实体,将数据表中的信息定义为变量,并且用get和set方法获取设置数据。
【2】在Controller层 不懂
添加一个DeliveryManMarketController class 继承于BaseController
public class DeliveryManMarketController extends BaseController {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(DeliveryManMarketController.class);
@Autowired protected IDeliveryManMarketService deliveryManMarketService;
@InitBinder public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
//true:允许输入空值,false:不能为空值 }
@RequestMapping(value = "init")
public ModelAndView init() {
return getModelAndView("paotui/deliverManMarket/init");
}
@RequestMapping(value = "/getList")
public void getList() {
logger.info("getList"); outJson(deliveryManMarketService.getGridList(request)); }
}
【3】在Service层
IDeliveryManMarketService中添加
public DeliverManMarket get(Long id);
public Map<String, Object> getGridList(HttpServletRequest request);
在DeliverManMarketServiceImpl中传送用户登录名,用户真实姓名,推广时间等信息。
【4】在Dao层 不懂
添加 IDeliverManMarketDao
DeliverManMarketDaoImpl
读IDeliverManMarketDaoR
写IDeliverManMarketDaoW
【5】xml文件
IDeliverManMarketDaoR .xml
查询功能(sql语句)
<select id="getListMapPage" resultType="hashmap" parameterType="hashmap">
SELECT
od.id as id,
od.delivery_man_id as deliveryManId,
od.customer_id as customerId,
od.open_id as openId,
od.market_time as marketTime,
od.status as status,
od.data_1 as data1,
od.data_2 as data2,
ol.id as deliveryManId,
ol.login_name as deliveryManLoginName,
ol.real_name as deliveryManRealName,
og.id as customerId,
og.login_name as customerLoginName,
og.real_name as customerRealName
FROM tb_deliver_man_market od
left join tb_delivery_man ol on (od.delivery_man_id=ol.id)
left join tb_customer og on (od.customer_id=og.id)
WHERE od.status = 1
<if test="deliveryManLoginName!=null and deliveryManLoginName!=''">
and ol.login_name LIKE CONCAT('%', #{deliveryManLoginName}, '%')
</if>
<if test="marketTime1!=null and marketTime1!='' ">
and od.market_time >= '${marketTime1}'
</if>
<if test="marketTime2!=null and marketTime2!=''">
and od.market_time <= '${marketTime2}'
</if>
limit ${(page-1)*pagesize},${pagesize}
</select>
IDeliverManMarketDaoW .xml
添加,删除,修改功能。
【6】init.jsp
推广日期判断
function getList(){ var deliveryManLoginName = $("#deliveryManLoginName").val(); var marketTime1 = $("#marketTime1").val(); var marketTime2 = $("#marketTime2").val(); if (!marketTime1=="" && !marketTime2=="") { if (marketTime2 < marketTime1) { alert("推广日期结束日期不能比推广开始日期早!"); return; } } var url_1 = "paotui/deliverManMarket/getList.htm?deliveryManLoginName="+deliveryManLoginName+"&marketTime1="+marketTime1+"&marketTime2="+marketTime2;
文本框
跑客登录名:<input type="text " name="deliveryManLoginName" id="deliveryManLoginName" class="h2y_input_just"> 推广日期:<input name="marketTime1" type="text" id="marketTime1" class="h2y_input_just" pattern="yyyy-MM-dd"/> ~~<input name="marketTime2" type="text" id="marketTime2" class="h2y_input_just" pattern="yyyy-MM-dd"/>