平时java学习总结

来源:互联网 发布:要知前世因今生受者是 编辑:程序博客网 时间:2024/06/03 06:50
(1)//List里面存储map
 List<Map<String,Object>> mapList = qaUserService.getQaUserPkResult(userId,"1");
                    String strScore = ""; // 得分
                    String strRanking = ""; // 得分排名
                    if (null != mapList && mapList.size() != 0) {
                        Map<String,Object> map = mapList.get(0);
                        
                        strScore = map.get("score").toString();
                        strRanking = map.get("rownum").toString();
                    }
Map<String, Object> mapList=allUser.get(0);
             
                    String virtualYieldRate =null == mapList.get("virtualYieldRate") ? "0" : mapList.get("virtualYieldRate").toString();



(2)
for (Fper fper : fperList) {
FperVO fperVO = new FperVO();
BeanUtils.copyProperties(fperVO, fper);
fperVO.settName(fper.getFperName());
fperVO.setPicPath(fper.getHeadPath());
returnList.add(fperVO);

}


(3)
//增加字段 不需要建造新字段
@Transient
public String getId_subDate() {
return id_subDate;
}
public void setId_subDate(String id_subDate) {
this.id_subDate = id_subDate;
}
(4)
//控制多选框
$(".checkbox2").click(function(){
for(var i=0;i<$(".checkbox2").length;i++){

if($(".checkbox2")[i].checked)
{
 $(".checkbox1").attr('checked', true);
     $(".checkboxQ").attr('checked', true);
}
   }
});
(5)
//定时跳转
setTimeout(function(){
                            location.href="http://a.app.qq.com/o/simple.jsp?pkgname=com.huhuda.app";
                        },2000);
(6)
   //a标签跳转
<li><a href="javascript:void(0);"  onclick="setGender('银行');">银行</a></li>
(7)
strRate = null == map2.get("virtualYieldRate") ? "" : map2.get("virtualYieldRate").toString();
 <a href="javascript:void(0);" onclick="js_methodZhu()">
http://localhost:8080/service/qaWeb/tournamentIndex/0
http://localhost:8080/justice/login.jsp


(8)
//登录必备神器
<div class="srkbj"><input type="text" id="mobile" class="srk1" value="请输入手机号码"  onfocus="this.value=''" onblur="if(this.value==''){this.value='请输入手机号码'}"></div>
   
<div class="srkbj"><input type="text" id="password" class="srk1" value="请输入登录密码"  onfocus="if(this.value==defaultValue) {this.value='';this.type='password'}" onblur="if(!value) {value=defaultValue; this.type='text';}" ></div>






(9)for 
方法1 
        UserVO userVO=null;
        for(int i=0;i<deviceKeeperList.size();i++){
//尤其注意
             userVO=deviceKeeperList.get(i);
           //根据deviceKeeperList.get(i).getUserId();查询user_building_rel条数 返回list
            //判断list条数
               String userId =deviceKeeperList.get(i).getUserId();
                userQO.setUserId(userId);
               List<UserVO> idList=userMapper.getBuildingId(userQO);
               for(int j=0;j<idList.size();j++){
                   if(j == 0){
                       buildingId =buildingId+idList.get(j).getBuildingId();
                   }else{
                       buildingId =buildingId+","+idList.get(j).getBuildingId();
                   }
               }
               userVO.setBuildingId(buildingId);


        }

方法2 
for(UserVO userVo : deviceKeeperList){
            String buildingId="";
            String userId =userVo.getUserId();
            userQO.setUserId(userId);
            List<UserVO> idList=userMapper.getBuildingId(userQO);
            for(int j=0;j<idList.size();j++){
                if(j == 0){
                    buildingId =buildingId+idList.get(j).getBuildingId();
                }else{
                    buildingId =buildingId+","+idList.get(j).getBuildingId();
                }
            }
            userVo.setBuildingId(buildingId);
        }






select * from t_auth_function where FIND_IN_SET(id, getMerryCh('c0a80175-5b3d-14d5-815b-3d5671b70002'))


(10)删除菜单下子节点
CREATE FUNCTION `getMerryCh`(rootId CHAR(100))
     RETURNS varchar(1000)
     BEGIN
     DECLARE sTemp VARCHAR(1000);
     DECLARE sTempChd VARCHAR(1000);
   
     SET sTemp = '$';
     SET sTempChd =cast(rootId as CHAR(100));
   
     WHILE sTempChd is not null DO
     SET sTemp = concat(sTemp,',',sTempChd);
     SELECT group_concat(id) INTO sTempChd FROM t_auth_function where FIND_IN_SET(parent_id,sTempChd)>0;
     END WHILE;
     RETURN sTemp;
     END




show function status


