| | |
| | | package com.fgkj.services; |
| | | |
| | | import com.fgkj.dto.Announce; |
| | | import com.fgkj.dto.PageBean; |
| | | import com.fgkj.dto.ServiceModel; |
| | | import com.fgkj.dto.User_inf; |
| | | import com.fgkj.mapper.impl.AnnounceMapper; |
| | | import com.fgkj.mapper.impl.User_infMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class AnnounceService { |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private AnnounceMapper mapper; |
| | | @Autowired |
| | | @Resource |
| | | private User_infMapper userInfMapper; |
| | | |
| | | //发布新公告 |
| | | public ServiceModel add(Object obj) { |
| | | public ServiceModel add(Announce a) { |
| | | ServiceModel model = new ServiceModel(); |
| | | Boolean bl=mapper.add(obj); |
| | | Boolean bl= null; |
| | | try { |
| | | bl = mapper.add(a)>0; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | model.setMsg("添加失败!"); |
| | | return model; |
| | | } |
| | | if(bl){ |
| | | model.setCode(1); |
| | | model.setMsg("添加成功!"); |
| | |
| | | } |
| | | |
| | | //更新公告 |
| | | public ServiceModel update(Object obj) { |
| | | public ServiceModel update(Announce a) { |
| | | ServiceModel model = new ServiceModel(); |
| | | Boolean bl=mapper.update(obj); |
| | | Boolean bl=mapper.update(a)>0; |
| | | if(bl){ |
| | | model.setCode(1); |
| | | model.setMsg("修改成功!"); |
| | |
| | | } |
| | | |
| | | //删除公告 |
| | | public ServiceModel delete(Object obj) { |
| | | public ServiceModel delete(Announce a) { |
| | | ServiceModel model = new ServiceModel(); |
| | | Boolean bl=mapper.del(obj); |
| | | Boolean bl=mapper.del(a)>0; |
| | | if(bl){ |
| | | model.setCode(1); |
| | | model.setMsg("删除成功!"); |
| | |
| | | return model; |
| | | } |
| | | //根据查询条件查询公告 |
| | | public ServiceModel serchByCondition(Object obj){ |
| | | public ServiceModel serchByCondition(Announce a){ |
| | | ServiceModel model = new ServiceModel(); |
| | | List<Announce> list=mapper.serchByCondition(obj); |
| | | //物理分页 |
| | | PageBean pageBean = a.getPageBean(); |
| | | PageHelper.startPage(pageBean.getPageNum(), pageBean.getPageSize()); |
| | | List<Announce> list=mapper.serchByCondition(a); |
| | | PageInfo<Announce> announcePageInfo = new PageInfo<>(list); |
| | | /*for (Object object : list) { |
| | | System.out.println(object); |
| | | }*/ |
| | | if(list!=null&&list.size()>0){ |
| | | for(int i=0;i<list.size();i++){ |
| | | User_inf uinf=new User_inf(); |
| | | uinf.setUId(list.get(i).getUsr_id()); |
| | | uinf.setuId(list.get(i).getUsr_id()); |
| | | List<User_inf> listU=userInfMapper.serchUname(uinf); |
| | | if(listU!=null){ |
| | | list.get(i).setUsr_name(listU.get(listU.size()-1).getUName()); |
| | | list.get(i).setUsr_name(listU.get(listU.size()-1).getuName()); |
| | | }else{ |
| | | list.get(i).setUsr_name(""); |
| | | } |
| | |
| | | if(list!=null && list.size()>0){ |
| | | model.setCode(1); |
| | | model.setMsg("查询成功!"); |
| | | model.setData(list); |
| | | model.setData(announcePageInfo); |
| | | }else{ |
| | | model.setCode(0); |
| | | model.setMsg("查询失败!"); |
| | |
| | | if(list!=null&&list.size()>0){ |
| | | for(int i=0;i<list.size();i++){ |
| | | User_inf uinf=new User_inf(); |
| | | uinf.setUId(list.get(i).getUsr_id()); |
| | | uinf.setuId(list.get(i).getUsr_id()); |
| | | List<User_inf> listU=userInfMapper.serchUname(uinf); |
| | | if(listU!=null){ |
| | | list.get(i).setUsr_name(listU.get(listU.size()-1).getUName()); |
| | | list.get(i).setUsr_name(listU.get(listU.size()-1).getuName()); |
| | | }else{ |
| | | list.get(i).setUsr_name(""); |
| | | } |
| | |
| | | if(list!=null&&list.size()>0){ |
| | | for(int i=0;i<list.size();i++){ |
| | | User_inf uinf=new User_inf(); |
| | | uinf.setUId(list.get(i).getUsr_id()); |
| | | uinf.setuId(list.get(i).getUsr_id()); |
| | | List<User_inf> listU=userInfMapper.serchUname(uinf); |
| | | if(listU!=null){ |
| | | list.get(i).setUsr_name(listU.get(listU.size()-1).getUName()); |
| | | list.get(i).setUsr_name(listU.get(listU.size()-1).getuName()); |
| | | }else{ |
| | | list.get(i).setUsr_name(""); |
| | | } |