فهرست منبع

Merge branch 'master' of https://gitee.com/zouxuan/mec

zouxuan 5 سال پیش
والد
کامیت
2759d33ee4

+ 0 - 92
mec-auth/mec-auth-api/src/main/java/com/ym/mec/auth/api/entity/SysDept.java

@@ -1,92 +0,0 @@
-package com.ym.mec.auth.api.entity;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
-/**
- * 对应数据库表(sys_dept):
- */
-public class SysDept {
-
-	/**  */
-	private Integer id;
-	
-	/** 部门名称 */
-	private String name;
-	
-	/** 排序 */
-	private Integer sort;
-	
-	/** 创建时间 */
-	private java.util.Date createTime;
-	
-	/** 修改时间 */
-	private java.util.Date updateTime;
-	
-	/** 是否删除  -1:已删除  0:正常 */
-	private String delFlag;
-	
-	/**  */
-	private Integer parentId;
-
-	public Integer getId() {
-		return id;
-	}
-
-	public void setId(Integer id) {
-		this.id = id;
-	}
-
-	public void setName(String name){
-		this.name = name;
-	}
-	
-	public String getName(){
-		return this.name;
-	}
-			
-	public void setSort(Integer sort){
-		this.sort = sort;
-	}
-	
-	public Integer getSort(){
-		return this.sort;
-	}
-			
-	public void setCreateTime(java.util.Date createTime){
-		this.createTime = createTime;
-	}
-	
-	public java.util.Date getCreateTime(){
-		return this.createTime;
-	}
-			
-	public void setUpdateTime(java.util.Date updateTime){
-		this.updateTime = updateTime;
-	}
-	
-	public java.util.Date getUpdateTime(){
-		return this.updateTime;
-	}
-			
-	public void setDelFlag(String delFlag){
-		this.delFlag = delFlag;
-	}
-	
-	public String getDelFlag(){
-		return this.delFlag;
-	}
-			
-	public void setParentId(Integer parentId){
-		this.parentId = parentId;
-	}
-	
-	public Integer getParentId(){
-		return this.parentId;
-	}
-			
-	@Override
-	public String toString() {
-		return ToStringBuilder.reflectionToString(this);
-	}
-
-}

+ 0 - 37
mec-auth/mec-auth-api/src/main/java/com/ym/mec/auth/api/entity/SysDeptRelation.java

@@ -1,37 +0,0 @@
-package com.ym.mec.auth.api.entity;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
-/**
- * 对应数据库表(sys_dept_relation):
- */
-public class SysDeptRelation {
-
-	/** 祖先节点 */
-	private Integer ancestor;
-	
-	/** 后代节点 */
-	private Integer descendant;
-	
-	public void setAncestor(Integer ancestor){
-		this.ancestor = ancestor;
-	}
-	
-	public Integer getAncestor(){
-		return this.ancestor;
-	}
-			
-	public void setDescendant(Integer descendant){
-		this.descendant = descendant;
-	}
-	
-	public Integer getDescendant(){
-		return this.descendant;
-	}
-			
-	@Override
-	public String toString() {
-		return ToStringBuilder.reflectionToString(this);
-	}
-
-}

+ 0 - 9
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/dal/dao/SysDeptDao.java

@@ -1,9 +0,0 @@
-package com.ym.mec.auth.dal.dao;
-
-import com.ym.mec.auth.api.entity.SysDept;
-import com.ym.mec.common.dal.BaseDAO;
-
-public interface SysDeptDao extends BaseDAO<Integer, SysDept> {
-
-	
-}

+ 0 - 9
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/dal/dao/SysDeptRelationDao.java

@@ -1,9 +0,0 @@
-package com.ym.mec.auth.dal.dao;
-
-import com.ym.mec.auth.api.entity.SysDeptRelation;
-import com.ym.mec.common.dal.BaseDAO;
-
-public interface SysDeptRelationDao extends BaseDAO<Integer, SysDeptRelation> {
-
-	
-}

+ 0 - 8
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/SysDeptRelationService.java

@@ -1,8 +0,0 @@
-package com.ym.mec.auth.service;
-
-import com.ym.mec.auth.api.entity.SysDeptRelation;
-import com.ym.mec.common.service.BaseService;
-
-public interface SysDeptRelationService extends BaseService<Integer, SysDeptRelation> {
-
-}

+ 0 - 8
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/SysDeptService.java

