qchouses notes

常用軟體,程式語言的筆記和疑問
Forum rules
盡量做到:
每一個貼子都精心編輯;
每一個疑問都得到解答。
ejsoon
Site Admin
Posts: 3858
Joined: 2016 Jan 10, 22:15

【後臺】多圖上傳

Post by ejsoon » 2017 Jun 13, 11:53

edit.vm

Code: Select all

js:
    $(function () {
		var piclist = $!{piclist};
        $("#imgdiv").empty();
        if (piclist != null && piclist.length > 0) {
            var imgdiv = "";
			var i = 0;
            piclist.forEach(function (data) {
                imgdiv += " <img class='pic1"+ i +"' src='"+data.pic+"' width='180' height='102' align='middle'>";
                imgdiv += "<a id='btn1"+ i +"' style='cursor:pointer' onclick='delpic("+ 1 + i +")'> 删除</a>";
				i++;
            });
            $("#imgdiv").append(imgdiv);
        }
    })

    function uploadpic(picurl) {
        goUpload(picurl);
    }

    function uploadback() {

        var imgdiv = "";
        $("#uploadList").children().each(function(i,n){
            var picurl = $(this).text();
            imgdiv += " <img class='pic2"+ i +"' src='"+picurl+"' width='180' height='102' align='middle'>";
            imgdiv += "<a id='btn2"+ i +"' class='easyui-linkbutton' onclick='delpic("+ 2 + i +")'> 删除</a>";
        });
        $("#imgdiv").append(imgdiv);
    }

	function delpic(picid) {
		$(".pic" + picid).remove();
        $("#btn" + picid).remove();
	}


...
...



                <tr>
                    <td align="left">
                        图片
                    </td>
                    <td>
                        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" onclick="uploadpic('previewpicurl');">添加照片</a>
                    </td>
                </tr>
                <tr>
                    <td align="left">
                    </td>
                    <td id="imgdiv" align="left">

                    </td>
                </tr>

ejsoon
Site Admin
Posts: 3858
Joined: 2016 Jan 10, 22:15

【後臺】添加「選擇門店」

Post by ejsoon » 2017 Jun 13, 12:02

edit.vm js:

Code: Select all

js:
        function selectshop() {
            Dream.openWin('选择门店', '${base}/qch/mst-shop/selectshop', 700, 510, null, self);
        }

...
        
<!-- <input name="shopid" class="easyui-textbox" value="$!{model.shopid}"> -->
<input type="hidden" id="shopid" name="shopid" value="$!{model.shopid}">
<label id="shopname">$!{model.shopname}</label>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" class="easyui-linkbutton" onclick="selectshop()">选择门店</a>
        
shop-action:

Code: Select all

    @RequestMapping(value = "selectshop")
    public String selectshop() {
        return getNameSpace() + "shoplist";
    }
