Skip to content

Commit

Permalink
remove JSONObject, add Gson
Browse files Browse the repository at this point in the history
  • Loading branch information
hzwy23 committed Jul 9, 2017
1 parent 2907fe3 commit 554cc12
Show file tree
Hide file tree
Showing 142 changed files with 260 additions and 1,516 deletions.
1 change: 1 addition & 0 deletions admin/src/main/java/com/asofdate/AsofdateMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RestController;


@ComponentScan(basePackages = {"com.asofdate.utils", "com.asofdate.hauth"})
@SpringBootApplication
@RestController
Expand Down
2 changes: 1 addition & 1 deletion admin/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#spring.jpa.show-sql=true
#spring.jpa.database=oracle
######################## mysql 连接配置信息 #########################
spring.datasource.url=jdbc:mysql://localhost:3306/etl?useUnicode=true&characterEncoding=UTF-8
spring.datasource.url=jdbc:mysql://localhost:3306/hauth?useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=huang
spring.datasource.driverClassName=com.mysql.jdbc.Driver
Expand Down
2 changes: 1 addition & 1 deletion db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ mysql -uroot -p databasename < ./mysql_init.sql
```


如果是oracle数据库,请连接上数据库后,执行oracle_init.sql脚本。
如果是oracle数据库,暂时不开放,可以自行根据mysql修改,或发送邮件,联系:[email protected]
1,248 changes: 23 additions & 1,225 deletions db/mysql_init.sql

Large diffs are not rendered by default.

165 changes: 0 additions & 165 deletions db/oracle_init.sql

This file was deleted.

19 changes: 19 additions & 0 deletions hauth/bin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>asofdate</artifactId>
<groupId>com.asofdate</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>hauth</artifactId>
<packaging>jar</packaging>

<name>hauth</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.asofdate.hauth.controller;

import com.asofdate.hauth.authentication.JwtService;
import com.asofdate.hauth.dto.PagingDto;
import com.asofdate.hauth.entity.HandleLogEntity;
import com.asofdate.hauth.service.HandleLogService;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand All @@ -22,15 +22,13 @@ public class HandleLogController {
private HandleLogService handleLogService;

@RequestMapping(method = RequestMethod.GET)
public String getAll(HttpServletRequest request) {
public PagingDto<List<HandleLogEntity>> getAll(HttpServletRequest request) {
String domainId = JwtService.getConnUser(request).getDomainID();
String offset = request.getParameter("offset");
String limit = request.getParameter("limit");
List<HandleLogEntity> list = handleLogService.findAll(domainId, Integer.parseInt(offset), Integer.parseInt(limit));
JSONObject jsonObject = new JSONObject();

Integer total = handleLogService.getTotal(domainId);
jsonObject.put("total", total);
jsonObject.put("rows", list);
return jsonObject.toString();
return new PagingDto<List<HandleLogEntity>>(total,list);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
import com.asofdate.utils.Hret;
import com.asofdate.utils.JoinCode;
import com.asofdate.utils.RetMsg;
import org.json.JSONArray;
import org.json.JSONObject;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
Expand Down Expand Up @@ -73,22 +73,18 @@ public String update(HttpServletResponse response, HttpServletRequest request) {

@RequestMapping(value = "/delete", method = RequestMethod.POST)
public String delete(HttpServletResponse response, HttpServletRequest request) {
String JSON = request.getParameter("JSON");
JSONArray jsonArray = new JSONArray(JSON);
List<OrgEntity> list = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject js = (JSONObject) jsonArray.get(i);
String orgId = js.getString("org_id");
String domainId = js.getString("domain_id");
String json = request.getParameter("JSON");
List<OrgEntity> list = new GsonBuilder().create().fromJson(json,
new TypeToken<List<OrgEntity>>(){}.getType());;
for (OrgEntity m:list) {

String orgId = m.getOrg_id();
String domainId = m.getDomain_id();

AuthDTO authDTO = authService.domainAuth(request, domainId, "w");
if (!authDTO.getStatus()) {
return Hret.error(403, "您没有权限删除域【" + domainId + "】中的机构信息", null);
}
OrgEntity entity = new OrgEntity();
entity.setOrg_id(orgId);
entity.setDomain_id(domainId);
list.add(entity);
}

RetMsg retMsg = orgService.delete(list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import com.asofdate.hauth.authentication.JwtService;
import com.asofdate.hauth.dto.AuthDTO;
import com.asofdate.hauth.entity.RoleEntity;
import com.asofdate.hauth.entity.UserRoleEntity;
import com.asofdate.hauth.service.AuthService;
import com.asofdate.hauth.service.RoleService;
import com.asofdate.utils.Hret;
import com.asofdate.utils.JoinCode;
import com.asofdate.utils.ParseJson;
import com.asofdate.utils.RetMsg;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import org.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -50,9 +51,10 @@ public List getOwner(HttpServletRequest request) {
@RequestMapping(value = "/auth", method = RequestMethod.POST)
public String auth(HttpServletResponse response, HttpServletRequest request) {
String modifyUserId = JwtService.getConnUser(request).getUserId();
JSONArray json = new JSONArray(request.getParameter("JSON"));
String json = request.getParameter("JSON");
List<UserRoleEntity> list = new ParseJson<UserRoleEntity>().toList(json);
try {
int size = roleService.auth(json, modifyUserId);
int size = roleService.auth(list, modifyUserId);
if (1 == size) {
return Hret.success(200, "success", null);
}
Expand All @@ -69,9 +71,10 @@ public String auth(HttpServletResponse response, HttpServletRequest request) {
@RequestMapping(value = "/auth/batch", method = RequestMethod.POST)
public String batchAuth(HttpServletResponse response, HttpServletRequest request) {
String modifyUserId = JwtService.getConnUser(request).getUserId();
JSONArray json = new JSONArray(request.getParameter("JSON"));
String json = request.getParameter("JSON");
List<UserRoleEntity> list = new ParseJson<UserRoleEntity>().toList(json);
try {
int size = roleService.batchAuth(json, modifyUserId);
int size = roleService.batchAuth(list, modifyUserId);
if (1 == size) {
return Hret.success(200, "success", null);
}
Expand All @@ -86,9 +89,10 @@ public String batchAuth(HttpServletResponse response, HttpServletRequest request

@RequestMapping(value = "/revoke", method = RequestMethod.POST)
public String revoke(HttpServletResponse response, HttpServletRequest request) {
JSONArray json = new JSONArray(request.getParameter("JSON"));
String json = request.getParameter("JSON");
List<UserRoleEntity> list = new ParseJson<UserRoleEntity>().toList(json);
try {
int size = roleService.revoke(json);
int size = roleService.revoke(list);
if (1 == size) {
return Hret.success(200, "success", null);
}
Expand Down
Loading

0 comments on commit 554cc12

Please sign in to comment.