package com.wgcloud.service; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.wgcloud.entity.HostGroup; import com.wgcloud.mapper.HostGroupMapper; import com.wgcloud.util.DateUtil; import com.wgcloud.util.HostUtil; import com.wgcloud.util.UUIDUtil; import com.wgcloud.util.staticvar.StaticKeys; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletRequest; import java.util.List; import java.util.Map; /** * @version v3.3 * @ClassName:HostGroupService.java * @author: http://www.wgstart.com * @date: 2021年1月16日 * @Description: HostGroupService.java * @Copyright: 2017-2021 wgcloud. All rights reserved. */ @Service public class HostGroupService { public PageInfo selectByParams(Map params, int currPage, int pageSize) throws Exception { PageHelper.startPage(currPage, pageSize); List list = hostGroupMapper.selectByParams(params); PageInfo pageInfo = new PageInfo(list); return pageInfo; } public void save(HostGroup HostGroup) throws Exception { HostGroup.setId(UUIDUtil.getUUID()); HostGroup.setCreateTime(DateUtil.getNowTime()); hostGroupMapper.save(HostGroup); } @Transactional public int deleteById(String[] id) throws Exception { return hostGroupMapper.deleteById(id); } public void updateById(HostGroup HostGroup) throws Exception { hostGroupMapper.updateById(HostGroup); } public HostGroup selectById(String id) throws Exception { return hostGroupMapper.selectById(id); } public List selectAllByParams(Map params) throws Exception { return hostGroupMapper.selectAllByParams(params); } public int countByParams(Map params) throws Exception { return hostGroupMapper.countByParams(params); } /** * 保存操作日志 * * @param request 获取当前登录用户 * @param action 操作标识 */ public void saveLog(HttpServletRequest request, String action, HostGroup hostGroup) { if (null == hostGroup) { return; } logInfoService.save(HostUtil.getAccountByRequest(request).getAccount() + action + "分组信息:" + hostGroup.getGroupName(), "主机分组:" + hostGroup.getRemark(), StaticKeys.LOG_XTCZ); } @Autowired private HostGroupMapper hostGroupMapper; @Autowired private LogInfoService logInfoService; }