1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-08-01 16:38:02 +08:00

Fix IMGroupRepository related class

This commit is contained in:
dengchao@xgtl 2020-04-17 11:12:44 +08:00
parent 0bca180d6b
commit 5837db1bfd
2 changed files with 37 additions and 37 deletions

View File

@ -37,6 +37,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@ -44,6 +45,7 @@ import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.server.ResponseStatusException;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
@ -230,7 +232,7 @@ public class EntIMController extends Handler {
@Menu(type = "im", subtype = "entim")
public ModelAndView groupMore(HttpServletRequest request, @Valid String id) {
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/group/index"));
IMGroup imGroup = imGroupRes.findById(id);
IMGroup imGroup = imGroupRes.findById(id).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("IMGroup %s not found", id)));
view.addObject("imGroup", imGroup);
view.addObject("imGroupUserList", imGroupUserRes.findByImgroupAndOrgi(imGroup, super.getOrgi(request)));
view.addObject("contextid", id);
@ -264,7 +266,7 @@ public class EntIMController extends Handler {
users.forEach(userProxy::attachOrgansPropertiesForUser);
view.addObject("userList", users);
IMGroup imGroup = imGroupRes.findById(id);
IMGroup imGroup = imGroupRes.findById(id).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("IMGroup %s not found", id)));
List<Organ> organs = organRes.findAllById(affiliates);
view.addObject("imGroup", imGroup);
@ -318,12 +320,11 @@ public class EntIMController extends Handler {
@Valid String tipmsg
) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/entim/group/tipmsg"));
IMGroup imGroup = imGroupRes.findById(id);
if (imGroup != null) {
imGroupRes.findById(id).ifPresent(imGroup -> {
imGroup.setTipmessage(tipmsg);
imGroupRes.save(imGroup);
}
view.addObject("imGroup", imGroup);
view.addObject("imGroup", imGroup);
});
return view;
}

View File

@ -1,31 +1,30 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.persistence.repository;
import com.chatopera.cc.model.IMGroup;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface IMGroupRepository extends
JpaRepository<IMGroup, String> {
IMGroup findById(String id);
List<IMGroup> findByCreaterAndOrgi(String user, String orgi);
int countByNameAndOrgi(String name, String orgi);
}
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.persistence.repository;
import com.chatopera.cc.model.IMGroup;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface IMGroupRepository extends JpaRepository<IMGroup, String> {
// IMGroup findById(String id);
List<IMGroup> findByCreaterAndOrgi(String user, String orgi);
int countByNameAndOrgi(String name, String orgi);
}