Commit adbcc2e2 authored by 刘基明's avatar 刘基明

boolean状态枚举类

parent 38135eb8
package com.tanpu.community.api.constants;
public enum TopicStatusEnum {
TRUE(1,true),FALSE(0,false);
private Integer code;
private boolean status;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
TopicStatusEnum(Integer code, boolean status) {
this.code = code;
this.status = status;
}
}
...@@ -2,6 +2,7 @@ package com.tanpu.community.service; ...@@ -2,6 +2,7 @@ package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.tanpu.community.api.constants.TopicStatusEnum;
import com.tanpu.community.dao.entity.community.TopicEntity; import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.dao.mapper.community.TopicMapper; import com.tanpu.community.dao.mapper.community.TopicMapper;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
...@@ -30,25 +31,25 @@ public class TopicService { ...@@ -30,25 +31,25 @@ public class TopicService {
public void updateTopicToTop(String topicId){ public void updateTopicToTop(String topicId){
TopicEntity topicEntity = new TopicEntity(); TopicEntity topicEntity = new TopicEntity();
topicEntity.setIsTop(1); topicEntity.setIsTop(TopicStatusEnum.TRUE.getCode());
topicMapper.update(topicEntity,new LambdaUpdateWrapper<TopicEntity>().eq(TopicEntity::getId,topicId)); topicMapper.update(topicEntity,new LambdaUpdateWrapper<TopicEntity>().eq(TopicEntity::getId,topicId));
} }
public void updateTopicNotTop(String topicId){ public void updateTopicNotTop(String topicId){
TopicEntity topicEntity = new TopicEntity(); TopicEntity topicEntity = new TopicEntity();
topicEntity.setIsTop(0); topicEntity.setIsTop(TopicStatusEnum.FALSE.getCode());
topicMapper.update(topicEntity,new LambdaUpdateWrapper<TopicEntity>().eq(TopicEntity::getId,topicId)); topicMapper.update(topicEntity,new LambdaUpdateWrapper<TopicEntity>().eq(TopicEntity::getId,topicId));
} }
public void updateTopicToConceal(String topicId){ public void updateTopicToConceal(String topicId){
TopicEntity topicEntity = new TopicEntity(); TopicEntity topicEntity = new TopicEntity();
topicEntity.setIsConceal(1); topicEntity.setIsConceal(TopicStatusEnum.TRUE.getCode());
topicMapper.update(topicEntity,new LambdaUpdateWrapper<TopicEntity>().eq(TopicEntity::getId,topicId)); topicMapper.update(topicEntity,new LambdaUpdateWrapper<TopicEntity>().eq(TopicEntity::getId,topicId));
} }
public void updateTopicNotConceal(String topicId){ public void updateTopicNotConceal(String topicId){
TopicEntity topicEntity = new TopicEntity(); TopicEntity topicEntity = new TopicEntity();
topicEntity.setIsConceal(0); topicEntity.setIsConceal(TopicStatusEnum.FALSE.getCode());
topicMapper.update(topicEntity,new LambdaUpdateWrapper<TopicEntity>().eq(TopicEntity::getId,topicId)); topicMapper.update(topicEntity,new LambdaUpdateWrapper<TopicEntity>().eq(TopicEntity::getId,topicId));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment