10 changed files with 407 additions and 6 deletions
@ -0,0 +1,21 @@ |
|||||
|
package com.bnyer.img.dto; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
|
||||
|
@Getter |
||||
|
@Setter |
||||
|
@ApiModel("imgSignRelation分页接收类") |
||||
|
public class ImgSignRelationPageDto extends BasePageDto { |
||||
|
|
||||
|
@ApiModelProperty(value="是否显示") |
||||
|
private String isShow; |
||||
|
|
||||
|
@ApiModelProperty(value="图片id") |
||||
|
private Long imgId; |
||||
|
|
||||
|
@ApiModelProperty(value="标签id") |
||||
|
private Long signId; |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
package com.bnyer.img.dto; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
|
||||
|
@Getter |
||||
|
@Setter |
||||
|
@ApiModel("sign分页接收类") |
||||
|
public class SignPageDto extends BasePageDto { |
||||
|
|
||||
|
@ApiModelProperty(value="标签名称") |
||||
|
private String name; |
||||
|
|
||||
|
@ApiModelProperty(value="是否显示") |
||||
|
private String isShow; |
||||
|
} |
||||
@ -0,0 +1,81 @@ |
|||||
|
package com.bnyer.img.service; |
||||
|
|
||||
|
import com.bnyer.img.domain.ImgSignRelation; |
||||
|
import com.bnyer.img.domain.Sign; |
||||
|
import com.bnyer.img.dto.ImgSignRelationPageDto; |
||||
|
import com.bnyer.img.dto.SignPageDto; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author qyh |
||||
|
* @Date 2022/7/10 21:23 |
||||
|
* @Description |
||||
|
*/ |
||||
|
public interface ImgSignRelationService { |
||||
|
/** |
||||
|
* 新增imgSignRelation |
||||
|
* @param imgSignRelation |
||||
|
* @return |
||||
|
*/ |
||||
|
int insert(ImgSignRelation imgSignRelation); |
||||
|
|
||||
|
/** |
||||
|
* 修改imgSignRelation |
||||
|
* @param imgSignRelation - |
||||
|
* @return - |
||||
|
*/ |
||||
|
int update(ImgSignRelation imgSignRelation); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除imgSignRelation |
||||
|
* @param ids ids |
||||
|
* @return - |
||||
|
*/ |
||||
|
int delete(List<Long> ids); |
||||
|
|
||||
|
/** |
||||
|
* 查询imgSignRelation分页 |
||||
|
* @param dto 分页对象 |
||||
|
* @return - |
||||
|
*/ |
||||
|
List<ImgSignRelation> queryPage(ImgSignRelationPageDto dto); |
||||
|
|
||||
|
/** |
||||
|
* 查询imgSignRelation详情 |
||||
|
* @param id 主键id |
||||
|
* @return - |
||||
|
*/ |
||||
|
ImgSignRelation queryDetails(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 查询小程序imgSignRelation列表 |
||||
|
* @param imgId 图片id |
||||
|
* @return - |
||||
|
*/ |
||||
|
List<ImgSignRelation> queryListByImgId(String imgId); |
||||
|
|
||||
|
/** |
||||
|
* 查询小程序imgSignRelation列表 |
||||
|
* @param signId 标签id |
||||
|
* @return - |
||||
|
*/ |
||||
|
List<ImgSignRelation> queryListBySignId(String signId); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 变更显示状态 |
||||
|
* @param id 主键id |
||||
|
* @param status 状态 |
||||
|
* @return - |
||||
|
*/ |
||||
|
int changeStatus(Long id,String status); |
||||
|
|
||||
|
/** |
||||
|
* 根据列名+条件删除 |
||||
|
* @param columnName 要删除的列名 |
||||
|
* @param conditions 根据什么条件删除 |
||||
|
* @return |
||||
|
*/ |
||||
|
int deleteByColumn(String columnName,Long conditions); |
||||
|
} |
||||
@ -1,4 +1,61 @@ |
|||||
package com.bnyer.img.service; |
package com.bnyer.img.service; |
||||
|
|
||||
|
import com.bnyer.img.domain.Banner; |
||||
|
import com.bnyer.img.domain.Sign; |
||||
|
import com.bnyer.img.dto.BannerPageDto; |
||||
|
import com.bnyer.img.dto.SignPageDto; |
||||
|
import com.bnyer.img.vo.BannerVo; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
public interface SignService { |
public interface SignService { |
||||
|
/** |
||||
|
* 新增Sign |
||||
|
* @param sign |
||||
|
* @return |
||||
|
*/ |
||||
|
int insert(Sign sign); |
||||
|
|
||||
|
/** |
||||
|
* 修改sign |
||||
|
* @param sign - |
||||
|
* @return - |
||||
|
*/ |
||||
|
int update(Sign sign); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除sign |
||||
|
* @param ids ids |
||||
|
* @return - |
||||
|
*/ |
||||
|
int delete(List<Long> ids); |
||||
|
|
||||
|
/** |
||||
|
* 查询sign分页 |
||||
|
* @param dto 分页对象 |
||||
|
* @return - |
||||
|
*/ |
||||
|
List<Sign> queryPage(SignPageDto dto); |
||||
|
|
||||
|
/** |
||||
|
* 查询sign详情 |
||||
|
* @param id 主键id |
||||
|
* @return - |
||||
|
*/ |
||||
|
Sign queryDetails(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 查询小程序sign列表 |
||||
|
* @param name 标签名字 |
||||
|
* @return - |
||||
|
*/ |
||||
|
List<Sign> queryList(String name); |
||||
|
|
||||
|
/** |
||||
|
* 变更显示状态 |
||||
|
* @param id 主键id |
||||
|
* @param status 状态 |
||||
|
* @return - |
||||
|
*/ |
||||
|
int changeStatus(Long id,String status); |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,104 @@ |
|||||
|
package com.bnyer.img.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
||||
|
import com.bnyer.common.core.utils.StringUtils; |
||||
|
import com.bnyer.img.domain.Banner; |
||||
|
import com.bnyer.img.domain.ImgSignRelation; |
||||
|
import com.bnyer.img.domain.Sign; |
||||
|
import com.bnyer.img.dto.ImgSignRelationPageDto; |
||||
|
import com.bnyer.img.dto.SignPageDto; |
||||
|
import com.bnyer.img.mapper.ImgSignRelationMapper; |
||||
|
import com.bnyer.img.service.ImgSignRelationService; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author qyh |
||||
|
* @Date 2022/7/10 21:22 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Service |
||||
|
@Slf4j |
||||
|
public class ImgSignRelationServiceImpl implements ImgSignRelationService { |
||||
|
@Autowired |
||||
|
private ImgSignRelationMapper imgSignRelationMapper; |
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int insert(ImgSignRelation imgSignRelation) { |
||||
|
return imgSignRelationMapper.insert(imgSignRelation); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int update(ImgSignRelation imgSignRelation) { |
||||
|
return imgSignRelationMapper.updateById(imgSignRelation); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int delete(List<Long> ids) { |
||||
|
return imgSignRelationMapper.deleteBatchIds(ids); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<ImgSignRelation> queryPage(ImgSignRelationPageDto dto) { |
||||
|
LambdaQueryWrapper<ImgSignRelation> wrapper = new LambdaQueryWrapper<>(); |
||||
|
if(dto.getImgId()!=null){ |
||||
|
wrapper.like(ImgSignRelation::getImgId,dto.getImgId()); |
||||
|
} |
||||
|
if(dto.getSignId()!=null){ |
||||
|
wrapper.eq(ImgSignRelation::getSignId, dto.getSignId()); |
||||
|
} |
||||
|
if(StringUtils.isNotBlank(dto.getIsShow())){ |
||||
|
wrapper.eq(ImgSignRelation::getIsShow, dto.getIsShow()); |
||||
|
} |
||||
|
wrapper.orderByDesc(ImgSignRelation::getSort); |
||||
|
return imgSignRelationMapper.selectList(wrapper); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ImgSignRelation queryDetails(Long id) { |
||||
|
return imgSignRelationMapper.selectById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<ImgSignRelation> queryListByImgId(String imgId) { |
||||
|
QueryWrapper<ImgSignRelation> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq("img_id",imgId); |
||||
|
return imgSignRelationMapper.selectList(wrapper); |
||||
|
} |
||||
|
@Override |
||||
|
public List<ImgSignRelation> queryListBySignId(String signId) { |
||||
|
QueryWrapper<ImgSignRelation> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq("sign_id",signId); |
||||
|
return imgSignRelationMapper.selectList(wrapper); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int changeStatus(Long id, String status) { |
||||
|
LambdaUpdateWrapper<ImgSignRelation> wrapper = new LambdaUpdateWrapper<>(); |
||||
|
wrapper.eq(ImgSignRelation::getId,id); |
||||
|
ImgSignRelation imgSignRelation = new ImgSignRelation(); |
||||
|
imgSignRelation.setIsShow(status); |
||||
|
return imgSignRelationMapper.update(imgSignRelation,wrapper); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int deleteByColumn(String columnName, Long conditions) { |
||||
|
QueryWrapper<ImgSignRelation> wrapper = new QueryWrapper<>(); |
||||
|
if (conditions!=null){ |
||||
|
wrapper.eq(columnName,conditions); |
||||
|
imgSignRelationMapper.delete(wrapper); |
||||
|
} |
||||
|
|
||||
|
return 0; |
||||
|
} |
||||
|
} |
||||
@ -1,10 +1,92 @@ |
|||||
package com.bnyer.img.service.impl; |
package com.bnyer.img.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
||||
|
import com.bnyer.common.core.utils.StringUtils; |
||||
|
import com.bnyer.img.domain.Banner; |
||||
|
import com.bnyer.img.domain.Sign; |
||||
|
import com.bnyer.img.dto.BannerPageDto; |
||||
|
import com.bnyer.img.dto.SignPageDto; |
||||
|
import com.bnyer.img.mapper.SignMapper; |
||||
import com.bnyer.img.service.SignService; |
import com.bnyer.img.service.SignService; |
||||
|
import com.bnyer.img.vo.BannerVo; |
||||
import lombok.extern.slf4j.Slf4j; |
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
@Service |
@Service |
||||
@Slf4j |
@Slf4j |
||||
public class SignServiceImpl implements SignService { |
public class SignServiceImpl implements SignService { |
||||
|
@Autowired |
||||
|
private SignMapper signMapper; |
||||
|
@Autowired |
||||
|
private ImgSignRelationServiceImpl imgSignRelationService; |
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int insert(Sign sign) { |
||||
|
List<Sign> signs = queryList(sign.getName()); |
||||
|
if (signs.size()<=0){ |
||||
|
sign.setCreateTime(new Date()); |
||||
|
sign.setUpdateTime(new Date()); |
||||
|
return signMapper.insert(sign); |
||||
|
} |
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int update(Sign sign) { |
||||
|
sign.setUpdateTime(new Date()); |
||||
|
return signMapper.updateById(sign); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int delete(List<Long> ids) { |
||||
|
//先把img_sign_relation关联的数据删掉
|
||||
|
for (Long id : ids) { |
||||
|
imgSignRelationService.deleteByColumn("sign_id",id); |
||||
|
} |
||||
|
return signMapper.deleteBatchIds(ids); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<Sign> queryPage(SignPageDto dto) { |
||||
|
LambdaQueryWrapper<Sign> wrapper = new LambdaQueryWrapper<>(); |
||||
|
if (StringUtils.isNotBlank(dto.getName())){ |
||||
|
wrapper.like(Sign::getName,dto.getName()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(dto.getIsShow())){ |
||||
|
wrapper.eq(Sign::getIsShow,dto.getIsShow()); |
||||
|
} |
||||
|
wrapper.orderByDesc(Sign::getSort); |
||||
|
return signMapper.selectList(wrapper); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Sign queryDetails(Long id) { |
||||
|
return signMapper.selectById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<Sign> queryList(String name) { |
||||
|
QueryWrapper<Sign> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq("name",name); |
||||
|
return signMapper.selectList(wrapper); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int changeStatus(Long id, String status) { |
||||
|
LambdaUpdateWrapper<Sign> wrapper = new LambdaUpdateWrapper<>(); |
||||
|
wrapper.eq(Sign::getId,id); |
||||
|
Sign sign = new Sign(); |
||||
|
sign.setIsShow(status); |
||||
|
return signMapper.update(sign,wrapper); |
||||
|
} |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue