| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Utils; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public String create(Sites sites) { |
| | | LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | |
| | | QueryWrapper<Sites> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Sites::getCode,sites.getCode()); |
| | | Integer count = sitesMapper.selectCount(wrapper); |
| | | if (count > 0){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"站点编号已存在"); |
| | | } |
| | | Sites insert = new Sites(); |
| | | insert.setCreateDate(new Date()); |
| | | insert.setCreator(principal.getId()); |
| | | insert.setEditDate(new Date()); |
| | | insert.setEditor(principal.getId()); |
| | | insert.setIsdeleted(Constants.ZERO); |
| | | insert.setInfo(sites.getInfo()); |
| | | insert.setName(sites.getName()); |
| | | insert.setCode(sites.getCode()); |
| | | insert.setStatus(sites.getStatus()); |
| | | insert.setLockNum(sites.getLockNum()); |
| | | insert.setIp(sites.getIp()); |
| | | sitesMapper.insert(sites); |
| | | return sites.getId(); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void updateById(Sites sites) { |
| | | sitesMapper.updateById(sites); |
| | | LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | Sites update = new Sites(); |
| | | update.setCreateDate(new Date()); |
| | | update.setEditor(principal.getId()); |
| | | update.setName(sites.getName()); |
| | | update.setLockNum(sites.getLockNum()); |
| | | update.setIp(sites.getIp()); |
| | | sitesMapper.updateById(update); |
| | | } |
| | | |
| | | @Override |
| | |
| | | QueryWrapper<Sites> wrapper = new QueryWrapper<>(sites); |
| | | return sitesMapper.selectList(wrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public PageData<Sites> findPage(PageWrap<Sites> pageWrap) { |
| | | IPage<Sites> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |