新增置顶功能
This commit is contained in:
parent
295327fcd7
commit
a65993f8aa
|
@ -77,7 +77,7 @@ public interface DataMapper extends BaseMapper<BcPersonSupport> {
|
||||||
" SELECT '50岁以下' AS age_group, 0 AS min_age, 49 AS max_age, 1 AS id " +
|
" SELECT '50岁以下' AS age_group, 0 AS min_age, 49 AS max_age, 1 AS id " +
|
||||||
" UNION SELECT '50-59岁', 50, 59, 2 " +
|
" UNION SELECT '50-59岁', 50, 59, 2 " +
|
||||||
" UNION SELECT '60-69岁', 60, 69, 3 " +
|
" UNION SELECT '60-69岁', 60, 69, 3 " +
|
||||||
" UNION SELECT '70-79岁', 70, 79, 4 " +
|
" UNION SELECT '70-79岁 ', 70, 79, 4 " +
|
||||||
" UNION SELECT '80-89岁', 80, 89, 5 " +
|
" UNION SELECT '80-89岁', 80, 89, 5 " +
|
||||||
" UNION SELECT '90岁以上', 90, 999, 6 " +
|
" UNION SELECT '90岁以上', 90, 999, 6 " +
|
||||||
") AS age_ranges " +
|
") AS age_ranges " +
|
||||||
|
|
|
@ -80,4 +80,17 @@ public class BcHonorShowController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置置顶
|
||||||
|
*/
|
||||||
|
@PostMapping("/setTop")
|
||||||
|
@PreAuthorize("@ss.hasPermi('honor:show:add')")
|
||||||
|
@Log(title = "荣誉橱窗展示置顶", businessType = BusinessType.UPDATE)
|
||||||
|
public AjaxResult setTop(@Validated @RequestBody IdParams params) {
|
||||||
|
log.info("BcHonorShowController - setTop params:{}", params);
|
||||||
|
|
||||||
|
bcHonorShowService.setTop(params.getId());
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,5 +40,10 @@ public class BcHonorShow extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private String files;
|
private String files;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否置顶 1-是 0-否
|
||||||
|
*/
|
||||||
|
private Integer ifTop;
|
||||||
|
|
||||||
public BcHonorShow() {}
|
public BcHonorShow() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,9 @@ package com.org.web.honor.mapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.org.web.honor.domain.BcHonorShow;
|
import com.org.web.honor.domain.BcHonorShow;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -19,8 +21,19 @@ public interface BcHonorShowMapper extends BaseMapper<BcHonorShow> {
|
||||||
" and title like concat('%', #{title}, '%') " +
|
" and title like concat('%', #{title}, '%') " +
|
||||||
" </if> " +
|
" </if> " +
|
||||||
|
|
||||||
" order by create_time desc " +
|
" order by if_top desc,create_time desc " +
|
||||||
"</script>")
|
"</script>")
|
||||||
List<BcHonorShow> queryList(BcHonorShow params);
|
List<BcHonorShow> queryList(BcHonorShow params);
|
||||||
|
|
||||||
|
// 置顶
|
||||||
|
@Update("<script>" +
|
||||||
|
"update bc_honor_show " +
|
||||||
|
"set if_top = #{ifTop} " +
|
||||||
|
"where 1 = 1 " +
|
||||||
|
" <if test = \"id != null \"> " +
|
||||||
|
" AND id = #{id} " +
|
||||||
|
" </if>" +
|
||||||
|
"</script>")
|
||||||
|
void setTop(@Param("id") Long id, @Param("ifTop") Integer ifTop);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,5 +57,24 @@ public class BcHonorShowService extends ServiceImpl<BcHonorShowMapper, BcHonorSh
|
||||||
public List<BcHonorShow> listShow(BcHonorShow params) {
|
public List<BcHonorShow> listShow(BcHonorShow params) {
|
||||||
return baseMapper.queryList(params);
|
return baseMapper.queryList(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 置顶操作
|
||||||
|
*/
|
||||||
|
public void setTop(Long id) {
|
||||||
|
log.info("BcHonorShowService - setTop id:{}", id);
|
||||||
|
|
||||||
|
BcHonorShow bcHonorShow = getById(id);
|
||||||
|
if (ObjectUtil.isEmpty(bcHonorShow)) {
|
||||||
|
throw new CustomException("数据不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取消 其他数据的 置顶状态
|
||||||
|
baseMapper.setTop(null, 0);
|
||||||
|
|
||||||
|
// 设置当前数据 为置顶
|
||||||
|
baseMapper.setTop(id, 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue