//package jj.tech.paolu.biz.webadmin.controller;
//
//import jj.tech.paolu.biz.webadmin.dao.SelectMapper;
//import jj.tech.paolu.repository.mybatis.dao.SysAreaMapper;
//import jj.tech.paolu.repository.mybatis.dao.support.SysAreaDynamicSqlSupport;
//import jj.tech.paolu.utils.R;
//import org.mybatis.dynamic.sql.render.RenderingStrategies;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;
//import static org.mybatis.dynamic.sql.SqlBuilder.select;
//
//@RestController
//@RequestMapping(value = "/op/area", name = "组织机构管理")
//public class SysAreasController {
//
//    @Autowired
//    public SysAreaMapper sysAreaMapper;
//    @Autowired
//    public SelectMapper selectMapper;
//
//    @PostMapping("findById/{id}")
//    public Object findById(@PathVariable("id") String id) {
//        return R.SUCCESS(sysAreaMapper.selectByPrimaryKey(id).orElse(null));
//    }
//
//    /**
//     * 获取省列表
//     *
//     * @return
//     */
//    @PostMapping("findProvince")
//    public Object findProvince() {
//        short level_code = 1;
//        var sql = select(
//                SysAreaDynamicSqlSupport.name,
//                SysAreaDynamicSqlSupport.parent_code,
//                SysAreaDynamicSqlSupport.area_code
//                )
//                .from(SysAreaDynamicSqlSupport.sysArea)
//                .applyWhere(whereFinisher -> whereFinisher
//                        .and(SysAreaDynamicSqlSupport.level_code, isEqualTo(level_code))
//                )
//                .build().render(RenderingStrategies.MYBATIS3);
//        return R.SUCCESS(selectMapper.selectMany(sql));
//    }
//
//    /**
//     * 获取省下面的市
//     * @return
//     */
//    @PostMapping("findCity/{area_code}")
//    public Object findCity(@PathVariable("area_code") String area_code) {
//        short level_code = 2;
//        var sql = select(
//                SysAreaDynamicSqlSupport.name,
//                SysAreaDynamicSqlSupport.parent_code,
//                SysAreaDynamicSqlSupport.area_code
//        )
//                .from(SysAreaDynamicSqlSupport.sysArea)
//                .applyWhere(whereFinisher -> whereFinisher
//                        .and(SysAreaDynamicSqlSupport.level_code, isEqualTo(level_code))
//                        .and(SysAreaDynamicSqlSupport.parent_code, isEqualTo(area_code))
//                )
//                .build().render(RenderingStrategies.MYBATIS3);
//        return R.SUCCESS(selectMapper.selectMany(sql));
//    }
//
//}
