王煜鑫
2018-11-06 184e2c9ec5d93965c818a5801439f54d3dfebd7c
更新权限接口
6 files added
8 files modified
6061 ■■■■■ changed files
.gitignore 3 ●●●●● patch | view | raw | blame | history
document/DBScript/auth_sso.sql 5425 ●●●●● patch | view | raw | blame | history
sourcecode/MVNFHM/pom.xml 6 ●●●●● patch | view | raw | blame | history
sourcecode/MVNFHM/src/main/java/com/fh/controller/outer/OuterInterfaceController.java 5 ●●●●● patch | view | raw | blame | history
sourcecode/MVNFHM/src/main/java/com/fh/controller/outer/PowerInterfaceController.java 37 ●●●●● patch | view | raw | blame | history
sourcecode/MVNFHM/src/main/java/com/fh/entity/RestResult.java 38 ●●●●● patch | view | raw | blame | history
sourcecode/MVNFHM/src/main/java/com/fh/entity/system/power/FuncPermission.java 27 ●●●●● patch | view | raw | blame | history
sourcecode/MVNFHM/src/main/java/com/fh/entity/system/power/UserPermission.java 20 ●●●●● patch | view | raw | blame | history
sourcecode/MVNFHM/src/main/java/com/fh/service/system/buttonrights/ButtonrightsManager.java 12 ●●●●● patch | view | raw | blame | history
sourcecode/MVNFHM/src/main/java/com/fh/service/system/buttonrights/impl/ButtonrightsService.java 9 ●●●●● patch | view | raw | blame | history
sourcecode/MVNFHM/src/main/java/com/fh/util/Watermark.java 16 ●●●● patch | view | raw | blame | history
sourcecode/MVNFHM/src/main/resources/dbconfig.properties 12 ●●●● patch | view | raw | blame | history
sourcecode/MVNFHM/src/main/resources/mybatis1/system/ButtonrightsMapper.xml 18 ●●●● patch | view | raw | blame | history
sourcecode/MVNFHM/src/main/webapp/WEB-INF/jsp/system/index/login_jd.jsp 433 ●●●● patch | view | raw | blame | history
.gitignore
New file
@@ -0,0 +1,3 @@
.idea
target
*.iml
document/DBScript/auth_sso.sql
New file
Diff too large
sourcecode/MVNFHM/pom.xml
@@ -17,6 +17,12 @@
    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.14</version>
        </dependency>
        <!-- spring start -->
        <dependency>
            <groupId>org.springframework</groupId>
