wangwei hace 7 años
padre
commit
9328472ef7

+ 0 - 72
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/OrgFunctionController.java

@@ -1,72 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.api.controller;
-
-import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import cn.com.qmth.examcloud.commons.web.helpers.tree.TreeNode;
-import cn.com.qmth.examcloud.commons.web.helpers.tree.TreeUtil;
-import cn.com.qmth.examcloud.commons.web.helpers.tree.ZtreeNode;
-import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
-import cn.com.qmth.examcloud.core.basic.dao.FunctionRepo;
-import cn.com.qmth.examcloud.core.basic.dao.OrgFunctionRepo;
-import cn.com.qmth.examcloud.core.basic.dao.entity.Function;
-import cn.com.qmth.examcloud.core.basic.dao.entity.OrgFunction;
-import io.swagger.annotations.ApiOperation;
-
-/**
- * 机构功能API
- * 
- * @author wang wei
- * @date 2018年4月9日
- */
-@RestController
-@RequestMapping("${$rmp.ctr.basic}/orgFunction")
-public class OrgFunctionController extends ControllerSupport {
-
-	@Autowired
-	OrgFunctionRepo orgFunctionRepo;
-
-	@Autowired
-	FunctionRepo functionRepo;
-
-	@ApiOperation(value = "查询所有功能", notes = "查询")
-	@GetMapping("/getAllFunctions")
-	public ResponseEntity<?> getAllFunctions() {
-		List<Function> allFuncs = functionRepo.findAll();
-
-		List<TreeNode> zTreeData = TreeUtil.convert(allFuncs, ZtreeNode.class);
-		return new ResponseEntity<>(zTreeData, HttpStatus.OK);
-	}
-
-	@ApiOperation(value = "查询机构功能", notes = "查询")
-	@GetMapping("/{id}")
-	public ResponseEntity<?> getOrgFunctions(@PathVariable Long id) {
-		log.debug("getOrgFunctions(). id=" + id);
-		List<OrgFunction> orgFunctions = orgFunctionRepo.getOrgFunctions(id);
-		return new ResponseEntity<>(orgFunctions, HttpStatus.OK);
-	}
-
-	@ApiOperation(value = "修改机构功能", notes = "修改")
-	@PutMapping("/{id}")
-	public ResponseEntity<?> setOrgFunctions(@PathVariable Long id, @RequestBody String[] funcIds) {
-		log.debug("setOrgFunctions(). id=" + id);
-		try {
-			orgFunctionRepo.deleteAllOrgFunctions(id);
-			for (String funcId : funcIds) {
-				orgFunctionRepo.addOrgFunction(id, Long.parseLong(funcId));
-			}
-			return new ResponseEntity<>("", HttpStatus.CREATED);
-		} catch (Exception e) {
-			return new ResponseEntity<>("", HttpStatus.INTERNAL_SERVER_ERROR);
-		}
-	}
-}

+ 0 - 10
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/FunctionRepo.java

@@ -1,10 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.dao;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.repository.query.QueryByExampleExecutor;
-
-import cn.com.qmth.examcloud.core.basic.dao.entity.Function;
-
-public interface FunctionRepo extends JpaRepository<Function, Long>, QueryByExampleExecutor<Function> {
-
-}

+ 0 - 31
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/OrgFunctionRepo.java

@@ -1,31 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.dao;
-
-import java.util.List;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Modifying;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.query.Param;
-import org.springframework.data.repository.query.QueryByExampleExecutor;
-import org.springframework.transaction.annotation.Transactional;
-
-import cn.com.qmth.examcloud.core.basic.dao.entity.OrgFunction;
-import cn.com.qmth.examcloud.core.basic.dao.entity.OrgFunctionPK;
-
-public interface OrgFunctionRepo
-		extends JpaRepository<OrgFunction, OrgFunctionPK>, QueryByExampleExecutor<OrgFunction> {
-
-	@Query(nativeQuery = true, value = "SELECT * from ecs_core_function x,ecs_core_org_function y where x.id=y.function_id and y.org_id = :orgId")
-	List<OrgFunction> getOrgFunctions(@Param("orgId") long orgId);
-
-	@Transactional
-	@Modifying
-	@Query(value = "delete from ecs_core_org_function  where org_id =?1", nativeQuery = true)
-	void deleteAllOrgFunctions(Long orgId);
-
-	@Transactional
-	@Modifying
-	@Query(value = "insert into ecs_core_org_function (org_id,function_id) values(?1,?2)", nativeQuery = true)
-	void addOrgFunction(Long orgId, Long funcId);
-
-}

+ 0 - 160
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/Function.java

