| | |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import com.highdatas.mdm.util.RedisClient; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | IMasterAuthorUnactiveService masterAuthorUnactiveService; |
| | | @Autowired |
| | | IMasterAuthorSubscribeService masterAuthorSubscribeService; |
| | | @Autowired |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | RedisClient redisClient; |
| | | |
| | | public static final String masterAuthorType = "masterAuthorType"; |
| | | public static final String masterId = "masterId"; |
| | |
| | | |
| | | @RequestMapping(value = "/addOrUpdate", method = RequestMethod.POST) |
| | | public Result deleteModel(@RequestBody MasterAuthor masterAuthor) { |
| | | if (StringUtils.isEmpty(masterAuthor.getMaintainFieldId())) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | if (!StringUtils.isEmpty(masterAuthor.getId())) { |
| | | masterAuthor.setUpdateTime(new Date()); |
| | | }else { |
| | |
| | | |
| | | boolean b = masterAuthor.insertOrUpdate(); |
| | | if (b) { |
| | | redisClient.delByCharacter(masterAuthor.getCharacterId()); |
| | | return Result.success(masterAuthor); |
| | | }else { |
| | | return Result.error(CodeMsg.UPDATE_ERROR); |
| | |
| | | .eq(Constant.PARENT_ID, masterAuthor.getId())); |
| | | masterAuthor.setFields(masterAuthorDetails); |
| | | } |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("type", type); |
| | | object.fluentPut("author",masterAuthorList); |
| | |
| | | } |
| | | |
| | | if (delete) { |
| | | redisClient.delByCharacter(characterId); |
| | | return Result.success(CodeMsg.DELETE_SUCCESS); |
| | | }else { |
| | | return Result.error(CodeMsg.DELETE_ERROR); |
| | |
| | | if (count == 1 && !StringUtils.isEmpty(maintainFieldId)) { |
| | | only = true; |
| | | } |
| | | MasterAuthor masterAuthor = authorService.selectOne(masterAuthorWrapper); |
| | | if (masterAuthor == null) { |
| | | List<MasterAuthor> masterAuthors = authorService.selectList(masterAuthorWrapper); |
| | | if (masterAuthors == null || masterAuthors.isEmpty()) { |
| | | return Result.success(null); |
| | | } |
| | | |
| | | boolean delete = authorDetailService.delete(new EntityWrapper<MasterAuthorDetail>().eq(Constant.PARENT_ID, masterAuthor.getId())); |
| | | if (delete) { |
| | | if (only){ |
| | | delete = masterAuthor.setMaintainFieldId(null).setFieldAuto(false).setMaintainAuto(false).setUpdateTime(new Date()).updateById(); |
| | | }else { |
| | | delete = masterAuthor.deleteById(); |
| | | boolean delete = false; |
| | | for (MasterAuthor masterAuthor : masterAuthors) { |
| | | delete = authorDetailService.delete(new EntityWrapper<MasterAuthorDetail>().eq(Constant.PARENT_ID, masterAuthor.getId())); |
| | | if (delete) { |
| | | if (only){ |
| | | delete = masterAuthor.setMaintainFieldId(null).setFieldAuto(false).setMaintainAuto(false).setUpdateTime(new Date()).updateById(); |
| | | }else { |
| | | delete = masterAuthor.deleteById(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (delete) { |
| | | redisClient.delByCharacter(characterId); |
| | | return Result.success(CodeMsg.DELETE_SUCCESS); |
| | | }else { |
| | | return Result.error(CodeMsg.DELETE_ERROR); |
| | |
| | | if (i > 0) { |
| | | menu.setSubscribe(true); |
| | | } |
| | | |
| | | } |
| | | |
| | | return Result.success(result); |
| | | } |
| | | |
| | | // @RequestMapping(value = "/canLoadData/{userId}", method = RequestMethod.GET) |
| | | // public Result canLoadData(@PathVariable String userId, @RequestParam String tableName, HttpServletRequest request) { |
| | | // TUser user = DbUtils.getUserById(userId); |
| | | // if (user == null) { |
| | | // return Result.error(CodeMsg.USER_NOT_MATHED); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | @RequestMapping(value = "/menu/{userId}", method = RequestMethod.GET) |
| | | public Result<List<SysMenu>> menuList(@PathVariable String userId, HttpServletRequest request) { |
| | | TUser user = DbUtils.getUserById(userId); |
| | |
| | | String maintainFieldId = masterAuthor.getMaintainFieldId(); |
| | | String tableName = masterAuthor.getTableName(); |
| | | List<Maintain> maintainByMaintainField = maintainFieldService.getMaintainByMaintainField(maintainFieldId, tableName); |
| | | maintainSet.addAll(maintainByMaintainField); |
| | | if (maintainByMaintainField != null) { |
| | | maintainSet.addAll(maintainByMaintainField); |
| | | } |
| | | |
| | | } |
| | | int unActiveCnt = masterAuthorUnactiveService.selectCount(new EntityWrapper<MasterAuthorUnactive>().in("maintain_id", maintainSet).eq("user_id", userId)); |
| | | if (maintainSet.size() != unActiveCnt) { |