@@ -1,8 +0,0 @@
-package com.ym.mec.auth.service;
-
-import com.ym.mec.auth.api.entity.SysDept;
-import com.ym.mec.common.service.BaseService;
-
-public interface SysDeptService extends BaseService<Integer, SysDept> {
-
-}

+ 0 - 23
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/impl/SysDeptRelationServiceImpl.java

@@ -1,23 +0,0 @@
-package com.ym.mec.auth.service.impl;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import com.ym.mec.auth.api.entity.SysDeptRelation;
-import com.ym.mec.auth.dal.dao.SysDeptRelationDao;
-import com.ym.mec.auth.service.SysDeptRelationService;
-import com.ym.mec.common.dal.BaseDAO;
-import com.ym.mec.common.service.impl.BaseServiceImpl;
-
-@Service
-public class SysDeptRelationServiceImpl extends BaseServiceImpl<Integer, SysDeptRelation> implements SysDeptRelationService {
-
-	@Autowired
-	private SysDeptRelationDao sysDeptRelationDao;
-
-	@Override
-	public BaseDAO<Integer, SysDeptRelation> getDAO() {
-		return sysDeptRelationDao;
-	}
-
-}

+ 0 - 23
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/impl/SysDeptServiceImpl.java

@@ -1,23 +0,0 @@
-package com.ym.mec.auth.service.impl;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import com.ym.mec.auth.api.entity.SysDept;
-import com.ym.mec.auth.dal.dao.SysDeptDao;
-import com.ym.mec.auth.service.SysDeptService;
-import com.ym.mec.common.dal.BaseDAO;
-import com.ym.mec.common.service.impl.BaseServiceImpl;
-
-@Service
-public class SysDeptServiceImpl extends BaseServiceImpl<Integer, SysDept>  implements SysDeptService {
-	
-	@Autowired
-	private SysDeptDao sysDeptDao;
-
-	@Override
-	public BaseDAO<Integer, SysDept> getDAO() {
-		return sysDeptDao;
-	}
-	
-}

+ 0 - 76
mec-auth/mec-auth-server/src/main/resources/config/mybatis/SysDeptMapper.xml

