Commit 9e37f45c authored by luben's avatar luben

Merge branch 'dev-lb' into 'dev'

fix

See merge request !204
parents 305d24c8 8801a5fd
Pipeline #144365 failed with stages
in 6 minutes and 22 seconds
......@@ -876,6 +876,9 @@ public class RegionController extends BaseController {
if(count>0){
throw new RuntimeException("当前菜单存在下级菜单,无法删除");
}
if(gridRegionMapper.countByFourthCode(wgCode)>0){
throw new RuntimeException("当前菜单存在房源,无法删除");
}
GridRegionExample example = new GridRegionExample();
GridRegionExample.Criteria criteria = example.createCriteria();
......@@ -990,10 +993,16 @@ public class RegionController extends BaseController {
return AjaxResult.success();
}
// @RequestMapping(value = "/exchangePosition", method = RequestMethod.GET)
// @ResponseBody
// public AjaxResult exchangePosition(@RequestParam("first") String first,@RequestParam("second") String second) {
// return AjaxResult.success(gridRegionMapper.getFourRegionList(wgCode));
// }
@RequestMapping(value = "/exchangePosition", method = RequestMethod.GET)
@ResponseBody
public void exchangePosition() {
// 用来更新position的接口,重置所有排序
List<String> wgCode = gridRegionMapper.getAllWgCode();
// List<String> wgCode = Arrays.asList("320282001001DL005");
for(String code : wgCode){
gridRegionMapper.initPositionVariable();
gridRegionMapper.updatePositionByWgCodes(code);
}
}
}
......@@ -84,4 +84,12 @@ public interface GridRegionMapper {
int position(@Param("id") String id,@Param("position") int position);
void exchangePosition(@Param("first") String first, @Param("second") String second);
List<String> getAllWgCode();
void initPositionVariable();
int updatePositionByWgCodes(@Param("wgCode") String wgCode);
int countByFourthCode(String code);
}
\ No newline at end of file
......@@ -760,5 +760,28 @@
SET position = #{position} where id = #{id}
</update>
<select id="getAllWgCode" resultType="String">
select wg_code from grid_region
where is_valid = '1' and level = 3
</select>
<!-- 初始化变量 -->
<update id="initPositionVariable">
SET @pos := 0;
</update>
<!-- 更新表中符合条件的数据,将 position 字段从 1 开始递增赋值 -->
<update id="updatePositionByWgCodes" parameterType="String">
UPDATE grid_region
SET position = (@pos := @pos + 1)
WHERE wg_parent_id = #{wgCode}
order by wg_code asc
</update>
<select id="countByFourthCode" resultType="Integer">
select count(*) from house_resource
where four = #{code}
</select>
</mapper>
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