後臺管理編寫流程及遇到問題

1,所需功能:sql

實現添加一個推廣管理的功能,並獲取用戶登陸名,用戶真實姓名,推廣時間等信息。能夠經過後臺管理頁面查詢按鈕查詢到相關用戶信息,而且能夠選擇推廣時間區間,以此來查找該區間內的用戶信息。(第一個文本框的時間應早於第二個文本框的時間)app

2,具體實現:jsp

1、後臺管理模塊ui

【1】首先在後臺登陸超級管理員帳號,利用超級管理員的權限在菜單管理中添加新的管理菜單——推廣管理。並填寫表單名稱,URL地址,是否顯示,是否系統菜單  ,是否列維護,是否查詢,是否驗證等信息。url

【2】在按鈕管理中選擇推廣管理添加查詢(點擊方法:h2y_search),刷新(點擊方法:h2y_refresh)按鈕。spa

【3】在菜單列維護中添加新表,填寫列標題,列名,寬度,單位,對齊方式,數據類型,支持排序,是否顯示,序號等信息。(其中填寫列名填寫的是sql中查找的對象名)orm

2、代碼編寫模塊xml

【1】首先創造一個DeliverManMarket實體,將數據表中的信息定義爲變量,而且用get和set方法獲取設置數據。htm

【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 &gt;= '${marketTime1}'

</if>

<if test="marketTime2!=null and marketTime2!=''">

and od.market_time &lt;= '${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"/>
相關文章
相關標籤/搜索