|
|
@@ -3,14 +3,14 @@ package com.zhongshu.card.server.core.service.school;
|
|
|
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
|
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
|
|
import com.github.microservice.core.util.bean.BeanUtil;
|
|
|
-import com.zhongshu.card.client.model.org.OrganizationUserSearch;
|
|
|
-import com.zhongshu.card.client.model.org.UserCountAddParam;
|
|
|
-import com.zhongshu.card.client.model.school.ExcelUserParam;
|
|
|
-import com.zhongshu.card.client.model.school.ImportUserModel;
|
|
|
+import com.zhongshu.card.client.model.org.*;
|
|
|
+import com.zhongshu.card.client.model.school.*;
|
|
|
import com.zhongshu.card.client.ret.ResultContent;
|
|
|
+import com.zhongshu.card.client.ret.ResultMessage;
|
|
|
import com.zhongshu.card.client.service.org.UserAccountService;
|
|
|
import com.zhongshu.card.client.service.school.SchoolUserService;
|
|
|
import com.zhongshu.card.client.utils.type.Sex;
|
|
|
+import com.zhongshu.card.server.core.dao.CardInfoDao;
|
|
|
import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
import com.zhongshu.card.server.core.dao.org.OrganizationUserDao;
|
|
|
import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
@@ -57,6 +57,12 @@ public class SchoolUserServiceImpl extends SuperService implements SchoolUserSer
|
|
|
@Autowired
|
|
|
OrganizationDao organizationDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ CardInfoServiceImpl cardInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ CardInfoDao cardInfoDao;
|
|
|
+
|
|
|
/**
|
|
|
* 导入 学校用户excel
|
|
|
*
|
|
|
@@ -181,4 +187,114 @@ public class SchoolUserServiceImpl extends SuperService implements SchoolUserSer
|
|
|
ExcelUtils.commonExecuteExcel(request, response, execlParam);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 编辑或新增加学校用户信息
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultContent addOrUpdateSchoolUser(SchoolUserCountParam param) {
|
|
|
+ List<CardInfoParam> cardInfos = param.getCardInfos();
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ for (CardInfoParam cardInfo : cardInfos) {
|
|
|
+ if (cardInfo.getCardType() == null) {
|
|
|
+ return ResultContent.buildFail("卡片类型不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(cardInfo.getCode())) {
|
|
|
+ return ResultContent.buildFail("卡片号码不能为空");
|
|
|
+ }
|
|
|
+ if (map.containsKey(cardInfo.getCode())) {
|
|
|
+ return ResultContent.buildFail(String.format("卡片号码已存在:%s", cardInfo.getCode()));
|
|
|
+ }
|
|
|
+ map.put("code", cardInfo.getCode());
|
|
|
+ }
|
|
|
+ ResultContent resultContent = userAccountService.update(param);
|
|
|
+ if (resultContent.isFailed()) {
|
|
|
+ return resultContent;
|
|
|
+ }
|
|
|
+ OrganizationUser organizationUser = (OrganizationUser) resultContent.getContent();
|
|
|
+ // 维护卡片信息
|
|
|
+ String userId = organizationUser.getUserId();
|
|
|
+ String oid = organizationUser.getOid();
|
|
|
+ cardInfoDao.deleteByUserIdAndOid(userId, oid);
|
|
|
+ for (CardInfoParam cardInfo : cardInfos) {
|
|
|
+ cardInfo.setUserId(userId);
|
|
|
+ cardInfo.setOid(oid);
|
|
|
+ cardInfoService.addCardInfo(cardInfo);
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询校园端用户详情
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent<SchoolUserModel> getSchoolUserDetail(OrgUserDetailParam param) {
|
|
|
+ SchoolUserModel model = new SchoolUserModel();
|
|
|
+ if (StringUtils.isEmpty(param.getOid())) {
|
|
|
+ param.setOid(getCurrentOid());
|
|
|
+ }
|
|
|
+ Assert.hasText(param.getUserId(), "userId不能为空");
|
|
|
+ Assert.hasText(param.getOid(), "oid不能为空");
|
|
|
+
|
|
|
+ ResultContent<OrganizationUserModel> resultContent = userAccountService.getOrgUserDetail(param);
|
|
|
+ if (resultContent.isFailed()) {
|
|
|
+ return ResultContent.buildFail(resultContent.getMsg());
|
|
|
+ }
|
|
|
+ OrganizationUserModel userModel = resultContent.getContent();
|
|
|
+ BeanUtils.copyProperties(userModel, model);
|
|
|
+
|
|
|
+ // 查询卡片信息
|
|
|
+ List<CardInfoModel> cardInfos = cardInfoService.getUserOrgAllCard(param.getUserId(), param.getOid());
|
|
|
+ model.setCardInfos(cardInfos);
|
|
|
+ return ResultContent.buildSuccess(model);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询用户的所有卡片
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultContent<List<CardInfoModel>> getUserOrgAllCard(OrgUserDetailParam param) {
|
|
|
+ if (StringUtils.isEmpty(param.getOid())) {
|
|
|
+ param.setOid(getCurrentOid());
|
|
|
+ }
|
|
|
+ Assert.hasText(param.getUserId(), "userId不能为空");
|
|
|
+ Assert.hasText(param.getOid(), "oid不能为空");
|
|
|
+ List<CardInfoModel> cardInfos = cardInfoService.getUserOrgAllCard(param.getUserId(), param.getOid());
|
|
|
+ return ResultContent.buildSuccess(cardInfos);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultContent<List<CardInfoModel>> getCurrentUserOrgAll() {
|
|
|
+ String userId = getCurrentUserId();
|
|
|
+ String oid = getCurrentOid();
|
|
|
+ Assert.hasText(userId, "userId不能为空");
|
|
|
+ Assert.hasText(oid, "oid不能为空");
|
|
|
+ List<CardInfoModel> cardInfos = cardInfoService.getUserOrgAllCard(userId, oid);
|
|
|
+ return ResultContent.buildSuccess(cardInfos);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除校园端用户
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultContent deleteUser(String id) {
|
|
|
+ Assert.hasText(id, "id不能为空");
|
|
|
+ OrganizationUser organizationUser = organizationUserDao.findTopById(id);
|
|
|
+ if (ObjectUtils.isEmpty(organizationUser)) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
+ }
|
|
|
+ organizationUserDao.delete(organizationUser);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
}
|