package se.wgcloud.service; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import se.wgcloud.entity.AppInfo; import se.wgcloud.mapper.AppInfoMapper; import se.wgcloud.mapper.AppStateMapper; import se.wgcloud.util.DateUtil; import se.wgcloud.util.UUIDUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Map; /** * @version v2.3 * @ClassName: AppInfoService.java * @author: * @date: 2019年11月16日 * @Description: AppInfoService.java * @Copyright: */ @Service public class AppInfoService { public PageInfo selectByParams(Map params, int currPage, int pageSize) throws Exception { PageHelper.startPage(currPage, pageSize); List list = appInfoMapper.selectByParams(params); PageInfo pageInfo = new PageInfo(list); return pageInfo; } public void save(AppInfo AppInfo) throws Exception { AppInfo.setId(UUIDUtil.getUUID()); AppInfo.setCreateTime(DateUtil.getNowTime()); if (!StringUtils.isEmpty(AppInfo.getAppPid())) { AppInfo.setAppPid(AppInfo.getAppPid().trim()); } appInfoMapper.save(AppInfo); } public int deleteByHostName(Map map) throws Exception { return appInfoMapper.deleteByHostName(map); } @Transactional public void saveRecord(List recordList) throws Exception { if (recordList.size() < 1) { return; } for (AppInfo as : recordList) { as.setId(UUIDUtil.getUUID()); } appInfoMapper.insertList(recordList); } public int countByParams(Map params) throws Exception { return appInfoMapper.countByParams(params); } @Transactional public int deleteById(String[] id) throws Exception { for (String AppInfoId : id) { appStateMapper.deleteByAppInfoId(AppInfoId); } return appInfoMapper.deleteById(id); } @Transactional public void updateRecord(List recordList) throws Exception { if (recordList.size() < 1) { return; } appInfoMapper.updateList(recordList); } public void updateById(AppInfo AppInfo) throws Exception { appInfoMapper.updateById(AppInfo); } public AppInfo selectById(String id) throws Exception { return appInfoMapper.selectById(id); } public List selectAllByParams(Map params) throws Exception { return appInfoMapper.selectAllByParams(params); } @Autowired private AppInfoMapper appInfoMapper; @Autowired private AppStateMapper appStateMapper; }