Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master'

lideyin 5 anni fa
parent
commit
65bcf936a1

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

@@ -1,183 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.api.controller;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import javax.persistence.criteria.Predicate;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.domain.Sort.Direction;
-import org.springframework.data.jpa.domain.Specification;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import cn.com.qmth.examcloud.api.commons.security.bean.User;
-import cn.com.qmth.examcloud.commons.exception.StatusException;
-import cn.com.qmth.examcloud.core.basic.api.controller.bean.ExamSiteDomain;
-import cn.com.qmth.examcloud.core.basic.dao.ExamSiteRepo;
-import cn.com.qmth.examcloud.core.basic.dao.entity.ExamSiteEntity;
-import cn.com.qmth.examcloud.core.basic.service.bean.ExamSiteInfo;
-import cn.com.qmth.examcloud.core.basic.service.impl.ExamSiteServiceImpl;
-import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
-import cn.com.qmth.examcloud.web.support.ControllerSupport;
-import io.swagger.annotations.ApiOperation;
-
-/**
- * 考点服务API Created by songyue on 17/1/14.
- */
-@RestController
-@RequestMapping("${$rmp.ctr.basic}/examSite")
-public class ExamSiteController extends ControllerSupport {
-
-	@Autowired
-	ExamSiteRepo examSiteRepo;
-
-	@Autowired
-	ExamSiteServiceImpl examSiteService;
-
-	@ApiOperation(value = "分页查询考点")
-	@GetMapping("examSitePage/{curPage}/{pageSize}")
-	public Page<ExamSiteEntity> getExamSitePage(@PathVariable Integer curPage,
-			@PathVariable Integer pageSize, @RequestParam(required = false) String name,
-			@RequestParam(required = false) String code, @RequestParam(required = true) Long orgId,
-			@RequestParam(required = false) Boolean enable) {
-
-		User accessUser = getAccessUser();
-
-		Specification<ExamSiteEntity> specification = (root, query, cb) -> {
-			List<Predicate> predicates = new ArrayList<>();
-
-			predicates.add(cb.equal(root.get("rootOrgId"), accessUser.getRootOrgId()));
-
-			if (null != orgId) {
-				predicates.add(cb.equal(root.get("orgId"), orgId));
-			}
-
-			if (StringUtils.isNotBlank(name)) {
-				predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
-			}
-			if (StringUtils.isNotBlank(code)) {
-				predicates.add(cb.like(root.get("code"), toSqlSearchPattern(code)));
-			}
-			if (null != enable) {
-				predicates.add(cb.equal(root.get("enable"), enable));
-			}
-
-			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-		};
-
-		PageRequest pageRequest = PageRequest.of(curPage, pageSize,
-				new Sort(Direction.DESC, "updateTime", "id"));
-
-		Page<ExamSiteEntity> page = examSiteRepo.findAll(specification, pageRequest);
-		return page;
-	}
-
-	/**
-	 * 修正
-	 *
-	 * @author WANGWEI
-	 * @param domain
-	 * @return
-	 */
-	@ApiOperation(value = "新增考点", notes = "新增")
-	@PostMapping
-	@Transactional
-	public Long addExamSite(@RequestBody ExamSiteDomain domain) {
-		trim(domain, true);
-
-		User accessUser = getAccessUser();
-		Long rootOrgId = accessUser.getRootOrgId();
-
-		String code = domain.getCode();
-		Long orgId = domain.getOrgId();
-
-		if (StringUtils.isBlank(code)) {
-			throw new StatusException("620001", "code is blank");
-		}
-		if (null == orgId) {
-			throw new StatusException("620002", "orgId is null");
-		}
-
-		ExamSiteEntity es = examSiteRepo.findByOrgIdAndCode(orgId, code);
-		if (null != es) {
-			throw new StatusException("620003", "考点代码已被占用");
-		}
-
-		ExamSiteInfo info = new ExamSiteInfo();
-		info.setRootOrgId(rootOrgId);
-		info.setOrgId(domain.getOrgId());
-		info.setCode(domain.getCode());
-		info.setEnable(domain.getEnable());
-		info.setId(domain.getId());
-		info.setName(domain.getName());
-		info.setRemark(domain.getRemark());
-		info.setTelephone(domain.getTelephone());
-		info.setContacts(domain.getContacts());
-
-		ExamSiteEntity saved = examSiteService.saveExamSite(info);
-		return saved.getId();
-	}
-
-	/**
-	 * 修正
-	 *
-	 * @author WANGWEI
-	 * @param domain
-	 * @return
-	 */
-	@ApiOperation(value = "更新考点", notes = "更新")
-	@PutMapping
-	@Transactional
-	public Long updateCourse(@RequestBody ExamSiteDomain domain) {
-		trim(domain, true);
-
-		User accessUser = getAccessUser();
-		Long rootOrgId = accessUser.getRootOrgId();
-
-		ExamSiteInfo info = new ExamSiteInfo();
-		info.setRootOrgId(rootOrgId);
-		info.setOrgId(domain.getOrgId());
-		info.setCode(domain.getCode());
-		info.setEnable(domain.getEnable());
-		info.setId(domain.getId());
-		info.setName(domain.getName());
-		info.setRemark(domain.getRemark());
-		info.setTelephone(domain.getTelephone());
-		info.setContacts(domain.getContacts());
-
-		ExamSiteEntity saved = examSiteService.saveExamSite(info);
-		return saved.getId();
-	}
-
-	@ApiOperation(value = "删除考点", notes = "删除")
-	@DeleteMapping("{ids}")
-	@Transactional
-	public void deleteExamSite(@PathVariable String ids) {
-		List<Long> examSiteIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
-				.collect(Collectors.toList());
-		for (Long id : examSiteIds) {
-			ExamSiteEntity one = GlobalHelper.getEntity(examSiteRepo, id, ExamSiteEntity.class);
-			if (null == one) {
-				continue;
-			}
-			validateRootOrgIsolation(one.getRootOrgId());
-			examSiteRepo.delete(one);
-		}
-	}
-
-}

