mybatis comment batch updates

A front end of the code

toShare: function () {
         // Analyzing selected 
        var IDS = "" ;
         // Analyzing selected 
        var NUM = 0 ;
        $(".checkbox").each(function () {
            if($(this).is(':checked')){
                ids +=$(this).val() + ",";
                a ++ ;
            }
        });
        if(num <= 0){
            toastr.error ( 'select the file you want to share!' );
             return  false ;
        }
        ids = ids.slice(0,ids.length-1);
        //共享
        $.ajax({
            cache: false,
            type: "post",
            url:backbasePath+'/apia/v1/file/shareFile',
            dataType:'json',
            data:{
                token:$("#token").val(),
                id:ids,
            },
            async: true,
            success: function(data) {
                if('000000'==data.code){
                    toastr.success(data.msg);
                    // conducted after a successful upload table reloading 
                    $ ( '# filesList' ) .DataTable () ajax.reload ();.
                     // settings are not checked 
                    $ ( "# checkBoxMaster") prop ( "the checked",. False ) ;
                } else if ('900000' == data.code) {
                    toastr.error ( 'shared failed!' );
                } else {
                    toastr.error(data.msg);
                }
            },
            error: function () {
                toastr.error ( 'shared failed!' );
            }
        });
    }

Second, the back-end code

1, business logic

   // shared files 
    the @Transactional
     public String ShareFile (the HttpServletRequest REQ) {
        String result="";
        try{
            Map<String, Object> m = getMaps(req);
            log.info ( "|" + m + "|" );
             // Get the selected ID 
            String m.get = IDS ( "ID" ) .toString ();
             // the acquired list of the selected package in the list 
            List <String> List = new new the ArrayList <String> ();
            String[] stIds = ids.split(",");
            for (String value : stIds){
                list.add(value);
            }
            int number =knowledgeDao.updateById(list);
            if(number > 0){
                result= RequestResponseTool.getJsonMessage(RespCode.commonSucc, RespMsg.commonSucc);
            }
         }catch(Exception e){
            rollBack(e,log);
            result= RequestResponseTool.getJsonMessage(RespCode.commonFail, RespMsg.commonFail);
        }
        return result;
    }

2, persistence layer

    /**
     * shared documents
     * * @return
     */
    @Update("<script>" +
            " update dzj_knowledge_resource_info set is_public='1' where id in " +
            " <foreach collection='ids' item='id' index='index' open='('  separator=',' close=')' >" +
            " #{id}" +
            " </foreach>" +
            "</script>")
    int updateById(@Param("ids")List<String> ids);

Guess you like

Origin www.cnblogs.com/flyShare/p/12518378.html