package com.wgcloud.service; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.wgcloud.entity.AccountInfo; import com.wgcloud.mapper.AccountInfoMapper; 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.Date; import java.util.List; import java.util.Map; /** * @version v3.3 * @ClassName:AccountInfoService.java * @author: http://www.wgstart.com * @date: 2022年6月6日 * @Description: AccountInfoService.java * @Copyright: 2017-2022 wgcloud. All rights reserved. */ @Service public class AccountInfoService { public PageInfo selectByParams(Map params, int currPage, int pageSize) throws Exception { PageHelper.startPage(currPage, pageSize); List list = accountInfoMapper.selectByParams(params); PageInfo pageInfo = new PageInfo(list); return pageInfo; } public void save(AccountInfo AccountInfo) throws Exception { AccountInfo.setId(UUIDUtil.getUUID()); AccountInfo.setCreateTime(new Date()); accountInfoMapper.save(AccountInfo); } @Transactional public int deleteById(String[] id) throws Exception { return accountInfoMapper.deleteById(id); } public void updateById(AccountInfo AccountInfo) throws Exception { accountInfoMapper.updateById(AccountInfo); } public AccountInfo selectById(String id) throws Exception { return accountInfoMapper.selectById(id); } public List selectAllByParams(Map params) throws Exception { return accountInfoMapper.selectAllByParams(params); } public int countByParams(Map params) throws Exception { return accountInfoMapper.countByParams(params); } /** * 保存操作日志 * * @param request 获取当前登录用户 * @param action 操作标识 */ public void saveLog(HttpServletRequest request, String action, AccountInfo accountInfo) { if (null == accountInfo) { return; } logInfoService.save(HostUtil.getAccountByRequest(request).getAccount() + action + "成员账号:" + accountInfo.getAccount(), "成员账号:" + accountInfo.getRemark(), StaticKeys.LOG_XTCZ); } @Autowired private AccountInfoMapper accountInfoMapper; @Autowired private LogInfoService logInfoService; }