+ 0 - 20
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/ExamSiteRepo.java

@@ -1,20 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.dao;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-import org.springframework.data.repository.query.QueryByExampleExecutor;
-
-import cn.com.qmth.examcloud.core.basic.dao.entity.ExamSiteEntity;
-
-/**
- * Created by songyue on 17/1/13.
- */
-public interface ExamSiteRepo
-		extends
-			JpaRepository<ExamSiteEntity, Long>,
-			QueryByExampleExecutor<ExamSiteEntity>,
-			JpaSpecificationExecutor<ExamSiteEntity> {
-
-	ExamSiteEntity findByOrgIdAndCode(Long orgId, String code);
-
-}

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

@@ -1,129 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.dao.entity;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Index;
-import javax.persistence.Table;
-
-import cn.com.qmth.examcloud.web.jpa.JpaEntity;
-
-/**
- * Created by songyue on 17/7/27.
- */
-@Entity
-@Table(name = "EC_B_EXAM_SITE", indexes = {
-		@Index(name = "IDX_B_E_S_003001", columnList = "orgId,code", unique = true),
-		@Index(name = "IDX_B_E_S_003002", columnList = "orgId,name", unique = false)})
-public class ExamSiteEntity extends JpaEntity {
-	private static final long serialVersionUID = 8042526239290337481L;
-
-	@Id
-	@GeneratedValue(strategy = GenerationType.IDENTITY)
-	private Long id;
-
-	@Column(nullable = false)
-	private Long rootOrgId;
-
-	@Column(nullable = false)
-	private Long orgId;
-
-	@Column(nullable = false)
-	private String code;
-
-	@Column(nullable = false)
-	private String name;
-
-	@Column(nullable = false)
-	private Boolean enable;
-
-	/**
-	 * 联系电话
-	 */
-	private String telephone;
-
-	/**
-	 * 联系人
-	 */
-	private String contacts;
-
-	/**
-	 * 备注
-	 */
-	private String remark;
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public Long getRootOrgId() {
-		return rootOrgId;
-	}
-
-	public void setRootOrgId(Long rootOrgId) {
-		this.rootOrgId = rootOrgId;
-	}
-
-	public Long getOrgId() {
-		return orgId;
-	}
-
-	public void setOrgId(Long orgId) {
-		this.orgId = orgId;
-	}
-
-	public String getCode() {
-		return code;
-	}
-
-	public void setCode(String code) {
-		this.code = code;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public Boolean getEnable() {
-		return enable;
-	}
-
-	public void setEnable(Boolean enable) {
-		this.enable = enable;
-	}
-
-	public String getTelephone() {
-		return telephone;
-	}
-
-	public void setTelephone(String telephone) {
-		this.telephone = telephone;
-	}
-
-	public String getContacts() {
-		return contacts;
-	}
-
-	public void setContacts(String contacts) {
-		this.contacts = contacts;
-	}
-
-	public String getRemark() {
-		return remark;
-	}
-
-	public void setRemark(String remark) {
-		this.remark = remark;
-	}
-
-}

+ 0 - 24
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/ExamSiteService.java

@@ -1,24 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.service;
-
-import cn.com.qmth.examcloud.core.basic.dao.entity.ExamSiteEntity;
-import cn.com.qmth.examcloud.core.basic.service.bean.ExamSiteInfo;
-
-/**
- * 类注释
- *
- * @author WANGWEI
- * @date 2018年8月31日
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
- */
-public interface ExamSiteService {
-
-	/**
-	 * 保存考点
-	 *
-	 * @author WANGWEI
-	 * @param info
-	 * @return
-	 */
-	ExamSiteEntity saveExamSite(ExamSiteInfo info);
-
-}

+ 0 - 133
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/ExamSiteServiceImpl.java

@@ -1,133 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.service.impl;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import cn.com.qmth.examcloud.commons.exception.StatusException;
-import cn.com.qmth.examcloud.core.basic.dao.ExamSiteRepo;
-import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
-import cn.com.qmth.examcloud.core.basic.dao.entity.ExamSiteEntity;
-import cn.com.qmth.examcloud.core.basic.dao.entity.OrgEntity;
-import cn.com.qmth.examcloud.core.basic.service.ExamSiteService;
-import cn.com.qmth.examcloud.core.basic.service.bean.ExamSiteInfo;
-import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
-
-/**
- * 类注释
- *
- * @author WANGWEI
- * @date 2018年8月31日
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
- */
-@Service
-public class ExamSiteServiceImpl implements ExamSiteService {
-
-	@Autowired
-	ExamSiteRepo examSiteRepo;
-
-	@Autowired
-	OrgRepo orgRepo;
-
-	@Override
-	public ExamSiteEntity saveExamSite(ExamSiteInfo info) {
-		Long rootOrgId = info.getRootOrgId();
-		Long orgId = info.getOrgId();
-		Long id = info.getId();
-		String code = info.getCode();
-		Boolean enable = info.getEnable();
-		String name = info.getName();
-		String remark = info.getRemark();
-		String contacts = info.getContacts();
-		String telephone = info.getTelephone();
-
-		if (null == rootOrgId) {
-			throw new StatusException("160000", "rootOrgId is null");
-		}
-		if (null == orgId) {
-			throw new StatusException("160001", "rootOrgId is null");
-		}
-		OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
-		if (null == rootOrg) {
-			throw new StatusException("160002", "顶级机构不存在");
-		}
-		if (null != rootOrg.getParentId()) {
-			throw new StatusException("160003", "顶级机构错误");
-		}
-
-		OrgEntity org = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
-		if (null == org) {
-			throw new StatusException("160004", "机构不存在");
-		}
-		if (!org.getParentId().equals(rootOrgId)) {
-			throw new StatusException("160005", "rootOrgId and orgId is not matched");
-		}
-
-		ExamSiteEntity entity = null;
-
-		if (null != id) {
-			entity = GlobalHelper.getEntity(examSiteRepo, id, ExamSiteEntity.class);
-
-			if (null == entity) {
-				throw new StatusException("160006", "考点ID错误");
-			}
-
-			if (!rootOrgId.equals(entity.getRootOrgId())) {
-				throw new StatusException("160007", "顶级机构错误");
-			}
-
-		} else if (StringUtils.isNotBlank(code)) {
-
-			entity = examSiteRepo.findByOrgIdAndCode(orgId, code);
-
-			if (null != entity) {
-				if (null == entity.getEnable()) {
-					entity.setEnable(true);
-				}
-			} else {
-				entity = new ExamSiteEntity();
-				entity.setRootOrgId(rootOrgId);
-				entity.setOrgId(orgId);
-				entity.setCode(code);
-				entity.setEnable(true);
-
-				if (StringUtils.isBlank(name)) {
-					throw new StatusException("160008", "name is blank");
-				}
-			}
-
-		} else {
-			throw new StatusException("160009", "id,code can not be all null");
-		}
-
-		if (null != enable) {
-			entity.setEnable(enable);
-		}
-
-		if (null != name) {
-			if (StringUtils.isBlank(name)) {
-				throw new StatusException("160008", "name is blank");
-			} else {
-				entity.setName(name);
-			}
-
-		}
-
-		if (null != telephone) {
-			entity.setTelephone(telephone);
-		}
-
-		if (null != contacts) {
-			entity.setContacts(contacts);
-		}
-
-		if (null != remark) {
-			entity.setRemark(remark);
-		}
-
-		ExamSiteEntity saved = examSiteRepo.saveAndFlush(entity);
-
-		return saved;
-	}
-
-}

+ 0 - 4
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/OrgServiceImpl.java

@@ -22,7 +22,6 @@ import cn.com.qmth.examcloud.commons.helpers.DynamicEnumManager;
 import cn.com.qmth.examcloud.commons.helpers.poi.ExcelReader;
 import cn.com.qmth.examcloud.commons.util.PathUtil;
 import cn.com.qmth.examcloud.core.basic.base.constants.BasicConsts;
-import cn.com.qmth.examcloud.core.basic.dao.ExamSiteRepo;
 import cn.com.qmth.examcloud.core.basic.dao.OrgPropertyRepo;
 import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
 import cn.com.qmth.examcloud.core.basic.dao.RoleRepo;
@@ -62,9 +61,6 @@ public class OrgServiceImpl implements OrgService {
 	@Autowired
 	UserRepo userRepo;
 
-	@Autowired
-	ExamSiteRepo examSiteRepo;
-
 	@Autowired
 	UserRoleRelationRepo userRoleRelationRepo;