| | |
| | | |
| | | select c.relname as "tab", cast(obj_description(c.oid) as varchar) as "desc", a.attnum as "num", a.attname as "col",atthasdef, |
| | | concat_ws('', t.typname, SUBSTRING(format_type(a.atttypid, a.atttypmod) from '(.*)')) as "type", d.description as "bak" |
| | | select * |
| | | -- select * |
| | | from pg_attribute a left join pg_description d on d.objoid = a.attrelid and d.objsubid = a.attnum left join pg_class c |
| | | on a.attrelid = c.oid left join pg_type t on a.atttypid = t.oid where a.attnum >= 0 and reltype>0 and relnamespace in (135502,69701) |
| | | on a.attrelid = c.oid left join pg_type t on a.atttypid = t.oid where a.attnum >= 0 and reltype>0 and relnamespace in (29257,20582)--135502,69701 |
| | | order by c.relname desc, a.attnum asc; |
| | | |
| | | select pg_constraint.conname as pk_name,pg_attribute.attname as colname,pg_type.typname as typename from |
| | |
| | | package com.lf.server; |
| | | |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| | |
| | | */ |
| | | @EnableSwagger2 |
| | | @SpringBootApplication(scanBasePackages = {"com.lf.server.*"}) |
| | | @MapperScan(basePackages = {"com.lf.server.mapper"}) |
| | | public class LfApplication { |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(LfApplication.class, args); |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.lf.server.entity.bd.DlgAgnp; |
| | | import com.lf.server.entity.bd.DlgAgnpEntity; |
| | | import com.lf.server.helper.PathHelper; |
| | | import com.lf.server.mapper.bd.DlgAgnpMapper; |
| | | import com.lf.server.service.sys.ArgsService; |
| | |
| | | * æµè¯ Mybatis-Plus |
| | | */ |
| | | private void testMybatisPlus() { |
| | | DlgAgnp dlg = dlgAgnpMapper.selectById(1); |
| | | dlg = dlgAgnpMapper.selectOne(2); |
| | | DlgAgnpEntity dlg = dlgAgnpMapper.selectById(1); |
| | | String wkt = dlgAgnpMapper.selectWktById(2); |
| | | |
| | | Map<String, Object> map = new HashMap<String, Object>(3); |
| | | map.put("gid", 2); |
| | | List<DlgAgnp> list1 = dlgAgnpMapper.selectByMap(map); |
| | | List<DlgAgnpEntity> list1 = dlgAgnpMapper.selectByMap(map); |
| | | |
| | | QueryWrapper<DlgAgnp> w1 = new QueryWrapper<>(); |
| | | QueryWrapper<DlgAgnpEntity> w1 = new QueryWrapper<>(); |
| | | w1.eq("name", "æ²»å¤å¿"); |
| | | List<DlgAgnp> list2 = dlgAgnpMapper.selectList(w1); |
| | | List<DlgAgnpEntity> list2 = dlgAgnpMapper.selectList(w1); |
| | | |
| | | UpdateWrapper<DlgAgnp> w2 = new UpdateWrapper<DlgAgnp>(); |
| | | UpdateWrapper<DlgAgnpEntity> w2 = new UpdateWrapper<DlgAgnpEntity>(); |
| | | // è®¾ç½®æ´æ°å
容 |
| | | w2.set("name", "newName").set("gb", "10013") |
| | | // è®¾ç½®æ´æ°æ¡ä»¶ |
| | |
| | | ids.add(1); |
| | | ids.add(2); |
| | | // dlgAgnpMapper.deleteBatchIds(ids) |
| | | List<DlgAgnp> list3 = dlgAgnpMapper.selectBatchIds(ids); |
| | | List<DlgAgnpEntity> list3 = dlgAgnpMapper.selectBatchIds(ids); |
| | | |
| | | // dlgAgnpMapper.updateById(dlg) |
| | | // List<DlgAgnp> all = dlgAgnpMapper.selectList(null) |
| | | |
| | | // é¡µæ° / æ¯é¡µè®°å½æ° |
| | | Page<DlgAgnp> page = new Page<>(1, 10); |
| | | Page<DlgAgnpEntity> page = new Page<>(1, 10); |
| | | // ååºæåº |
| | | page.addOrder(OrderItem.asc("gid")); |
| | | // å页ï¼Wrapperæ¥è¯¢æ¡ä»¶ |
| | | Page<DlgAgnp> userPage = dlgAgnpMapper.selectPage(page, null); |
| | | Page<DlgAgnpEntity> userPage = dlgAgnpMapper.selectPage(page, null); |
| | | // æ»é¡µæ° / æ»è®°å½æ°ï¼325 / 3247 |
| | | String str = userPage.getPages() + " / " + userPage.getTotal(); |
| | | List<DlgAgnp> list4 = userPage.getRecords(); |
| | | List<DlgAgnpEntity> list4 = userPage.getRecords(); |
| | | |
| | | QueryWrapper<DlgAgnp> w3 = new QueryWrapper<>(); |
| | | QueryWrapper<DlgAgnpEntity> w3 = new QueryWrapper<>(); |
| | | w3.like("name", "å¤").ge("gid", 100); |
| | | List<DlgAgnp> list5 = dlgAgnpMapper.selectList(w3); |
| | | List<DlgAgnpEntity> list5 = dlgAgnpMapper.selectList(w3); |
| | | } |
| | | } |
| | |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.bd.DlgAgnp; |
| | | import com.lf.server.entity.bd.DlgAgnpEntity; |
| | | import com.lf.server.service.show.ComprehensiveService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | @ApiImplicitParam(name = "pageIndex", value = "å页æ°ï¼ä»1å¼å§ï¼", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectAddrByPage") |
| | | public ResponseMsg<List<DlgAgnp>> selectAddrByPage(String name, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<DlgAgnpEntity>> selectAddrByPage(String name, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("æ¯é¡µé¡µæ°æå页æ°å°äº1", null); |
| | | } |
| | | |
| | | Page<DlgAgnp> paged = comprehensiveService.selectAddrByPage(name, pageSize, pageIndex); |
| | | Page<DlgAgnpEntity> paged = comprehensiveService.selectAddrByPage(name, pageSize, pageIndex); |
| | | |
| | | return success(paged.getTotal(), paged.getRecords()); |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ ¹æ®IDæ¥è¯¢-å°åå°å") |
| | | @ApiOperation(value = "æ ¹æ®IDæ¥è¯¢WKT-å°åå°å") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectAddrById") |
| | | public ResponseMsg<DlgAgnp> selectAddrById(Integer id) { |
| | | @GetMapping(value = "/selectWktById") |
| | | public ResponseMsg<String> selectWktById(Integer id) { |
| | | try { |
| | | DlgAgnp entity = comprehensiveService.selectAddrById(id); |
| | | String wkt = comprehensiveService.selectWktById(id); |
| | | |
| | | return success(entity); |
| | | return success(wkt); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.lf.server.entity.bd; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.io.Serializable; |
| | | import java.sql.Timestamp; |
| | | |
| | | /** |
| | | * DlgAgnp |
| | | * @author WWW |
| | | */ |
| | | @Data |
| | | @AllArgsConstructor |
| | | @TableName("bd.dlg_agnp") |
| | | public class DlgAgnpEntity implements Serializable { |
| | | private static final long serialVersionUID = 558385325390093696L; |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | | private Integer gid; |
| | | |
| | | private Long objectid; |
| | | |
| | | private String gb; |
| | | |
| | | private String name; |
| | | |
| | | @TableField(value = "class") |
| | | private String clazz; |
| | | |
| | | private String pinyin; |
| | | |
| | | private String pac; |
| | | |
| | | private String bsm; |
| | | |
| | | @TableField(select = false) |
| | | private String geom; |
| | | |
| | | public DlgAgnpEntity() { |
| | | } |
| | | |
| | | public Integer getGid() { |
| | | return gid; |
| | | } |
| | | |
| | | public void setGid(Integer gid) { |
| | | this.gid = gid; |
| | | } |
| | | |
| | | public Long getObjectid() { |
| | | return objectid; |
| | | } |
| | | |
| | | public void setObjectid(Long objectid) { |
| | | this.objectid = objectid; |
| | | } |
| | | |
| | | public String getGb() { |
| | | return gb; |
| | | } |
| | | |
| | | public void setGb(String gb) { |
| | | this.gb = gb; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getClazz() { |
| | | return clazz; |
| | | } |
| | | |
| | | public void setClazz(String clazz) { |
| | | this.clazz = clazz; |
| | | } |
| | | |
| | | public String getPinyin() { |
| | | return pinyin; |
| | | } |
| | | |
| | | public void setPinyin(String pinyin) { |
| | | this.pinyin = pinyin; |
| | | } |
| | | |
| | | public String getPac() { |
| | | return pac; |
| | | } |
| | | |
| | | public void setPac(String pac) { |
| | | this.pac = pac; |
| | | } |
| | | |
| | | public String getBsm() { |
| | | return bsm; |
| | | } |
| | | |
| | | public void setBsm(String bsm) { |
| | | this.bsm = bsm; |
| | | } |
| | | |
| | | public String getGeom() { |
| | | return geom; |
| | | } |
| | | |
| | | public void setGeom(String geom) { |
| | | this.geom = geom; |
| | | } |
| | | } |
| | |
| | | package com.lf.server.mapper.bd; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.lf.server.entity.bd.DlgAgnp; |
| | | import com.lf.server.entity.bd.DlgAgnpEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | /** |
| | | * å°åå°å |
| | | * DlgAgnp |
| | | * @author WWW |
| | | */ |
| | | @Mapper |
| | | @Repository |
| | | public interface DlgAgnpMapper extends BaseMapper<DlgAgnp> { |
| | | public interface DlgAgnpMapper extends BaseMapper<DlgAgnpEntity> { |
| | | /** |
| | | * æ¥è¯¢ä¸æ¡ |
| | | * æ ¹æ®IDæ¥è¯¢WKT |
| | | * |
| | | * @param gid |
| | | * @return |
| | | */ |
| | | @Select("select gid,gb,name,st_astext(geom) geom from bd.dlg_agnp where gid = #{gid}") |
| | | DlgAgnp selectOne(@Param("gid") Integer gid); |
| | | @Select("select st_astext(geom) geom from bd.dlg_agnp where gid = #{gid}") |
| | | String selectWktById(@Param("gid") Integer gid); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.lf.server.entity.bd.DlgAgnp; |
| | | import com.lf.server.entity.bd.DlgAgnpEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.mapper.bd.DlgAgnpMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Autowired |
| | | DlgAgnpMapper dlgAgnpMapper; |
| | | |
| | | public Page<DlgAgnp> selectAddrByPage(String name, Integer pageSize, Integer pageIndex) { |
| | | Page<DlgAgnp> paging = new Page<>(pageIndex, pageSize); |
| | | public Page<DlgAgnpEntity> selectAddrByPage(String name, Integer pageSize, Integer pageIndex) { |
| | | Page<DlgAgnpEntity> paging = new Page<>(pageIndex, pageSize); |
| | | paging.addOrder(OrderItem.asc("gid")); |
| | | |
| | | QueryWrapper<DlgAgnp> wrapper = null; |
| | | QueryWrapper<DlgAgnpEntity> wrapper = null; |
| | | if (!StringHelper.isEmpty(name)) { |
| | | wrapper = new QueryWrapper<>(); |
| | | wrapper.like("name", name.trim()); |
| | |
| | | return dlgAgnpMapper.selectPage(paging, wrapper); |
| | | } |
| | | |
| | | public DlgAgnp selectAddrById(Integer id) { |
| | | return dlgAgnpMapper.selectOne(id); |
| | | public String selectWktById(Integer id) { |
| | | return dlgAgnpMapper.selectWktById(id); |
| | | } |
| | | } |