码迷,mamicode.com
首页 > 其他好文 > 详细

考试复习

时间:2020-12-10 11:09:55      阅读:3      评论:0      收藏:0      [点我收藏+]

标签:post   etc   查询   from   UNC   select   rom   exception   hash   

考试复习

  • 查询所有角色
SELECT r.*
FROM employee_role e
LEFT JOIN role r
ON e.role_id=r.id
WHERE e.employee_id = #{id}
  • 查询权限列表
select p.expression
from employee_role er
left JOIN role_permission rp
ON er.role_id = rp.role_id
LEFT JOIN permission p
ON rp.permission_id = p.id
WHERE er.employee_id = #{id}
  • 重新加载前台处理
function permissionset(){
    alert(1111);
    $.post(‘/permission/reload.do‘, function (obj){
        if(obj.success){
            $.messager.alert("温馨提示","保存成功1s后关闭");
            window.setTimeout(function (){
                window.location.reload();
            },1000);
        }else {
            alert(obj.msg);
        }
    });
}
  • 重新加载后台
@RequestMapping("/reload")
@ResponseBody
public JsonResult reload() {
    try {
        //查询数据库中所有的权限表达式
        List<String> list = permissionService.selectAllExperssion();
        //找IOC要所有含有@controller注解的bean
        Map<String, Object> beans = ctx.getBeansWithAnnotation(Controller.class);
        //把map中所有的bean提取到collection中
        Collection<Object> controllercglisb = beans.values();
        for (Object controller : controllercglisb) {
            if (AopUtils.isCglibProxy(controllercglisb)) {
                continue;
            }
            Class clazz = controllercglisb.getClass().getSuperclass();
            Method[] methods = clazz.getDeclaredMethods();
            for (Method method : methods) {
                RequiresPermissions requiresPermissions = method.getAnnotation(RequiresPermissions.class);
                if (requiresPermissions != null) {
                    String[] expandname = requiresPermissions.value();
                    String expression = expandname[0];
                    String name = expandname[1];
                    if (list.contains(expandname)) {
                        Permission permission = new Permission();
                        permission.setName(name);
                        permission.setExpression(expression);
                        permissionService.insert(permission);
                    }
                }
            }
        }
        return new JsonResult(true, "重新加载成功");
    } catch (Exception e) {
        return new JsonResult(false,"重新加载失败");
    }
}
  • 潜在客户报表sql
<select id="selectCustomerReport" resultType="java.util.HashMap">
    select ${groupType} groupType,count(c.id) number,c.gender from customer c
    left join employee e on c.seller_id = e.id

    <where>
        c.status = 0
        <if test="keyword != null">
            and e.name like concat(‘%‘,#{keyword},‘%‘)
        </if>
        <if test="beginDate != null">
            and c.input_time &gt;= #{beginDate}
        </if>
        <if test="endDate != null">
            and c.input_time &lt;= #{endDate}
        </if>
    </where>


    group by ${groupType}
</select>
  • 柱状图后台
@RequestMapping("/listByBar")
private String listByBar(@ModelAttribute("qo") customerReportQuery qo, Model model){
    List<HashMap> list = customerReportService.listALL(qo);
    ArrayList xList = new ArrayList();
    ArrayList yList = new ArrayList();
    Iterator iterator = list.iterator();
    while (iterator.hasNext()){
        Map map = (Map) iterator.next();
        xList.add(map.get("groupType"));
        yList.add(map.get("number"));
    }
    model.addAttribute("xList", JSON.toJSONString(xList));
    model.addAttribute("yList", JSON.toJSONString(yList));
    model.addAttribute("groupTypeName", MessageUtil.changMsg(qo));
    return "customerReport/listByBar";
}

考试复习

标签:post   etc   查询   from   UNC   select   rom   exception   hash   

原文地址:https://www.cnblogs.com/zfjcool/p/14092114.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!