drop function function_name


调用的样式
/jstree/3.3.3/themes/default/style.min.css
/jquery-treegrid/0.3.0/css/jquery.treegrid.css
/jstree/3.3.3/jstree.min.js
/bootstrap-select/1.12.0/css/bootstrap-select.min.css
/bootstrap-select/1.12.0/js/bootstrap-select.min.js
/jquery-treegrid/0.3.0/js/jquery.treegrid.min.js
/jquery-treegrid/0.3.0/js/jquery.treegrid.min.js
 //清空jstree缓存   调用ajax
        $('#tree_4').data('jstree', false).empty();
 //单击触发事件
        $('#tree_3').bind("activate_node.jstree", function(obj, e) {
            // 处理代码
            // 获取当前节点
            $("#form").hide();
            var currentNode = e.node;
            id = currentNode.id;
            parent = currentNode.parent;
            text = currentNode.text;
        });
        //右键触发事件
        var customMenu = function(data) {
            $('#selector1').selectpicker('refresh');
            var divD = document.getElementById("selectHide");
            $("#cf_parentId").val(id);
            if (parent == "#") {
                $('#cf_functionValue').hide();
                divD.style.display = "block";
            } else {
                $('#cf_functionValue').val('');
                divD.style.display = "none";
                $('#cf_functionValue').show();
               
            }
            $("#form").show();
            if (parent == "0" || parent == "#") {
                $("#lableButton").hide();
                $("#lableMenu").show();
                $(":radio[name='type'][value='menu']").prop("checked", "checked");
            } else {
                $("#lableMenu").hide();
                $("#lableButton").show();
                $(":radio[name='type'][value='button']").prop("checked", "checked");
            }
          
        }

//前段js
 $("#tree_3").jstree({
                    "core" : {
                        "themes" : {
                            "responsive" : false
                        },
                        "check_callback" : true,
                        "data" : data
                    },
                    "types" : {
                        "default" : {
                            "icon" : "fa fa-folder icon-state-warning icon-lg"
                        },
                        "file" : {
                            "icon" : "fa fa-file icon-state-warning icon-lg"
                        }
                    },
                    "plugins" : [ "contextmenu", "types" ],
                    "contextmenu" : {
                        "items" : {
                            "newxuanxian" : {
                                "label" : "添加此目录下权限",
                                "action" : customMenu,
                            }
                        }
                    }
                }).on('changed.jstree', function (e, data) {     
                                            var parentIdValue = data.instance.get_node(data.selected[0]).id;
                                            $("#editForm #ef_parentId").val(parentIdValue);
                                         });

//后台代码
list = iFunctionMapper.findFunctionSecondMenu();
            Map<String, Boolean> json1 = new HashMap<>();
            json1.put("selected", true);
            Map<String, Boolean> json2 = new HashMap<>();
            json2.put("opened", true);
            Map<String, Object> json = new HashMap<>();
            json.put("text", "根节点");
            json.put("id", "0");
            json.put("parent", "#");
            json.put("state", json2);
            getValue.add(json);
            for (int i = 0; i < list.size(); i++) {
                Map<String, Object> jsonObject = new HashMap<>();
                jsonObject.put("text", list.get(i).getFunctionName());
                jsonObject.put("id", list.get(i).getId());
                jsonObject.put("state", json2);
                String parentId;
                // parentId为空时,属于二级菜单目录
                if ("".equals(list.get(i).getParentId()) || null == list.get(i).getParentId()) {
                    parentId = "0";
                } else {
                    parentId = list.get(i).getParentId();
                }
                jsonObject.put("parent", parentId);
                getValue.add(jsonObject);
            }


  $('#selector1').selectpicker('refresh');
            var ComponentsBootstrapSelect = function() {
                var n = function() {
                    $(".bs-select").selectpicker({
                        iconBase: "fa",
                        tickIcon: "fa-check"
                    })
                };
                return {
                    init: function() {
                        n()
                    }
                }
            } ();
            App.isAngularJsApp() === !1 && jQuery(document).ready(function() {
                ComponentsBootstrapSelect.init()
            });
//加权限值图标
<div id="selectHide">
<select class="bs-select form-control" id="selector1" data-show-subtext="true" onchange="document.createForm.functionValue.value=this.value">
<option value="">请选择权限图标</option>
<option data-icon="icon-diamond" value="icon-diamond">Mustard</option>
<option data-icon="icon-settings" value="icon-settings">Ketchup</option>
<option data-icon="icon-bulb" value="icon-bulb">Relish</option>
<option data-icon="icon-puzzle" value="icon-puzzle">Mayonnaise</option>
<option data-icon="icon-user" value="icon-user">Barbecue Sauce</option>
</select>
</div>