@@ -1,160 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.dao.entity;
-
-import java.io.Serializable;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.validation.constraints.NotNull;
-
-import cn.com.qmth.examcloud.commons.web.helpers.tree.TreeNode;
-
-/**
- * 功能
- * 
- * @author wang wei
- * @date 2018年4月9日
- */
-@Entity
-@Table(name = "ecs_core_function")
-public class Function implements Serializable, TreeNode {
-
-	private static final long serialVersionUID = -3894524658332441373L;
-
-	@Id
-	@GeneratedValue
-	@Column(name = "id")
-	private Long funcId;
-
-	/**
-	 * 功能编码
-	 */
-	@NotNull
-	private String funcCode;
-
-	/**
-	 * 父功能id
-	 */
-	@NotNull
-	@Column(name = "parent_id")
-	private Long parentFuncId;
-
-	/**
-	 * 功能名称
-	 */
-	@NotNull
-	private String funcName;
-
-	/**
-	 * 描述
-	 */
-	@NotNull
-	private String description;
-
-	/**
-	 * 权重
-	 */
-	@NotNull
-	private int weigth;
-
-	@Override
-	public String getTreeNodeId() {
-		if (null == funcId) {
-			return null;
-		}
-		return String.valueOf(this.funcId);
-	}
-
-	@Override
-	public void setTreeNodeId(String treeId) {
-		if (null != treeId) {
-			this.funcId = Long.parseLong(treeId);
-		}
-	}
-
-	@Override
-	public String getTreeNodeName() {
-		return this.funcName;
-	}
-
-	@Override
-	public void setTreeNodeName(String treeName) {
-		this.funcName = treeName;
-	}
-
-	@Override
-	public String getParentTreeNodeId() {
-		if (null == this.parentFuncId) {
-			return null;
-		}
-		return String.valueOf(this.parentFuncId);
-	}
-
-	@Override
-	public void setParentTreeNodeId(String parentTreeId) {
-		if (null != parentFuncId) {
-			this.parentFuncId = Long.parseLong(parentTreeId);
-		}
-	}
-
-	public Long getFuncId() {
-		return funcId;
-	}
-
-	public void setFuncId(Long funcId) {
-		this.funcId = funcId;
-	}
-
-	public String getFuncCode() {
-		return funcCode;
-	}
-
-	public void setFuncCode(String funcCode) {
-		this.funcCode = funcCode;
-	}
-
-	public Long getParentFuncId() {
-		return parentFuncId;
-	}
-
-	public void setParentFuncId(Long parentFuncId) {
-		this.parentFuncId = parentFuncId;
-	}
-
-	public String getFuncName() {
-		return funcName;
-	}
-
-	public void setFuncName(String funcName) {
-		this.funcName = funcName;
-	}
-
-	public String getDescription() {
-		return description;
-	}
-
-	public void setDescription(String description) {
-		this.description = description;
-	}
-
-	public int getWeigth() {
-		return weigth;
-	}
-
-	public void setWeigth(int weigth) {
-		this.weigth = weigth;
-	}
-
-	@Override
-	public String getTreeNodeCode() {
-		return null;
-	}
-
-	@Override
-	public void setTreeNodeCode(String code) {
-
-	}
-
-}

+ 0 - 48
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/OrgFunction.java

@@ -1,48 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.dao.entity;
-
-import java.io.Serializable;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.IdClass;
-import javax.persistence.Table;
-
-/**
- * 机构功能关联
- * 
- * @author wang wei
- * @date 2018年4月9日
- */
-@Entity
-@Table(name = "ecs_core_org_function")
-@IdClass(OrgFunctionPK.class)
-public class OrgFunction implements Serializable {
-
-	private static final long serialVersionUID = 3282637192076703638L;
-
-	@Id
-	@Column(name = "org_id")
-	private Long orgId;
-
-	@Id
-	@Column(name = "function_id")
-	private Long funcId;
-
-	public Long getOrgId() {
-		return orgId;
-	}
-
-	public void setOrgId(Long orgId) {
-		this.orgId = orgId;
-	}
-
-	public Long getFuncId() {
-		return funcId;
-	}
-
-	public void setFuncId(Long funcId) {
-		this.funcId = funcId;
-	}
-
-}

+ 0 - 35
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/OrgFunctionPK.java

@@ -1,35 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.dao.entity;
-
-import java.io.Serializable;
-
-/**
- * 机构功能关联 PK
- * 
- * @author wang wei
- * @date 2018年4月9日
- */
-public class OrgFunctionPK implements Serializable {
-
-	private static final long serialVersionUID = -4200806793260092705L;
-
-	private Long orgId;
-
-	private Long funcId;
-
-	public Long getOrgId() {
-		return orgId;
-	}
-
-	public void setOrgId(Long orgId) {
-		this.orgId = orgId;
-	}
-
-	public Long getFuncId() {
-		return funcId;
-	}
-
-	public void setFuncId(Long funcId) {
-		this.funcId = funcId;
-	}
-
-}