shoplist.vm(複製shop的index.vm】:

Code: Select all

js:
            function confirmShop(){
                var row = jQuery('#dg').datagrid('getSelected');
                if (row){
                    var obj = Dream.findpapa();

                    // 关闭处理窗口
                    parent.$('#win').window('close');
                    obj.jQuery('#shopid').val(row.id);
                    obj.jQuery('#shopname').html(row.shopname);
                }
            }

...

    		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="confirmShop()">选择</a>
之後還要在domain中增加shopname並generate get and set。
然後在xml中的get和custlist加入以下兩句:
,shopname
left join (select id as sid, shopname from kfdb_test.qch_mst_shop) as mstshop on mstshop.sid = shopid

ejsoon
Site Admin
Posts: 3858
Joined: 2016 Jan 10, 22:15

我也能做後臺

Post by ejsoon » 2017 Jul 15, 10:40

單條:

action:

Code: Select all

    /**
     * 开店申请状态取得接口
     *
     * @param request  request
     * @param response response
     */
    @RequestMapping(value = "getShopApplyStatus")
    public void getShopApplyStatus(HttpServletRequest request, HttpServletResponse response) throws Exception {
        Map<String, Object> map = new LinkedHashMap<>();

        map.put(A.CODE, "");
        map.put(A.MSG, "");
        map.put(A.DATA, "");

        String code = Constant.RETURN_CODE_OK;
        String[] msgParam = new String[1];
        String msg = "";

        try {
            map.put(A.DATA, "OK"); // 调用成功返回数据
            Condition condition = bindCondition(request);

            Map paramMap = condition.getMap();

            if (Constant.RETURN_CODE_OK.equals(code)) {

                Map applymap = entityService.getShopApplyStatus(paramMap);
                if (applymap == null) {
                    applymap = new HashMap();
                    applymap.put("applysts", "20");
                }

                // 品牌保证金
                if (applymap != null) {
                    applymap.put("brandmoney", "5000");
                }

                map.put(A.DATA, (applymap == null) ? "" : applymap); // 调用成功返回数据
            }

        } catch (Exception e) {
            code = Constant.RETURN_CODE_DB_ERROR;
            logger.error(new Throwable().getStackTrace()[0], e);

        } finally {
            if (StringUtils.isNullOrEmpty(msg)) {
                msg = MessageFomater.INSTANCE.format(code, msgParam);
            }
            map.put(A.CODE, code);
            map.put(A.MSG, msg);

            printJson(response, JsonUtils.bean2Api(map));
        }
    }
service:

Code: Select all

    /**
     * 门店申请状态取得
     *
     * @param map
     * @return
     */
    public Map getShopApplyStatus(Map map) {
        Assert.notNull(map);

        return super.selectOne("Barberapi_getShopApplyStatus", map);
    }
多條:

action:

Code: Select all

    /**
     * 试题列表取得接口
     *
     * @param request  request
     * @param response response
     */
    @RequestMapping(value = "getBarberQuestionList")
    public void getBarberQuestionList(HttpServletRequest request, HttpServletResponse response) throws Exception {
        Map<String, Object> map = new LinkedHashMap<>();

        map.put(A.CODE, "");
        map.put(A.MSG, "");
        map.put(A.DATA, "");

        String code = Constant.RETURN_CODE_OK;
        String[] msgParam = new String[1];
        String msg = "";

        try {
            map.put(A.DATA, "OK"); // 调用成功返回数据
            Condition condition = bindCondition(request);

            Map paramMap = condition.getMap();

            if (Constant.RETURN_CODE_OK.equals(code)) {
                Map qamap = new HashMap();
                List<Map> qList = entityService.getBarberQuestionList(paramMap);
                if (qList != null && qList.size() > 0) {
                    for(Map qmap: qList) {
                        List<Map> aList = entityService.getQuestionAnswer(qmap);
                        qmap.put("alist", aList);
                    }
                }

                qamap.put("qList", qList);

                map.put(A.DATA, (qamap == null) ? "" : qamap); // 调用成功返回数据
            }

        } catch (Exception e) {
            code = Constant.RETURN_CODE_DB_ERROR;
            logger.error(new Throwable().getStackTrace()[0], e);

        } finally {
            if (StringUtils.isNullOrEmpty(msg)) {
                msg = MessageFomater.INSTANCE.format(code, msgParam);
            }
            map.put(A.CODE, code);
            map.put(A.MSG, msg);

            printJson(response, JsonUtils.bean2Api(map));
        }
    }
service:

Code: Select all

    /**
     * 试题列表取得
     *
     * @param map
     * @return
     */
    public List<Map> getBarberQuestionList(Map map) {
        Assert.notNull(map);

        return super.manQuery("Barberapi_getBarberQuestionList", map);
    }

翻頁:

action:

Code: Select all

    /**
     * 理发师票券列表取得接口
     *
     * @param request  request
     * @param response response
     */
    @RequestMapping(value = "getBarberTicketList")
    public void getBarberTicketList(HttpServletRequest request, HttpServletResponse response) throws Exception {
        Map<String, Object> map = new LinkedHashMap<>();

        map.put(A.CODE, "");
        map.put(A.MSG, "");
        map.put(A.DATA, "");

        String code = Constant.RETURN_CODE_OK;
        String[] msgParam = new String[1];
        String msg = "";

        try {
            map.put(A.DATA, "OK"); // 调用成功返回数据
            Condition condition = bindCondition(request);

            Map paramMap = condition.getMap();

            // 参数验证
            if (StringUtils.isNullOrEmpty(paramMap.get("usests"))) {
                code = Constant.RETURN_CODE_MUST_INPUT_ERROR;
                msgParam = new String[]{"使用状态"};
            }

            if (Constant.RETURN_CODE_OK.equals(code)) {
                paramMap.put("rows", "10");
                PageInfo<Map> ticketList = entityService.getBarberTicketList(paramMap);

                map.put(A.DATA, (ticketList == null) ? "" : ticketList); // 调用成功返回数据
            }

        } catch (Exception e) {
            code = Constant.RETURN_CODE_DB_ERROR;
            logger.error(new Throwable().getStackTrace()[0], e);

        } finally {
            if (StringUtils.isNullOrEmpty(msg)) {
                msg = MessageFomater.INSTANCE.format(code, msgParam);
            }
            map.put(A.CODE, code);
            map.put(A.MSG, msg);

            printJson(response, JsonUtils.bean2Api(map));
        }
    }
service:

Code: Select all

    /**
     * 理发师票券列表取得
     *
     * @param map
     * @return
     */
    public PageInfo<Map> getBarberTicketList(Map map) {
        Assert.notNull(map);
        return super.manPaged("Barberapi_getBarberTicketList", map);
    }

ejsoon
Site Admin
Posts: 3858
Joined: 2016 Jan 10, 22:15

其他的接口

Post by ejsoon » 2017 Jul 15, 11:51

插入,更新,刪除:

service:

Code: Select all

    /**
     * 新建用户订单
     *
     * @param map
     * @return
     */
    public int insertUserOrder(Map map) {
        Assert.notNull(map);
        return super.getSqlSession().insert("Barberapi_insertUserOrder", map);
    }

    /**
     * 更新用户订单
     *
     * @param map
     * @return
     */
    public int updateUserOrder(Map map) {
        Assert.notNull(map);
        return super.getSqlSession().update("Barberapi_updateUserOrder", map);
    }
    
    /**
     * 删除点赞
     *
     * @param map
     * @return
     */
    public int deleteLike(Map map) {
        Assert.notNull(map);
        return super.getSqlSession().delete("Dreamapi_deleteLikes", map);
    }

ejsoon
Site Admin
Posts: 3858
Joined: 2016 Jan 10, 22:15

領導叫我研究MQTT

Post by ejsoon » 2017 Aug 29, 10:08


ejsoon
Site Admin
Posts: 3858
Joined: 2016 Jan 10, 22:15

Re: qchouses notes

Post by ejsoon » 2017 Sep 18, 16:30

如果resultMap是一個domain裡面的話,要先加上geter and seter。

ejsoon
Site Admin
Posts: 3858
Joined: 2016 Jan 10, 22:15

遷移centor記

Post by ejsoon » 2017 Oct 18, 18:14

先全部複製(自建deploy空目錄),再裝SVN,如果代碼太舊就刪重新取。裝maven,複製settings.xml到~/.m2。改Tomcat的設置最後倒數某行。

ejsoon
Site Admin
Posts: 3858
Joined: 2016 Jan 10, 22:15

從DreamAction裡複製manCustPaged要把T改爲本地Action

Post by ejsoon » 2017 Nov 13, 15:40

如複製到MstShopAction.java,把T改爲MstShop。

ejsoon
Site Admin
Posts: 3858
Joined: 2016 Jan 10, 22:15

easy ui的textarea

Post by ejsoon » 2017 Nov 14, 10:56

<input name="leavereason" class="easyui-textbox" value="$!{model.leavereason}" data-options="multiline:true" style="height:90px;width:350px">

ejsoon
Site Admin
Posts: 3858
Joined: 2016 Jan 10, 22:15

如果edit只改其中一些數據,要get和set

Post by ejsoon » 2017 Nov 14, 13:30

如:

Code: Select all

 /**
  * 保存单条Dictionary记录.
  */
 @RequestMapping(value = "save", method = RequestMethod.POST)
 @Override
 public void save(HttpServletRequest request, HttpServletResponse response) throws Exception{
  try {
   BarberSalary o = bindEntity(request, entityClass);

   BarberSalary barberSalary = entityService.get(o.getId());
   barberSalary.setLimitsalary(o.getLimitsalary());
   barberSalary.setReward(o.getReward());
   barberSalary.setPunish(o.getPunish());
   barberSalary.setMemo(o.getMemo());

   entityService.saveOrUpdate(barberSalary);

   printText(response, messageSuccuseWrap());
  } catch (Exception e) {
   logger.error("save", e);
   printText(response, messageFailureWrap("保存失败!"));
  }
 }

Post Reply