sourcecode/MVNFHM/src/main/java/com/fh/controller/outer/OuterInterfaceController.java
@@ -230,7 +230,7 @@
     * @return
     * @throws Exception
     */
    @RequestMapping(value="/user/tenant", method=RequestMethod.POST,produces="application/json;charset=UTF-8")
    @RequestMapping(value="/user/tenant", method=RequestMethod.GET,produces="application/json;charset=UTF-8")
    @ResponseBody
    public Object getTenant(String openId) throws Exception {
        Map<String, Object> map = new HashMap<>();
@@ -267,4 +267,5 @@
        map.put(RSP_MSG, Const.M0000);
        return JSON.toJSONString(map);
    }
 }
}
sourcecode/MVNFHM/src/main/java/com/fh/controller/outer/PowerInterfaceController.java
New file
@@ -0,0 +1,37 @@
package com.fh.controller.outer;
import com.fh.controller.base.BaseController;
import com.fh.entity.RestResult;
import com.fh.entity.system.power.UserPermission;
import com.fh.service.system.buttonrights.ButtonrightsManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@Controller
@RequestMapping(value="/jd-api")
public class PowerInterfaceController extends BaseController {
    @Resource
    private ButtonrightsManager buttonrightsManager;
    /**
     * 获取用户权限
     * @param openId
     * @param systemId
     * @return
     * @throws Exception
     */
    @RequestMapping(value="/user/power")
    @ResponseBody
    public RestResult<UserPermission> getPermission(@RequestParam("openId") String openId, @RequestParam("systemId") String systemId) throws Exception{
        return RestResult.success(new UserPermission(
                buttonrightsManager.findButtonByOpenIdAndSystemId(openId, systemId)));
    }
}
sourcecode/MVNFHM/src/main/java/com/fh/entity/RestResult.java
New file
@@ -0,0 +1,38 @@
package com.fh.entity;
import lombok.Data;
import static com.fh.util.Const.C0000;
@Data
public class RestResult<T> {
    /**
     * 应答/错误代码
     */
    private String rspCode;
    /**
     * 应答/错误描述
     */
    private String rspMsg;
    /**
     * 返回结果数据
     */
    private T data;
    private RestResult() {}
    public static <T> RestResult<T> newInstance() {
        return new RestResult<>();
    }
    public static <T> RestResult<T> success(T data){
        RestResult<T> r = new RestResult<>();
        r.data = data;
        r.rspCode = C0000;
        return r;
    }
}
sourcecode/MVNFHM/src/main/java/com/fh/entity/system/power/FuncPermission.java
New file
@@ -0,0 +1,27 @@
package com.fh.entity.system.power;
import lombok.Data;
import java.io.Serializable;
@Data
public class FuncPermission implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 权限id
     */
    protected String id;
    /**
     * 权限显示名
     */
    protected String display;
    /**
     * 权限标识
     */
    private String name;
}
sourcecode/MVNFHM/src/main/java/com/fh/entity/system/power/UserPermission.java
New file
@@ -0,0 +1,20 @@
package com.fh.entity.system.power;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserPermission implements Serializable {
    private static final long serialVersionUID = 1L;
    protected List<FuncPermission> functionPermissionSet = Collections.EMPTY_LIST;
}
sourcecode/MVNFHM/src/main/java/com/fh/service/system/buttonrights/ButtonrightsManager.java
@@ -1,6 +1,9 @@
package com.fh.service.system.buttonrights;
import java.util.List;
import java.util.Set;
import com.fh.entity.system.power.FuncPermission;
import com.fh.util.PageData;
/** 
@@ -40,6 +43,13 @@
     * @throws Exception
     */
    public List<PageData> listAllBrAndQxname(PageData pd)throws Exception;
    /**
     * 获取按钮权限
     * @param openId
     * @param systemId
     * @return
     */
    List<FuncPermission> findButtonByOpenIdAndSystemId(String openId, String systemId)throws Exception;
}
sourcecode/MVNFHM/src/main/java/com/fh/service/system/buttonrights/impl/ButtonrightsService.java
@@ -1,14 +1,17 @@
package com.fh.service.system.buttonrights.impl;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
import com.fh.entity.system.power.FuncPermission;
import org.springframework.stereotype.Service;
import com.fh.dao.DaoSupport;
import com.fh.util.PageData;
import com.fh.service.system.buttonrights.ButtonrightsManager;
import org.springframework.ui.ModelMap;
/** 
 * 说明: 按钮权限
@@ -64,5 +67,11 @@
        return (List<PageData>)dao.findForList("ButtonrightsMapper.listAllBrAndQxname", pd);
    }
    @Override
    public List<FuncPermission> findButtonByOpenIdAndSystemId(String openId, String systemId) throws Exception{
        return (List<FuncPermission>) dao.findForList("ButtonrightsMapper.findButtonByOpenIdAndSystemId"
                , new ModelMap("openId", openId).addAttribute("systemId", systemId));
    }
}
sourcecode/MVNFHM/src/main/java/com/fh/util/Watermark.java
@@ -10,8 +10,6 @@
import javax.imageio.ImageIO;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
/** 
 * 说明:图片水印处理类 (报错注意:用安装版的jdk,不要用开发工具自带的jdk)
@@ -74,7 +72,7 @@
         */
        public final static void pressImage(String pressImg, String targetImg,
                int x, int y) {
            try {
            try (FileOutputStream out = new FileOutputStream(targetImg)){
                //目标文件
                File _file = new File(targetImg);
                Image src = ImageIO.read(_file);
@@ -94,10 +92,7 @@
                g.drawImage(src_biao, x, y, wideth_biao, height_biao, null);
                //水印文件结束
                g.dispose();
                FileOutputStream out = new FileOutputStream(targetImg);
                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                encoder.encode(image);
                out.close();
                ImageIO.write(image, "jpg", out);
            } catch (Exception e) {
                e.printStackTrace();
            }
@@ -125,7 +120,7 @@
        public static void pressText(String pressText, String targetImg,
                String fontName, int fontStyle, Color color, int fontSize, int x,int y) {
            try {
            try (FileOutputStream out = new FileOutputStream(targetImg)){
                File _file = new File(targetImg);
                Image src = ImageIO.read(_file);
                int wideth = src.getWidth(null);
@@ -138,10 +133,7 @@
                g.setFont(new Font(fontName, fontStyle, fontSize));
                g.drawString(pressText, x, y);
                g.dispose();
                FileOutputStream out = new FileOutputStream(targetImg);
                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                encoder.encode(image);
                out.close();
                ImageIO.write(image, "jpg", out);
            } catch (Exception e) {
                System.out.println(e);
            }
sourcecode/MVNFHM/src/main/resources/dbconfig.properties
@@ -1,8 +1,8 @@
#\u6570\u636e\u6e901
url:jdbc:mysql://localhost:3306/fhadmin?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
url:jdbc:mysql://10.4.32.149:3306/auth_sso?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
driverClassName:com.mysql.jdbc.Driver
username:root
password:123456
username:jiuding
password:jiuding@iemsoft.cn
filters:stat
maxActive:20
initialSize:1
@@ -21,10 +21,10 @@
logAbandoned:true
#\u6570\u636e\u6e902
url2:jdbc:mysql://localhost:3306/fhadmin2?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
url2:jdbc:mysql://10.4.32.149:3306/auth_sso?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
driverClassName2:com.mysql.jdbc.Driver
username2:root
password2:root
username2:jiuding
password2:jiuding@iemsoft.cn
filters2:stat
maxActive2:20
initialSize2:1
sourcecode/MVNFHM/src/main/resources/mybatis1/system/ButtonrightsMapper.xml
@@ -85,6 +85,20 @@
        where
            a.ROLE_ID = #{ROLE_ID}
    </select>
    <!-- fh313596790qq(青苔) -->
    <select id="findButtonByOpenIdAndSystemId" parameterType="java.util.Map" resultType="com.fh.entity.system.power.FuncPermission">
        SELECT
            f.FHBUTTON_ID id,
            f.QX_NAME name,
            f.`NAME` display
        FROM
            sys_user u
            LEFT JOIN sys_user_system s ON u.USER_ID = s.USER_ID
            AND s.SYSTEM_ID = #{systemId}
            LEFT JOIN sys_role_fhbutton r ON s.ROLE_ID = r.ROLE_ID
            LEFT JOIN sys_fhbutton f ON r.BUTTON_ID = f.FHBUTTON_ID
        WHERE
            u.USER_ID = #{openId}
    </select>
</mapper>
sourcecode/MVNFHM/src/main/webapp/WEB-INF/jsp/system/index/login_jd.jsp
@@ -1,213 +1,220 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        body {
            font-family: "微软雅黑";
            font-size: 14px;
        }
        .box {
            width: 22%;
            background: white;
            background-size: 100% 100%;
            border-radius: 10px;
            overflow: hidden;
            text-align: center;
            padding-bottom: 40px;
            box-shadow: darkgrey 0px 10px 30px 5px;
        }
        .input_outer {
            width: 80%;
            height: 40px;
            border: 1px solid #999999;
            margin-left: 10%;
            margin-top: 30px;
            border-radius: 20px;
        }
        .input_outer span {
            width: 40px;
            height: 40px;
            float: left;
        }
        .input_outer input {
            width: 80%;
            background: none;
            border: none;
            outline: none;
            height: 40px;
            float: left;
        }
        .box button {
            width: 80%;
            height: 40px;
            background: #236c77;
            border-radius: 20px;
            border: none;
            margin-top: 20px;
            outline: none;
            cursor: pointer;
        }
        .box button a {
            font-size: 18px;
            color: black;
            text-decoration: none;
        }
        .box button:nth-of-type(1) {
            background: #fe8d00;
            color: white;
        }
        .box button:nth-of-type(1) a {
            color: white;
        }
        .box p {
            font-size: 18px;
            color: rgb(37, 37, 37);
            padding-top: 30px;
        }
        .dl {
            width: 100%;
            font-size: 25px;
            color: white;
            position: fixed;
            z-index: 999;
            top: 45px;
            text-align: center;
        }
        .forgetPassword {
            display: block;
            text-align: right;
            color: #337ab7;
            text-decoration: none;
            margin-top: 10px;
            margin-right: 10%;
        }
        .hide {
            display: none;
            padding: 0 !important;
            display: none;
            font-size: 14px !important;
            color: red !important;
            float: left;
            margin-left: 10%;
        }
    </style>
</head>
<body>
    <div class="box">
        <p>用户登录</p>
        <div class="input_outer">
            <span class="u_user">
                <img src="static/login/yh.png" style="margin-top:6px" height="25px" width="25px" />
            </span>
            <input name="logname" class="userName" type="text" placeholder="请输入ID或用户名">
        </div>
        <p class="userNameVerification hide"></p>
        <div class="input_outer">
            <span class="us_uer">
                <img src="static/login/mm.png" style="margin-top:6px" height="25px" width="25px" />
            </span>
            <input name="logpass" type="passWord" class="passWord" placeholder="请输入密码" type="password">
        </div>
        <p class="passwordVerification hide"></p>
        <a href="#" class="forgetPassword">忘记密码</a>
        <p class="errorMessage hide"></p>
        <button class="signIn"><a href="#">登 录</a></button>
    </div>
    <script type="text/javascript" src="static/login/js/jquery-1.5.1.min.js"></script>
    <script>
        window.onload = function () {
            var url = window.location.href;
            function GetQueryString(url,name) {
            var index = url.indexOf('?')
            var str = url.substring(index + 1);
            var arr = str.split('&');
            var result = {};
            arr.forEach(function (item){
                var a = item.split('=');
                result[a[0]] = a[1];
            })
            return result[name];
            }
            loginUrl = GetQueryString(url,"service");
            $.ajaxSetup({
                headers: {
                    "Access-Control-Allow-Origin": "*",
                    "Access-Control-Allow-Methods": "*",
                    "Access-Control-Allow-Headers": "*",
                    "withCredentials": "true"
                }
            });
            $('.signIn').click(function () {
                var fals = true;
                if ($('.userName').val() == "") {
                    $('.userNameVerification').html('请输入账号');
                    $('.userNameVerification').show();
                    fals = false;
                }
                if ($('.passWord').val() == "") {
                    $('.passwordVerification').html('请输入密码');
                    $('.passwordVerification').show();
                    fals = false;
                }
                if (fals) {
                    $('.passwordVerification').hide();
                    $('.userNameVerification').hide();
                    var signObj = {
                        "userName": $('.userName').val(),
                        "passWord": $('.passWord').val()
                    }
                    $.ajax({
                        type: "get",
                        url: "/jd-api/user/login?",
                        data: signObj,
                        dataType: "json",
                        success: function (res) {
                            if (res.rspCode == "000000") {
                                window.location.href = loginUrl + (loginUrl.indexOf('?') >-1 ? "&LOGIN_INFO=" : "?LOGIN_INFO=") + res.LOGIN_INFO;
                            } else {
                                $(".errorMessage").html(res.rspMsg);
                                $(".errorMessage").show();
                            }
                        }
                    });
                }
            })
        }
    </script>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
        <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
            <%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
                <!DOCTYPE html>
                <html lang="en">
                <head>
                    <base href="<%=basePath%>">
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
                    <meta http-equiv="X-UA-Compatible" content="ie=edge">
                    <title>Document</title>
                    <style>
                        * {
                            margin: 0;
                            padding: 0;
                        }
                        body {
                            font-family: "微软雅黑";
                            font-size: 14px;
                        }
                        .box {
                            width: 100%;
                            background: white;
                            background-size: 100% 100%;
                            border-radius: 10px;
                            overflow: hidden;
                            text-align: center;
                            padding-bottom: 40px;
                            box-shadow: darkgrey 0px 10px 30px 5px;
                        }
                        .input_outer {
                            width: 80%;
                            height: 40px;
                            border: 1px solid #999999;
                            margin-left: 10%;
                            margin-top: 30px;
                            border-radius: 20px;
                        }
                        .input_outer span {
                            width: 40px;
                            height: 40px;
                            float: left;
                        }
                        .input_outer input {
                            width: 80%;
                            background: none;
                            border: none;
                            outline: none;
                            height: 40px;
                            float: left;
                        }
                        .box button {
                            width: 80%;
                            height: 40px;
                            background: #236c77;
                            border-radius: 20px;
                            border: none;
                            margin-top: 20px;
                            outline: none;
                            cursor: pointer;
                        }
                        .box button a {
                            font-size: 18px;
                            color: black;
                            text-decoration: none;
                        }
                        .box button:nth-of-type(1) {
                            background: #fe8d00;
                            color: white;
                        }
                        .box button:nth-of-type(1) a {
                            color: white;
                        }
                        .box p {
                            font-size: 18px;
                            color: rgb(37, 37, 37);
                            padding-top: 30px;
                        }
                        .dl {
                            width: 100%;
                            font-size: 25px;
                            color: white;
                            position: fixed;
                            z-index: 999;
                            top: 45px;
                            text-align: center;
                        }
                        .forgetPassword {
                            display: block;
                            text-align: right;
                            color: #337ab7;
                            text-decoration: none;
                            margin-top: 10px;
                            margin-right: 10%;
                        }
                        .hide {
                            display: none;
                            padding: 0 !important;
                            display: none;
                            font-size: 14px !important;
                            color: red !important;
                            float: left;
                            margin-left: 10%;
                        }
                    </style>
                </head>
                <body>
                    <div class="box">
                        <p>用户登录</p>
                        <div class="input_outer">
                            <span class="u_user">
                                <img src="static/login/yh.png" style="margin-top:6px" height="25px" width="25px" />
                            </span>
                            <input name="logname" class="userName" type="text" placeholder="请输入ID或用户名">
                        </div>
                        <p class="userNameVerification hide"></p>
                        <div class="input_outer">
                            <span class="us_uer">
                                <img src="static/login/mm.png" style="margin-top:6px" height="25px" width="25px" />
                            </span>
                            <input name="logpass" type="passWord" class="passWord" placeholder="请输入密码" type="password">
                        </div>
                        <p class="passwordVerification hide"></p>
                        <a href="#" class="forgetPassword">忘记密码</a>
                        <p class="errorMessage hide"></p>
                        <button class="signIn"><a href="javascript:;">登 录</a></button>
                    </div>
                    <script type="text/javascript" src="static/login/js/jquery-1.5.1.min.js"></script>
                    <script>
                        window.onload = function () {
                            var url = window.location.href;
                            function GetQueryString(url, name) {
                                var index = url.indexOf('?')
                                var str = url.substring(index + 1);
                                var arr = str.split('&');
                                var result = {};
                                arr.forEach(function (item) {
                                    var a = item.split('=');
                                    result[a[0]] = a[1];
                                })
                                return result[name];
                            }
                            // loginUrl = GetQueryString(decodeURIComponent(url.replace(/\+/g,  " ")),"service");
                            loginUrl = decodeURIComponent(GetQueryString(url, "service").replace(/\+/g, " "));
                            $.ajaxSetup({
                                headers: {
                                    "Access-Control-Allow-Origin": "*",
                                    "Access-Control-Allow-Methods": "*",
                                    "Access-Control-Allow-Headers": "*",
                                    "withCredentials": "true"
                                }
                            });
                            $(document).keyup(function (event) {
                                if (event.keyCode == 13) {
                                    $('.signIn').trigger("click");
                                }
                            });
                            $('.signIn').click(function () {
                                var fals = true;
                                if ($('.userName').val() == "") {
                                    $('.userNameVerification').html('请输入账号');
                                    $('.userNameVerification').show();
                                    fals = false;
                                }
                                if ($('.passWord').val() == "") {
                                    $('.passwordVerification').html('请输入密码');
                                    $('.passwordVerification').show();
                                    fals = false;
                                }
                                if (fals) {
                                    $('.passwordVerification').hide();
                                    $('.userNameVerification').hide();
                                    var signObj = {
                                        "userName": $('.userName').val(),
                                        "passWord": $('.passWord').val()
                                    }
                                    $.ajax({
                                        type: "get",
                                        url: "/jd-api/user/login?",
                                        data: signObj,
                                        dataType: "json",
                                        success: function (res) {
                                            if (res.rspCode == "000000") {
                                                window.location.href = loginUrl + (loginUrl.indexOf('?') > -1 ? "&LOGIN_INFO=" : "?LOGIN_INFO=") + res.LOGIN_INFO;
                                            } else {
                                                $(".errorMessage").html(res.rspMsg);
                                                $(".errorMessage").show();
                                            }
                                        }
                                    });
                                }
                            })
                        }
                    </script>
                </body>
                </html>