单独分出ui,后端不做变化
This commit is contained in:
parent
e939bad3c1
commit
12ab551c2e
|
@ -48,4 +48,6 @@ image/*
|
|||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sln
|
||||
|
||||
*auto-config/*
|
|
@ -1,39 +0,0 @@
|
|||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
import context from '@/components/context'
|
||||
import Home from '@/components/home'
|
||||
import Person from '@/components/person'
|
||||
import Detail from '@/components/detail/detail-context'
|
||||
|
||||
Vue.use(Router)
|
||||
|
||||
export default new Router({
|
||||
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
name: 'context',
|
||||
component: context
|
||||
},
|
||||
{
|
||||
path: '/:id',
|
||||
name: 'detail',
|
||||
component: context
|
||||
},
|
||||
{
|
||||
path:'/home/:id',
|
||||
component:Home,
|
||||
children:[
|
||||
{
|
||||
path: 'person',
|
||||
component: Person
|
||||
}
|
||||
]
|
||||
},{
|
||||
path:'/detail/:id',
|
||||
name:'Detail',
|
||||
component:Detail
|
||||
},
|
||||
|
||||
]
|
||||
})
|
|
@ -18,6 +18,10 @@
|
|||
<groupId>com.len</groupId>
|
||||
<artifactId>len-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.len</groupId>
|
||||
<artifactId>len-sys</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -1,11 +1,31 @@
|
|||
package com.len.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.len.base.BaseController;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhuxiaomeng
|
||||
* @date 2018/7/22.
|
||||
* @email 154040976@qq.com
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/blog")
|
||||
public class BlogMenuController extends BaseController {
|
||||
|
||||
@GetMapping("/menu")
|
||||
public List<String> menuList(){
|
||||
List<String> list=new ArrayList<>();
|
||||
list.add("java");
|
||||
list.add("架构");
|
||||
list.add("Linux");
|
||||
list.add("其他");
|
||||
System.out.println(JSON.toJSON(list));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package com.len.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.len.base.BaseController;
|
||||
import com.len.entity.BlogLabel;
|
||||
import com.len.service.BlogLabelService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhuxiaomeng
|
||||
* @date 2018/7/28.
|
||||
* @email 154040976@qq.com
|
||||
* <p>
|
||||
* 标签
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/blog")
|
||||
public class LabelController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private BlogLabelService blogLabelService;
|
||||
|
||||
private static String[] color = {"green", "red", "yellow", "blue"};
|
||||
|
||||
/**
|
||||
* 获取标签 后期增加规则 颜色后期处理成浅色 好看
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getLabel")
|
||||
public JSONArray label() {
|
||||
List<BlogLabel> blogLabels = blogLabelService.selectAll();
|
||||
JSONArray array = JSONArray.parseArray(JSON.toJSONString(blogLabels));
|
||||
int i = 0;
|
||||
JSONObject object;
|
||||
for (Object o : array) {
|
||||
i = i == 4 ? 0 : i;
|
||||
object = (JSONObject) o;
|
||||
object.put("color", color[i]);
|
||||
object.remove("id");
|
||||
i++;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.len.controller;
|
||||
|
||||
import com.len.entity.SysUser;
|
||||
import com.len.service.SysUserService;
|
||||
import com.len.util.JWTUtil;
|
||||
import com.len.util.Md5Util;
|
||||
import org.apache.shiro.authz.UnauthorizedException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author zhuxiaomeng
|
||||
* @date 2018/7/25.
|
||||
* @email 154040976@qq.com
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/blog")
|
||||
public class SignController {
|
||||
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@PostMapping("/login")
|
||||
public String login(@RequestParam("username") String username,
|
||||
@RequestParam("password") String password) {
|
||||
SysUser user=new SysUser();
|
||||
user.setUsername(username);
|
||||
SysUser sysUser=sysUserService.selectOne(user);
|
||||
String pass = Md5Util.getMD5(password, username);
|
||||
if (sysUser.getPassword().equals(pass)) {
|
||||
return JWTUtil.sign(username, password);
|
||||
} else {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.len.service;
|
||||
|
||||
import com.len.base.BaseService;
|
||||
import com.len.entity.BlogLabel;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhuxiaomeng
|
||||
* @date 2018/7/28.
|
||||
* @email 154040976@qq.com
|
||||
*/
|
||||
public interface BlogLabelService extends BaseService<BlogLabel, String> {
|
||||
|
||||
@Override
|
||||
public int insertList(@Param("list") List<BlogLabel> blogLabels);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.len.service.impl;
|
||||
|
||||
import com.len.base.BaseMapper;
|
||||
import com.len.base.impl.BaseServiceImpl;
|
||||
import com.len.entity.BlogLabel;
|
||||
import com.len.mapper.BlogLabelMapper;
|
||||
import com.len.service.BlogLabelService;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhuxiaomeng
|
||||
* @date 2018/7/28.
|
||||
* @email 154040976@qq.com
|
||||
*/
|
||||
@Service
|
||||
public class BlogLabelServiceImpl extends BaseServiceImpl<BlogLabel, String> implements BlogLabelService {
|
||||
|
||||
@Autowired
|
||||
private BlogLabelMapper blogLabelMapper;
|
||||
|
||||
@Override
|
||||
public BaseMapper<BlogLabel, String> getMappser() {
|
||||
return blogLabelMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertList(@Param("list") List<BlogLabel> blogLabels) {
|
||||
return blogLabelMapper.insertList(blogLabels);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.len;
|
||||
|
||||
/**
|
||||
* @author zhuxiaomeng
|
||||
* @date 2018/7/28.
|
||||
* @email 154040976@qq.com
|
||||
*/
|
||||
public class BlogTest {
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.len.util;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.exceptions.JWTDecodeException;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
|
||||
public class JWTUtil {
|
||||
|
||||
// 过期时间5分钟
|
||||
private static final long EXPIRE_TIME = 5*60*1000;
|
||||
|
||||
/**
|
||||
* 校验token是否正确
|
||||
* @param token 密钥
|
||||
* @param secret 用户的密码
|
||||
* @return 是否正确
|
||||
*/
|
||||
public static boolean verify(String token, String username, String secret) {
|
||||
try {
|
||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||
JWTVerifier verifier = JWT.require(algorithm)
|
||||
.withClaim("username", username)
|
||||
.build();
|
||||
DecodedJWT jwt = verifier.verify(token);
|
||||
return true;
|
||||
} catch (Exception exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得token中的信息无需secret解密也能获得
|
||||
* @return token中包含的用户名
|
||||
*/
|
||||
public static String getUsername(String token) {
|
||||
try {
|
||||
DecodedJWT jwt = JWT.decode(token);
|
||||
return jwt.getClaim("username").asString();
|
||||
} catch (JWTDecodeException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成签名,5min后过期
|
||||
* @param username 用户名
|
||||
* @param secret 用户的密码
|
||||
* @return 加密的token
|
||||
*/
|
||||
public static String sign(String username, String secret) {
|
||||
Date date = new Date(System.currentTimeMillis()+EXPIRE_TIME);
|
||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||
// 附带username信息
|
||||
return JWT.create()
|
||||
.withClaim("username", username)
|
||||
.withExpiresAt(date)
|
||||
.sign(algorithm);
|
||||
}
|
||||
}
|
|
@ -52,6 +52,11 @@ public class LoginRealm extends AuthorizingRealm{
|
|||
@Autowired
|
||||
private RoleMenuService roleMenuService;
|
||||
|
||||
/* @Override
|
||||
public boolean supports(AuthenticationToken token) {
|
||||
return super.supports(token);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 获取认证
|
||||
* @param principalCollection
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package test;
|
||||
|
||||
import com.len.Application;
|
||||
import com.len.entity.BlogLabel;
|
||||
import com.len.service.BlogLabelService;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author zhuxiaomeng
|
||||
* @date 2018/7/28.
|
||||
* @email 154040976@qq.com
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@WebAppConfiguration
|
||||
public class BlogTest {
|
||||
|
||||
@Autowired
|
||||
private BlogLabelService blogLabelService;
|
||||
|
||||
/**
|
||||
* 新建标签数据
|
||||
*/
|
||||
@Test
|
||||
public void insertTestData(){
|
||||
String label[]={"java","spring","spring boot","linux","spring cloud",
|
||||
"vue","mybatis","git","sql","quartz","centos7","oauth2.0"
|
||||
,"spring security","redis","shiro"};
|
||||
List<BlogLabel> blogLabels=new ArrayList<>();
|
||||
BlogLabel blogLabel;
|
||||
for(int i=0;i<label.length;i++){
|
||||
blogLabel=new BlogLabel();
|
||||
blogLabel.setId(UUID.randomUUID().toString().replace("-",""));
|
||||
blogLabel.setLabelCode(label[i]);
|
||||
blogLabel.setLabelName(label[i]);
|
||||
blogLabels.add(blogLabel);
|
||||
}
|
||||
/* boolean isOk = blogLabelService.insertList(blogLabels) > 0;
|
||||
System.out.println("录入数据:"+isOk);*/
|
||||
|
||||
}
|
||||
}
|
|
@ -26,22 +26,22 @@
|
|||
password="123456" />
|
||||
<!--mode-->
|
||||
<javaModelGenerator targetPackage="com.len.entity"
|
||||
targetProject="len-activiti/src/main/java">
|
||||
targetProject="len-blog/src/main/java">
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
|
||||
<property name="trimStrings" value="true" />
|
||||
</javaModelGenerator>
|
||||
<!--生成映射文件存放位置-->
|
||||
<sqlMapGenerator targetPackage="com.len.mapper" targetProject="len-activiti/src/main/java" >
|
||||
<sqlMapGenerator targetPackage="com.len.mapper" targetProject="len-blog/src/main/java" >
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
</sqlMapGenerator>
|
||||
<!--生成Dao类存放位置-->
|
||||
<javaClientGenerator targetPackage="com.len.mapper"
|
||||
targetProject="len-activiti/src/main/java" type="XMLMAPPER" >
|
||||
targetProject="len-blog/src/main/java" type="XMLMAPPER" >
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
</javaClientGenerator>
|
||||
<!--生成table 先建表 后生成 勿随意覆盖本身table 避免功能缺失 测试 自己找其他表测试 by zxm-->
|
||||
<table tableName="act_assignee" domainObjectName="ActAssignee">
|
||||
<table tableName="blog_label" domainObjectName="BlogLabel">
|
||||
<generatedKey column="id" sqlStatement="JDBC"/>
|
||||
</table>
|
||||
<!-- enableCountByExample="false"
|
||||
|
|
Loading…
Reference in New Issue