@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<!--
-这个文件是自动生成的。
-不要修改此文件。所有改动将在下次重新自动生成时丢失。
--->
-<mapper namespace="com.ym.mec.auth.dal.dao.SysDeptDao">
-	
-	<resultMap type="com.ym.mec.auth.api.entity.SysDept" id="SysDept">
-		<result column="id_" property="id" />
-		<result column="name_" property="name" />
-		<result column="sort_" property="sort" />
-		<result column="create_time_" property="createTime" />
-		<result column="update_time_" property="updateTime" />
-		<result column="del_flag_" property="delFlag" />
-		<result column="parent_id_" property="parentId" />
-	</resultMap>
-	
-	<!-- 根据主键查询一条记录 -->
-	<select id="get" resultMap="SysDept" >
-		SELECT * FROM sys_dept WHERE id_ = #{id}
-	</select>
-	
-	<!-- 全查询 -->
-	<select id="findAll" resultMap="SysDept">
-		SELECT * FROM sys_dept ORDER BY id_
-	</select>
-	
-	<!-- 向数据库增加一条记录 -->
-	<insert id="insert" parameterType="com.ym.mec.auth.api.entity.SysDept" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		<!--
-		<selectKey resultClass="int" keyProperty="id" > 
-		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
-		</selectKey>
-		-->
-		INSERT INTO sys_dept (id_,name_,sort,create_time_,update_time_,del_flag_,parent_id_) VALUES(#{id},#{name},#{sort},#{createTime},#{updateTime},#{delFlag},#{parentId})
-	</insert>
-	
-	<!-- 根据主键查询一条记录 -->
-	<update id="update" parameterType="com.ym.mec.auth.api.entity.SysDept">
-		UPDATE sys_dept
-		 <set>
-			 <if test="delFlag != null">
-				 del_flag_ = #{delFlag},
-			 </if>
-			 <if test="updateTime != null">
-				 update_time_ = #{updateTime},
-			 </if>
-			 <if test="parentId != null">
-				 parent_id_ = #{parentId},
-			 </if>
-			 <if test="name != null">
-				 name_ = #{name},
-			 </if>
-			 <if test="sort != null">
-				 sort_ = #{sort},
-			 </if>
-		 </set>
-		 WHERE id_ = #{id}
-	</update>
-	
-	<!-- 根据主键删除一条记录 -->
-	<delete id="delete" >
-		DELETE FROM sys_dept WHERE id_ = #{id}
-	</delete>
-	
-	<!-- 分页查询 -->
-	<select id="queryPage" resultMap="SysDept" parameterType="map">
-		SELECT * FROM sys_dept ORDER BY id_ <include refid="global.limit"/>
-	</select>
-	
-	<!-- 查询当前表的总记录数 -->
-	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM sys_dept
-	</select>
-</mapper>

+ 0 - 48
mec-auth/mec-auth-server/src/main/resources/config/mybatis/SysDeptRelationMapper.xml

@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<!--
-这个文件是自动生成的。
-不要修改此文件。所有改动将在下次重新自动生成时丢失。
--->
-<mapper namespace="com.ym.mec.auth.dal.dao.SysDeptRelationDao">
-	
-	<resultMap type="com.ym.mec.auth.api.entity.SysDeptRelation" id="SysDeptRelation">
-		<result column="ancestor_" property="ancestor" />
-		<result column="descendant_" property="descendant" />
-	</resultMap>
-	
-	<!-- 根据主键查询一条记录 -->
-	<select id="get" resultMap="SysDeptRelation" parameterType="java.util.Map">
-		SELECT * FROM sys_dept_relation WHERE ancestor_ = #{ancestor} AND descendant_ = #{descendant}
-	</select>
-	
-	<!-- 全查询 -->
-	<select id="findAll" resultMap="SysDeptRelation">
-		SELECT * FROM sys_dept_relation ORDER BY ancestor_,descendant_
-	</select>
-	
-	<!-- 向数据库增加一条记录 -->
-	<insert id="insert" parameterType="com.ym.mec.auth.api.entity.SysDeptRelation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		<!--
-		<selectKey resultClass="int" keyProperty="id" > 
-		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
-		</selectKey>
-		-->
-		INSERT INTO sys_dept_relation (ancestor_,descendant_) VALUES(#{ancestor},#{descendant})
-	</insert>
-	
-	<!-- 根据主键删除一条记录 -->
-	<delete id="delete" parameterType="java.util.Map">
-		DELETE FROM sys_dept_relation WHERE ancestor_ = #{ancestor} AND descendant_ = #{descendant}
-	</delete>
-	
-	<!-- 分页查询 -->
-	<select id="queryPage" resultMap="SysDeptRelation" parameterType="map">
-		SELECT * FROM sys_dept_relation ORDER BY ancestor_,descendant_ <include refid="global.limit"/>
-	</select>
-	
-	<!-- 查询当前表的总记录数 -->
-	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM sys_dept_relation
-	</select>
-</mapper>

+ 9 - 3
mec-common/common-core/src/main/java/com/ym/mec/common/config/EnumConverterConfig.java

@@ -14,9 +14,15 @@ public class EnumConverterConfig implements Converter<String, BaseEnum<?, ?>> {
 	}
 
 	private <T extends BaseEnum<?, ?>> T getEnum(Class<T> targerType, String source) {
-		for (T enumObj : targerType.getEnumConstants()) {
-			if (source.equals(String.valueOf(enumObj.getCode()))) {
-				return enumObj;
+		for (T en : targerType.getEnumConstants()) {
+			if (en.getCode() instanceof Integer) {
+				if ((int) en.getCode() == Integer.parseInt(source.toString())) {
+					return en;
+				}
+			} else {
+				if (source.equals(String.valueOf(en.getCode()))) {
+					return en;
+				}
 			}
 		}
 		return null;

+ 40 - 11
mec-common/common-core/src/main/java/com/ym/mec/common/controller/BaseController.java

@@ -1,28 +1,39 @@
 package com.ym.mec.common.controller;
 
-import com.ym.mec.common.entity.HttpCode;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+
 import com.ym.mec.common.entity.HttpResponseResult;
 
+@ControllerAdvice
 public class BaseController {
+	
+	private final static Logger logger = LoggerFactory.getLogger(BaseController.class);
 
 	public static HttpResponseResult succeed(Object object) {
-		return getResponseData(true, HttpCode.DEFAULT_SUCCESS_CODE, object, "");
+		return getResponseData(true, HttpStatus.OK, object, "");
 	}
 
 	public static HttpResponseResult succeed() {
-		return getResponseData(true, HttpCode.DEFAULT_SUCCESS_CODE, null, "");
+		return getResponseData(true, HttpStatus.OK, null, "");
 	}
 
 	public static HttpResponseResult succeed(String message) {
-		return failed(HttpCode.DEFAULT_SUCCESS_CODE, message);
+		return failed(HttpStatus.OK, message);
 	}
 
 	public static HttpResponseResult succeedData(Object obj) {
-		return getResponseData(true, HttpCode.DEFAULT_SUCCESS_CODE, obj, "操作成功");
+		return getResponseData(true, HttpStatus.OK, obj, "操作成功");
 	}
 
 	public static HttpResponseResult warned(String message) {
-		return failed(HttpCode.PART_THROW, message);
+		return failed(HttpStatus.MULTI_STATUS, message);
 	}
 
 	public static HttpResponseResult failed() {
@@ -30,20 +41,38 @@ public class BaseController {
 	}
 
 	public static HttpResponseResult failed(String msg) {
-		return failed(HttpCode.DEFAULT_FAILD_CODE, msg);
+		return failed(HttpStatus.INTERNAL_SERVER_ERROR, msg);
 	}
 
-	public static HttpResponseResult failed(int code, String msg) {
-		return getResponseData(false, code, null, msg);
+	public static HttpResponseResult failed(HttpStatus statusCode, String msg) {
+		return getResponseData(false, statusCode, null, msg);
 	}
 
-	private static HttpResponseResult getResponseData(boolean status, int code, Object data, String message) {
+	private static HttpResponseResult getResponseData(boolean status, HttpStatus statusCode, Object data, String message) {
 		HttpResponseResult obj = new HttpResponseResult();
 		obj.setStatus(status);
-		obj.setCode(code);
+		obj.setCode(statusCode.value());
 		obj.setData(data);
 		obj.setMsg(message);
 		return obj;
 	}
+	
+	/**
+	 * 处理一般异常
+	 * 
+	 * @param ex
+	 * @param request
+	 * @return
+	 */
+	@ExceptionHandler(Exception.class)
+	public HttpResponseResult handleException(Exception ex, HttpServletRequest request) {
+		Throwable e = ExceptionUtils.getRootCause(ex);
+		if (e == null) {
+			e = ex;
+		}
+
+		logger.error("System Error", e);
+		return failed(e.getMessage());
+	}
 
 }

+ 0 - 22
mec-common/common-core/src/main/java/com/ym/mec/common/entity/HttpCode.java

@@ -1,22 +0,0 @@
-package com.ym.mec.common.entity;
-
-/**
- * http状态码
- */
-public class HttpCode {
-
-	/** 未登陆 */
-	public static final int NO_LOGIN = 401;
-
-	/** 无权限 */
-	public static final int NO_PERM = 403;
-
-	/** 部分成功 */
-	public static final int PART_THROW = 206;
-
-	/** 成功 */
-	public static final int DEFAULT_SUCCESS_CODE = 200;
-
-	/** 失败 */
-	public final static int DEFAULT_FAILD_CODE = 300;
-}

+ 0 - 46
mec-common/common-core/src/main/java/com/ym/mec/common/exception/BasicControllerAdvice.java

@@ -1,46 +0,0 @@
-package com.ym.mec.common.exception;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.security.access.AccessDeniedException;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import com.ym.mec.common.controller.BaseController;
-import com.ym.mec.common.entity.HttpResponseResult;
-
-@ControllerAdvice
-public class BasicControllerAdvice extends BaseController {
-
-	private final static Logger logger = LoggerFactory.getLogger(BasicControllerAdvice.class);
-
-	/**
-	 * 处理一般异常
-	 * 
-	 * @param ex
-	 * @param request
-	 * @return
-	 */
-	@ExceptionHandler(Exception.class)
-	@ResponseBody
-	public HttpResponseResult handleException(Exception ex, HttpServletRequest request) {
-		Throwable e = ExceptionUtils.getRootCause(ex);
-		if (e == null) {
-			e = ex;
-		}
-
-		if (e instanceof AccessDeniedException) {
-			logger.error("Access Denied", e);
-			return failed(HttpStatus.FORBIDDEN.value(), "禁止访问");
-		}
-
-		logger.error("System Error", e);
-		return failed(e.getMessage());
-	}
-
-}