parent
df1c83aed2
commit
d3f207fb0b
@ -0,0 +1,31 @@
|
|||||||
|
package com.zh.project0512.mapper;
|
||||||
|
|
||||||
|
import com.zh.project0512.model.CommonWords;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.zh.project0512.model.Tag;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zh
|
||||||
|
* @since 2023-02-16
|
||||||
|
*/
|
||||||
|
public interface CommonWordsMapper extends BaseMapper<CommonWords> {
|
||||||
|
@Update("update commonWords set sortWeight = sortWeight + 1 where sortWeight <> 0;\n" +
|
||||||
|
"insert into commonWords ( title, creatAt,sortWeight) VALUES ( #{title}, #{creatAt},1 );")
|
||||||
|
void addWords(CommonWords words);
|
||||||
|
@Update("<script>" +
|
||||||
|
"update commonWords set sortWeight = -1 where sortWeight = #{origin};\n" +
|
||||||
|
"<if test='originHigherCurrent'> " +
|
||||||
|
"update commonWords set sortWeight = sortWeight + 1 where sortWeight <> 0 and sortWeight >= #{current} and sortWeight < #{origin};"+
|
||||||
|
"</if>" +
|
||||||
|
"<if test='!originHigherCurrent'> " +
|
||||||
|
"update commonWords set sortWeight = sortWeight - 1 where sortWeight <> 0 and sortWeight > #{origin} and sortWeight <= #{current};\n" +
|
||||||
|
"</if>" +
|
||||||
|
"update commonWords set sortWeight = #{current} where sortWeight = -1;" +
|
||||||
|
"</script>")
|
||||||
|
void updSort(int origin, int current, boolean originHigherCurrent);
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.zh.project0512.service;
|
||||||
|
|
||||||
|
import com.zh.project0512.model.CommonWords;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.zh.project0512.model.Tag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zh
|
||||||
|
* @since 2023-02-16
|
||||||
|
*/
|
||||||
|
public interface ICommonWordsService extends IService<CommonWords> {
|
||||||
|
void addWords(CommonWords words);
|
||||||
|
void updSort(int origin, int current, boolean originHigherCurrent);
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.zh.project0512.serviceImpl;
|
||||||
|
|
||||||
|
import com.zh.project0512.mapper.TagMapper;
|
||||||
|
import com.zh.project0512.model.CommonWords;
|
||||||
|
import com.zh.project0512.mapper.CommonWordsMapper;
|
||||||
|
import com.zh.project0512.model.Tag;
|
||||||
|
import com.zh.project0512.service.ICommonWordsService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zh
|
||||||
|
* @since 2023-02-16
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CommonWordsServiceImpl extends ServiceImpl<CommonWordsMapper, CommonWords> implements ICommonWordsService {
|
||||||
|
@Autowired
|
||||||
|
private CommonWordsMapper commonWordsMapper;
|
||||||
|
public void addWords(CommonWords words){
|
||||||
|
commonWordsMapper.addWords(words);
|
||||||
|
}
|
||||||
|
public void updSort(int origin, int current, boolean originHigherCurrent) {
|
||||||
|
commonWordsMapper.updSort(origin, current, originHigherCurrent);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue