56 changed files with 1548 additions and 729 deletions
@ -0,0 +1,20 @@ |
|||||||
|
package vip.xumy.admin.bmap; |
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan; |
||||||
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||||
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
||||||
|
import org.springframework.context.annotation.ComponentScan; |
||||||
|
|
||||||
|
@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class) |
||||||
|
@ComponentScan(value = "vip.xumy.admin.bmap", useDefaultFilters = true) |
||||||
|
@MapperScan("vip.xumy.admin.bmap.mapper") |
||||||
|
public class BMapInitializer extends SpringBootServletInitializer { |
||||||
|
|
||||||
|
@Override |
||||||
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { |
||||||
|
return builder.sources(BMapInitializer.class); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,75 @@ |
|||||||
|
package vip.xumy.admin.bmap.controller; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
import com.github.pagehelper.Page; |
||||||
|
import com.github.pagehelper.PageHelper; |
||||||
|
|
||||||
|
import vip.xumy.admin.bmap.pojo.CityLocate; |
||||||
|
import vip.xumy.admin.bmap.pojo.DownWorker; |
||||||
|
import vip.xumy.admin.bmap.pojo.WorkContext; |
||||||
|
import vip.xumy.admin.bmap.service.CityLocateService; |
||||||
|
import vip.xumy.admin.bmap.service.LoadWorkService; |
||||||
|
import vip.xumy.admin.bmap.util.DownloadWorker; |
||||||
|
import vip.xumy.core.pojo.com.AjaxResponse; |
||||||
|
import vip.xumy.core.pojo.com.PageResponse; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2021年10月25日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@RestController |
||||||
|
@RequestMapping("bmap") |
||||||
|
public class BMapController { |
||||||
|
@Autowired |
||||||
|
private CityLocateService cityLocateService; |
||||||
|
@Autowired |
||||||
|
private LoadWorkService loadWorkService; |
||||||
|
@Autowired |
||||||
|
private DownloadWorker worker; |
||||||
|
|
||||||
|
@GetMapping("city/list") |
||||||
|
public PageResponse<CityLocate> list(CityLocate example){ |
||||||
|
Page<CityLocate> pages = PageHelper.startPage(example.getPage(), example.getSize()); |
||||||
|
List<CityLocate> list = cityLocateService.list(example); |
||||||
|
PageResponse<CityLocate> rsp = new PageResponse<>(); |
||||||
|
rsp.setRows(list); |
||||||
|
rsp.setTotal(pages.getTotal()); |
||||||
|
return rsp; |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping("work/add") |
||||||
|
public AjaxResponse add(@RequestBody WorkContext context) throws Exception { |
||||||
|
loadWorkService.add(context); |
||||||
|
return new AjaxResponse(true, "添加下载任务成功"); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("work/history") |
||||||
|
public PageResponse<DownWorker> workHistory(int page, int size){ |
||||||
|
Page<DownWorker> pages = PageHelper.startPage(page, size); |
||||||
|
List<DownWorker> list = loadWorkService.history(); |
||||||
|
PageResponse<DownWorker> rsp = new PageResponse<>(); |
||||||
|
rsp.setRows(list); |
||||||
|
rsp.setTotal(pages.getTotal()); |
||||||
|
return rsp; |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("work/wait") |
||||||
|
public List<DownWorker> waitWork(){ |
||||||
|
return loadWorkService.waitList(); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("working") |
||||||
|
public WorkContext working(){ |
||||||
|
return worker.getContext(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
package vip.xumy.admin.bmap.controller; |
||||||
|
|
||||||
|
import java.io.File; |
||||||
|
import java.io.FileInputStream; |
||||||
|
import java.io.IOException; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value; |
||||||
|
import org.springframework.http.MediaType; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||||
|
|
||||||
|
import lombok.extern.log4j.Log4j2; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2020年4月16日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Log4j2 |
||||||
|
@Controller |
||||||
|
@RequestMapping("image") |
||||||
|
public class ImageController { |
||||||
|
@Value("${image.bmap.maptile}") |
||||||
|
private String filePath; |
||||||
|
|
||||||
|
@RequestMapping(value = "tile/{b}/{d}/{a}", produces = MediaType.IMAGE_PNG_VALUE) |
||||||
|
@ResponseBody |
||||||
|
public byte[] getImage(@PathVariable("b") String b, @PathVariable("d") String d, @PathVariable("a") String a) |
||||||
|
throws IOException { |
||||||
|
String path = filePath + "/" + b + "/" + d + "/" + a; |
||||||
|
File file = new File(path); |
||||||
|
if (!file.exists()) { |
||||||
|
log.warn("找不到目标文件:" + path); |
||||||
|
file = new File(filePath, "0.png"); |
||||||
|
} |
||||||
|
try (FileInputStream input = new FileInputStream(file);) { |
||||||
|
byte[] bytes = new byte[input.available()]; |
||||||
|
input.read(bytes); |
||||||
|
return bytes; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
package vip.xumy.admin.bmap.mapper; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Insert; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Select; |
||||||
|
import org.apache.ibatis.annotations.Update; |
||||||
|
|
||||||
|
import vip.xumy.admin.bmap.pojo.CityLocate; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2021年10月25日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Mapper |
||||||
|
public interface ICityLocateMapper { |
||||||
|
static final String BASE_COLUMN = "id, name, level, parent, max_lng, min_lng, max_lat, min_lat, count, space"; |
||||||
|
|
||||||
|
@Insert({ "<script>", "INSERT INTO bmap_city_location ( ", BASE_COLUMN, " ) VALUES ", |
||||||
|
"<foreach collection='list' item='item' separator=','>", |
||||||
|
"(NULL, #{item.name}, #{item.level}, #{item.parent}, #{item.maxLng}, #{item.minLng}, #{item.maxLat}, #{item.minLat}, #{item.count}, #{item.space}) ", |
||||||
|
"</foreach>", "</script>" }) |
||||||
|
void saveBatch(List<CityLocate> cityInfos); |
||||||
|
|
||||||
|
@Select({ "<script>", "SELECT ", BASE_COLUMN, " FROM bmap_city_location ", "<where>", |
||||||
|
"<if test='id != null'> AND id = #{id} </if>", "<if test='level != null'> AND level = #{level} </if>", |
||||||
|
"<if test='name != null'> AND name = #{name} </if>", |
||||||
|
"<if test='parent != null'> AND parent = #{parent} </if>", |
||||||
|
"<if test='partName != null'> AND name like CONCAT('%',#{partName},'%') </if>", "</where>", "</script>" }) |
||||||
|
List<CityLocate> list(CityLocate example); |
||||||
|
|
||||||
|
@Update({ "UPDATE bmap_city_location SET max_lng = #{maxLng}, min_lng = #{minLng}, max_lat = #{maxLat}, ", |
||||||
|
"min_lat = #{minLat}, count = #{count}, space = #{space} WHERE id = #{id}" }) |
||||||
|
void update(CityLocate cityInfo); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
package vip.xumy.admin.bmap.mapper; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Insert; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Options; |
||||||
|
import org.apache.ibatis.annotations.Select; |
||||||
|
import org.apache.ibatis.annotations.Update; |
||||||
|
|
||||||
|
import vip.xumy.admin.bmap.pojo.DownWorker; |
||||||
|
import vip.xumy.admin.bmap.pojo.WorkContext; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2021年10月26日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Mapper |
||||||
|
public interface ILoadWorkMapper { |
||||||
|
static final String INSERT_COLUMN = "city, city_name, add_time, status, min_zom, max_zom, total"; |
||||||
|
|
||||||
|
@Select({ "<script>", "SELECT * FROM bmap_load_work ", "<where>", |
||||||
|
"<if test='cityName != null'> AND city_name like CONCAT('%',#{cityName},'%') </if>", |
||||||
|
"<if test='id != null'> AND id = #{id} </if>", "<if test='city != null'> AND city = #{city} </if>", |
||||||
|
"<if test='status != null'> AND status = #{status} </if>", "</where>", "ORDER BY add_time DESC", |
||||||
|
"</script>" }) |
||||||
|
List<DownWorker> list(DownWorker example); |
||||||
|
|
||||||
|
@Insert({ "<script>", "INSERT INTO bmap_load_work ( ", INSERT_COLUMN, " ) VALUES ", |
||||||
|
"<foreach collection='list' item='item' separator=','>", |
||||||
|
"(#{item.city}, #{item.cityName}, NOW(), 0, #{item.minZom}, #{item.maxZom}, #{item.total}) ", "</foreach>", |
||||||
|
"</script>" }) |
||||||
|
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") |
||||||
|
void saveBatch(List<WorkContext> context); |
||||||
|
|
||||||
|
@Insert({ "<script>", "INSERT INTO bmap_load_work ( ", INSERT_COLUMN, " ) VALUES ", |
||||||
|
"(#{city}, #{cityName}, NOW(), 0, #{minZom}, #{maxZom}, #{total}) ", "</script>" }) |
||||||
|
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") |
||||||
|
void save(WorkContext context); |
||||||
|
|
||||||
|
@Update({ "UPDATE bmap_load_work SET start_time = #{startTime}, end_time = #{endTime}, status = #{status}, ", |
||||||
|
"`exist` = #{exist}, success = #{success}, fail = #{fail}, result = #{result} WHERE id = #{id}" }) |
||||||
|
void update(DownWorker context); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
package vip.xumy.admin.bmap.pojo; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
import vip.xumy.core.pojo.base.BasePageParam; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2021年10月25日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public class CityLocate extends BasePageParam { |
||||||
|
|
||||||
|
private Integer id; |
||||||
|
private String name; |
||||||
|
private Integer level; |
||||||
|
private Integer parent; |
||||||
|
private String maxLng; |
||||||
|
private String minLng; |
||||||
|
private String maxLat; |
||||||
|
private String minLat; |
||||||
|
private Integer count; |
||||||
|
private Long space; |
||||||
|
|
||||||
|
private String partName; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
package vip.xumy.admin.bmap.pojo; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2021年10月26日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public class DownWorker { |
||||||
|
|
||||||
|
private Integer id; |
||||||
|
private Integer city; |
||||||
|
private String cityName; |
||||||
|
private String addTime; |
||||||
|
private String startTime; |
||||||
|
private String endTime; |
||||||
|
private int status; |
||||||
|
private Integer result; |
||||||
|
|
||||||
|
protected int total = 0; |
||||||
|
protected int success = 0; |
||||||
|
protected int fail = 0; |
||||||
|
protected int exist = 0; |
||||||
|
protected int minZom = 1; |
||||||
|
protected int maxZom = 19; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,40 @@ |
|||||||
|
package vip.xumy.admin.bmap.pojo; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2020年4月28日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public class Point { |
||||||
|
|
||||||
|
private int x; |
||||||
|
private int y; |
||||||
|
private int z; |
||||||
|
private double lan; |
||||||
|
private double lat; |
||||||
|
|
||||||
|
public Point(String lan, String lat) { |
||||||
|
super(); |
||||||
|
this.lan = Double.parseDouble(lan); |
||||||
|
this.lat = Double.parseDouble(lat); |
||||||
|
} |
||||||
|
|
||||||
|
public Point(double lan, double lat) { |
||||||
|
super(); |
||||||
|
this.lan = lan; |
||||||
|
this.lat = lat; |
||||||
|
} |
||||||
|
|
||||||
|
public Point(int x, int y, int z) { |
||||||
|
super(); |
||||||
|
this.x = x; |
||||||
|
this.y = y; |
||||||
|
this.z = z; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,105 @@ |
|||||||
|
package vip.xumy.admin.bmap.pojo; |
||||||
|
|
||||||
|
import java.text.MessageFormat; |
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.Iterator; |
||||||
|
import java.util.Set; |
||||||
|
import java.util.concurrent.Future; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
import vip.xumy.admin.bmap.util.BMapTool; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2021年10月26日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public class WorkContext extends DownWorker { |
||||||
|
|
||||||
|
private long start; |
||||||
|
|
||||||
|
private Set<Future<?>> futures = new HashSet<>(); |
||||||
|
private Future<?> submit; |
||||||
|
private Point leftBottom; |
||||||
|
private Point rightTop; |
||||||
|
|
||||||
|
public void setCityInfo(CityLocate city) { |
||||||
|
super.setCity(city.getId()); |
||||||
|
super.setCityName(city.getName()); |
||||||
|
this.leftBottom = new Point(city.getMinLng(), city.getMinLat()); |
||||||
|
this.rightTop = new Point(city.getMaxLng(), city.getMaxLat()); |
||||||
|
this.callTotal(); |
||||||
|
} |
||||||
|
|
||||||
|
private void callTotal() { |
||||||
|
for (int z = minZom; z <= maxZom; z++) { |
||||||
|
leftBottom.setZ(z); |
||||||
|
rightTop.setZ(z); |
||||||
|
BMapTool.callXY(leftBottom); |
||||||
|
BMapTool.callXY(rightTop); |
||||||
|
total += ((rightTop.getX() - leftBottom.getX() + 1) * (rightTop.getY() - leftBottom.getY() + 1)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void addFuture(Future<?> future) { |
||||||
|
futures.add(future); |
||||||
|
} |
||||||
|
|
||||||
|
public void success() { |
||||||
|
super.success++; |
||||||
|
} |
||||||
|
|
||||||
|
public void fail() { |
||||||
|
super.fail++; |
||||||
|
} |
||||||
|
|
||||||
|
public void exist() { |
||||||
|
super.exist++; |
||||||
|
} |
||||||
|
|
||||||
|
public String status() { |
||||||
|
return MessageFormat.format("瓦片总数:{0},下载成功:{1},已存在:{2},下载失败:{3}", total, success, exist, fail); |
||||||
|
} |
||||||
|
|
||||||
|
public int getSize() { |
||||||
|
Iterator<Future<?>> iter = futures.iterator(); |
||||||
|
while (iter.hasNext()) { |
||||||
|
Future<?> future = (Future<?>) iter.next(); |
||||||
|
if (future.isDone() || future.isCancelled()) { |
||||||
|
iter.remove(); |
||||||
|
} |
||||||
|
} |
||||||
|
return futures.size(); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean started() { |
||||||
|
return submit != null; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isDone() { |
||||||
|
if (submit == null) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
return submit != null && submit.isDone() && getSize() == 0; |
||||||
|
} |
||||||
|
|
||||||
|
public long getUsed() { |
||||||
|
return System.currentTimeMillis() - start; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public long getUse() { |
||||||
|
int i = success + fail; |
||||||
|
if (i == 0) { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
int l = total - i - exist; |
||||||
|
double x = l * 1.0 / i; |
||||||
|
long used = System.currentTimeMillis() - start; |
||||||
|
return (long) (used * x); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
package vip.xumy.admin.bmap.service; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import vip.xumy.admin.bmap.mapper.ICityLocateMapper; |
||||||
|
import vip.xumy.admin.bmap.pojo.CityLocate; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2021年10月25日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Service |
||||||
|
public class CityLocateService { |
||||||
|
@Autowired |
||||||
|
private ICityLocateMapper cityLocateMapper; |
||||||
|
|
||||||
|
public List<CityLocate> list(CityLocate example) { |
||||||
|
return cityLocateMapper.list(example); |
||||||
|
} |
||||||
|
|
||||||
|
public CityLocate get(Integer id) { |
||||||
|
CityLocate example = new CityLocate(); |
||||||
|
example.setId(id); |
||||||
|
List<CityLocate> list = cityLocateMapper.list(example); |
||||||
|
if (list == null || list.isEmpty()) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return list.get(0); |
||||||
|
} |
||||||
|
|
||||||
|
public CityLocate get(String name) { |
||||||
|
CityLocate example = new CityLocate(); |
||||||
|
example.setName(name); |
||||||
|
List<CityLocate> list = cityLocateMapper.list(example); |
||||||
|
if (list == null || list.isEmpty()) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return list.get(0); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,71 @@ |
|||||||
|
package vip.xumy.admin.bmap.service; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
import vip.xumy.admin.bmap.mapper.ILoadWorkMapper; |
||||||
|
import vip.xumy.admin.bmap.pojo.CityLocate; |
||||||
|
import vip.xumy.admin.bmap.pojo.DownWorker; |
||||||
|
import vip.xumy.admin.bmap.pojo.WorkContext; |
||||||
|
import vip.xumy.admin.bmap.util.DownloadWorker; |
||||||
|
import vip.xumy.core.exception.CoreException; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2021年10月26日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Service |
||||||
|
public class LoadWorkService { |
||||||
|
@Autowired |
||||||
|
private ILoadWorkMapper loadWorkMapper; |
||||||
|
@Autowired |
||||||
|
private CityLocateService cityLocateService; |
||||||
|
@Autowired |
||||||
|
private DownloadWorker worker; |
||||||
|
|
||||||
|
public List<DownWorker> history() { |
||||||
|
DownWorker example = new WorkContext(); |
||||||
|
example.setStatus(2); |
||||||
|
return loadWorkMapper.list(example); |
||||||
|
} |
||||||
|
|
||||||
|
public List<DownWorker> waitList() { |
||||||
|
DownWorker example = new WorkContext(); |
||||||
|
example.setStatus(0); |
||||||
|
return loadWorkMapper.list(example); |
||||||
|
} |
||||||
|
|
||||||
|
public DownWorker working() { |
||||||
|
DownWorker example = new WorkContext(); |
||||||
|
example.setStatus(1); |
||||||
|
List<DownWorker> list = loadWorkMapper.list(example); |
||||||
|
if (list == null || list.isEmpty()) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return list.get(0); |
||||||
|
} |
||||||
|
|
||||||
|
@Transactional |
||||||
|
public void add(WorkContext context) throws Exception { |
||||||
|
Integer cityId = context.getCity(); |
||||||
|
if (cityId == null) { |
||||||
|
throw new CoreException("请选择城市"); |
||||||
|
} |
||||||
|
CityLocate city = cityLocateService.get(cityId); |
||||||
|
if (city == null) { |
||||||
|
throw new CoreException("未录入该城市对应经纬度,添加失败"); |
||||||
|
} |
||||||
|
context.setCityInfo(city); |
||||||
|
loadWorkMapper.save(context); |
||||||
|
worker.addTask(context); |
||||||
|
} |
||||||
|
|
||||||
|
public void update(DownWorker context) { |
||||||
|
loadWorkMapper.update(context); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,40 @@ |
|||||||
|
package vip.xumy.admin.bmap.util; |
||||||
|
|
||||||
|
import vip.xumy.admin.bmap.pojo.Point; |
||||||
|
|
||||||
|
/** Ownership belongs to the company |
||||||
|
* author:mengyxu |
||||||
|
* date:2020年4月28日 |
||||||
|
*/ |
||||||
|
|
||||||
|
public class BMapTool { |
||||||
|
private static final double[][] BV = new double[][]{ |
||||||
|
new double[]{-0.0015702102444, 111320.7020616939, 1704480524535203L, -10338987376042340L, 26112667856603880L, -35149669176653700L, 26595700718403920L, -10725012454188240L, 1800819912950474L, 82.5}, |
||||||
|
new double[]{8.277824516172526E-4, 111320.7020463578, 6.477955746671607E8, -4.082003173641316E9, 1.077490566351142E10, -1.517187553151559E10, 1.205306533862167E10, -5.124939663577472E9, 9.133119359512032E8, 67.5}, |
||||||
|
new double[]{0.00337398766765, 111320.7020202162, 4481351.045890365, -2.339375119931662E7, 7.968221547186455E7, -1.159649932797253E8, 9.723671115602145E7, -4.366194633752821E7, 8477230.501135234, 52.5}, |
||||||
|
new double[]{0.00220636496208, 111320.7020209128, 51751.86112841131, 3796837.749470245, 992013.7397791013, -1221952.21711287, 1340652.697009075, -620943.6990984312, 144416.9293806241, 37.5}, |
||||||
|
new double[]{-3.441963504368392E-4, 111320.7020576856, 278.2353980772752, 2485758.690035394, 6070.750963243378, 54821.18345352118, 9540.606633304236, -2710.55326746645, 1405.483844121726, 22.5}, |
||||||
|
new double[]{-3.218135878613132E-4, 111320.7020701615, 0.00369383431289, 823725.6402795718, 0.46104986909093, 2351.343141331292, 1.58060784298199, 8.77738589078284, 0.37238884252424, 7.45} |
||||||
|
}; |
||||||
|
|
||||||
|
public static void callXY(Point p) { |
||||||
|
double lan = fix(p.getLan(), -180, 180); |
||||||
|
double lat = fix(p.getLat(), -89.999999, 89.999999); |
||||||
|
int idx = 5 - (int) Math.abs(lat/15); |
||||||
|
double[] b = BV[idx]; |
||||||
|
Double c = b[0] + b[1] * Math.abs(lan); |
||||||
|
double d = Math.abs(lat) / b[9]; |
||||||
|
double e = b[2] + b[3] * d + b[4] * d * d + b[5] * d * d * d + b[6] * d * d * d * d + b[7] * d * d * d * d * d + b[8] * d * d * d * d * d * d; |
||||||
|
c *= (lan < 0 ? -1 : 1); |
||||||
|
e *= (lan < 0 ? -1 : 1); |
||||||
|
double x = Math.floor(c * Math.pow(2, p.getZ() - 18)); |
||||||
|
double y = Math.floor(e * Math.pow(2, p.getZ() - 18)); |
||||||
|
p.setX((int)Math.floor(x / 256)); |
||||||
|
p.setY((int)Math.floor(y / 256)); |
||||||
|
} |
||||||
|
|
||||||
|
private static double fix(double a, double b, double c) { |
||||||
|
return Math.min(Math.max(a, b), c); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,241 @@ |
|||||||
|
package vip.xumy.admin.bmap.util; |
||||||
|
|
||||||
|
import java.io.File; |
||||||
|
import java.io.FileNotFoundException; |
||||||
|
import java.io.FileOutputStream; |
||||||
|
import java.io.InputStream; |
||||||
|
import java.net.ConnectException; |
||||||
|
import java.net.MalformedURLException; |
||||||
|
import java.net.URL; |
||||||
|
import java.text.MessageFormat; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
import java.util.concurrent.ExecutorService; |
||||||
|
import java.util.concurrent.Executors; |
||||||
|
import java.util.concurrent.Future; |
||||||
|
import java.util.concurrent.LinkedBlockingQueue; |
||||||
|
import java.util.concurrent.locks.Lock; |
||||||
|
import java.util.concurrent.locks.ReentrantLock; |
||||||
|
|
||||||
|
import org.springframework.beans.BeanUtils; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.beans.factory.annotation.Value; |
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling; |
||||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import lombok.extern.log4j.Log4j2; |
||||||
|
import vip.xumy.admin.bmap.pojo.DownWorker; |
||||||
|
import vip.xumy.admin.bmap.pojo.Point; |
||||||
|
import vip.xumy.admin.bmap.pojo.WorkContext; |
||||||
|
import vip.xumy.admin.bmap.service.LoadWorkService; |
||||||
|
import vip.xumy.core.utils.DateUtil; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2020年4月10日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Log4j2 |
||||||
|
@Component |
||||||
|
@EnableScheduling |
||||||
|
public class DownloadWorker { |
||||||
|
private static final LinkedBlockingQueue<Point> queue = new LinkedBlockingQueue<>(1000); |
||||||
|
private static final ExecutorService executor = Executors.newFixedThreadPool(100); |
||||||
|
private static final LinkedBlockingQueue<WorkContext> works = new LinkedBlockingQueue<>(500); |
||||||
|
private static final String urlFromat = "http://{0}.bdimg.com/tile/?qt=vtile&x={1}&y={2}&z={3}&styles=pl"; |
||||||
|
private static final String[] MAP_HOSTS = { "maponline0", "maponline1", "maponline2", "maponline3" }; |
||||||
|
|
||||||
|
@Value("${image.bmap.maptile}") |
||||||
|
private String path; |
||||||
|
@Value("${bmap.download.size}") |
||||||
|
private int size; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
public void setWorkService(LoadWorkService workService) { |
||||||
|
this.workService = workService; |
||||||
|
this.init(); |
||||||
|
} |
||||||
|
|
||||||
|
private LoadWorkService workService; |
||||||
|
|
||||||
|
@Getter |
||||||
|
private WorkContext context; |
||||||
|
private Lock lockS = new ReentrantLock(); |
||||||
|
private Lock lockF = new ReentrantLock(); |
||||||
|
private Lock lockE = new ReentrantLock(); |
||||||
|
|
||||||
|
public void init() { |
||||||
|
DownWorker working = workService.working(); |
||||||
|
if (working != null) { |
||||||
|
working.setStatus(2); |
||||||
|
working.setResult(2); |
||||||
|
workService.update(working); |
||||||
|
} |
||||||
|
List<DownWorker> waitList = workService.waitList(); |
||||||
|
if (waitList == null || waitList.isEmpty()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
for (int i = waitList.size(); i > 0; i--) { |
||||||
|
DownWorker worker = waitList.get(i - 1); |
||||||
|
WorkContext context = new WorkContext(); |
||||||
|
BeanUtils.copyProperties(worker, context); |
||||||
|
try { |
||||||
|
works.put(context); |
||||||
|
} catch (InterruptedException e) { |
||||||
|
context.setStatus(2); |
||||||
|
context.setResult(3); |
||||||
|
workService.update(context); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void addTask(WorkContext context) throws InterruptedException { |
||||||
|
works.put(context); |
||||||
|
} |
||||||
|
|
||||||
|
@Scheduled(cron = "${bmap.download.work.cron}") |
||||||
|
public void createWorker() throws InterruptedException { |
||||||
|
if (context == null) { |
||||||
|
if (!works.isEmpty()) { |
||||||
|
context = works.take(); |
||||||
|
; |
||||||
|
} else { |
||||||
|
return; |
||||||
|
} |
||||||
|
} else if (context.isDone()) { |
||||||
|
context.setEndTime(DateUtil.format(new Date(), DateUtil.FORMAT19_LINE_YYYYMMDDHHMMSS)); |
||||||
|
context.setStatus(2); |
||||||
|
context.setResult(1); |
||||||
|
workService.update(context); |
||||||
|
if (!works.isEmpty()) { |
||||||
|
context = works.take(); |
||||||
|
; |
||||||
|
} else { |
||||||
|
context = null; |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
addCaller(); |
||||||
|
addWorker(size - context.getSize()); |
||||||
|
log.debug(context.status()); |
||||||
|
} |
||||||
|
|
||||||
|
private void addCaller() { |
||||||
|
if (context.started()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
Future<?> submit = executor.submit(() -> { |
||||||
|
context.setStartTime(DateUtil.format(new Date(), DateUtil.FORMAT19_LINE_YYYYMMDDHHMMSS)); |
||||||
|
context.setStart(System.currentTimeMillis()); |
||||||
|
context.setStatus(1); |
||||||
|
workService.update(context); |
||||||
|
log.info(context.getCityName() + "-submit线程开始"); |
||||||
|
Point leftBottom = context.getLeftBottom(); |
||||||
|
Point rightTop = context.getRightTop(); |
||||||
|
long start = System.currentTimeMillis(); |
||||||
|
for (int z = context.getMinZom(); z <= context.getMaxZom(); z++) { |
||||||
|
leftBottom.setZ(z); |
||||||
|
rightTop.setZ(z); |
||||||
|
BMapTool.callXY(leftBottom); |
||||||
|
BMapTool.callXY(rightTop); |
||||||
|
log.debug(MessageFormat.format("Z:{0},X:{1}-{2},Y:{3}-{4}", z, leftBottom.getX(), rightTop.getX(), |
||||||
|
leftBottom.getY(), rightTop.getY())); |
||||||
|
for (int x = leftBottom.getX(); x <= rightTop.getX(); x++) { |
||||||
|
for (int y = leftBottom.getY(); y <= rightTop.getY(); y++) { |
||||||
|
Point p = new Point(x, y, z); |
||||||
|
try { |
||||||
|
queue.put(p); |
||||||
|
} catch (InterruptedException e) { |
||||||
|
fail(p); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
long time = (System.currentTimeMillis() - start) / 1000; |
||||||
|
log.info(context.getCityName() + "-submit线程结束,耗时" + time + "秒,速度约" |
||||||
|
+ (context.getTotal() - context.getExist() - 1000) / time + "个/秒"); |
||||||
|
}); |
||||||
|
context.setSubmit(submit); |
||||||
|
} |
||||||
|
|
||||||
|
private void addWorker(int size) { |
||||||
|
for (int i = 0; i < size; i++) { |
||||||
|
Future<?> future = executor.submit(() -> { |
||||||
|
while (!queue.isEmpty()) { |
||||||
|
try { |
||||||
|
Point point = queue.take(); |
||||||
|
if (!downLoad(point)) { |
||||||
|
fail(point); |
||||||
|
} |
||||||
|
} catch (InterruptedException e) { |
||||||
|
log.error("download failed", e); |
||||||
|
} |
||||||
|
} |
||||||
|
System.out.println(Thread.currentThread().getName() + "下载线程结束"); |
||||||
|
}); |
||||||
|
context.addFuture(future); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private boolean downLoad(Point point) { |
||||||
|
int z = point.getZ(); |
||||||
|
int x = point.getX(); |
||||||
|
int y = point.getY(); |
||||||
|
File file = new File(path + "/" + z + "/" + x + "/" + y + ".png"); |
||||||
|
|
||||||
|
if (file.exists()) { |
||||||
|
exist(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
new File(file.getParent()).mkdirs(); |
||||||
|
int idx = Math.abs(x + y) % MAP_HOSTS.length; |
||||||
|
String urlStr = MessageFormat.format(urlFromat, MAP_HOSTS[idx], x + "", y + "", z); |
||||||
|
URL url; |
||||||
|
try { |
||||||
|
url = new URL(urlStr); |
||||||
|
} catch (MalformedURLException e) { |
||||||
|
log.error("download failed:" + e.getMessage()); |
||||||
|
return false; |
||||||
|
} |
||||||
|
try (InputStream is = url.openConnection().getInputStream(); |
||||||
|
FileOutputStream os = new FileOutputStream(file);) { |
||||||
|
byte[] buf = new byte[1024 * 20]; |
||||||
|
int bytesRead; |
||||||
|
while ((bytesRead = is.read(buf)) > 0) { |
||||||
|
os.write(buf, 0, bytesRead); |
||||||
|
} |
||||||
|
os.flush(); |
||||||
|
success(); |
||||||
|
return true; |
||||||
|
} catch (ConnectException | FileNotFoundException e) { |
||||||
|
log.error(e.getMessage()); |
||||||
|
file.delete(); |
||||||
|
return false; |
||||||
|
} catch (Exception e) { |
||||||
|
log.error("download failed", e); |
||||||
|
file.delete(); |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void success() { |
||||||
|
lockS.lock(); |
||||||
|
context.success(); |
||||||
|
lockS.unlock(); |
||||||
|
} |
||||||
|
|
||||||
|
private void fail(Point p) { |
||||||
|
lockF.lock(); |
||||||
|
context.fail(); |
||||||
|
lockF.unlock(); |
||||||
|
} |
||||||
|
|
||||||
|
private void exist() { |
||||||
|
lockE.lock(); |
||||||
|
context.exist(); |
||||||
|
lockE.unlock(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
package vip.xumy.admin.sys.conf; |
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan; |
||||||
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||||
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
||||||
|
import org.springframework.context.annotation.ComponentScan; |
||||||
|
|
||||||
|
@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class) |
||||||
|
@ComponentScan(value = "vip.xumy.admin.sys,vip.xumy.core", useDefaultFilters = true) |
||||||
|
@MapperScan("vip.xumy.admin.sys.mapper") |
||||||
|
public class SysInitializer extends SpringBootServletInitializer { |
||||||
|
|
||||||
|
@Override |
||||||
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { |
||||||
|
return builder.sources(SysInitializer.class); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,49 @@ |
|||||||
|
package vip.xumy.admin.sys.controller; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||||
|
import org.springframework.web.bind.annotation.PutMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
import com.github.pagehelper.Page; |
||||||
|
import com.github.pagehelper.PageHelper; |
||||||
|
|
||||||
|
import vip.xumy.admin.sys.pojo.SysConfig; |
||||||
|
import vip.xumy.admin.sys.service.ConfigService; |
||||||
|
import vip.xumy.core.pojo.com.AjaxResponse; |
||||||
|
import vip.xumy.core.pojo.com.PageResponse; |
||||||
|
|
||||||
|
/** |
||||||
|
* Do not use for any commercial purposes without permission |
||||||
|
* |
||||||
|
* @author: mengyxu |
||||||
|
* @date: 2022年1月4日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@RestController |
||||||
|
@RequestMapping("sys/config") |
||||||
|
public class ConfigController { |
||||||
|
@Autowired |
||||||
|
private ConfigService configService; |
||||||
|
|
||||||
|
@GetMapping |
||||||
|
public PageResponse<SysConfig> list(SysConfig example) { |
||||||
|
Page<SysConfig> pages = PageHelper.startPage(example.getPage(), example.getSize()); |
||||||
|
List<SysConfig> list = configService.queryByExample(example); |
||||||
|
PageResponse<SysConfig> rsp = new PageResponse<>(); |
||||||
|
rsp.setRows(list); |
||||||
|
rsp.setTotal(pages.getTotal()); |
||||||
|
return rsp; |
||||||
|
} |
||||||
|
|
||||||
|
@PutMapping |
||||||
|
public AjaxResponse update(@RequestBody SysConfig sysConfig) { |
||||||
|
configService.update(sysConfig); |
||||||
|
return new AjaxResponse(true, "修改成功"); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
package vip.xumy.admin.sys.controller; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.beans.factory.annotation.Value; |
||||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
import vip.xumy.admin.sys.pojo.Dictionary; |
||||||
|
import vip.xumy.admin.sys.service.DictionaryService; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2019年10月21日 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@RequestMapping("public") |
||||||
|
public class SysPublicContoller { |
||||||
|
@Value("${version.num:3.0.0}") |
||||||
|
private String versionNum; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private DictionaryService dictService; |
||||||
|
|
||||||
|
@RequestMapping(value = "get/dict", method = RequestMethod.POST) |
||||||
|
public Map<String, List<Dictionary>> getDictionarys(@RequestBody String[] codes) { |
||||||
|
return dictService.getDicts(codes); |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value = "version") |
||||||
|
public String getVersionNum() { |
||||||
|
return versionNum; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
package vip.xumy.admin.sys.mapper; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Delete; |
||||||
|
import org.apache.ibatis.annotations.Insert; |
||||||
|
import org.apache.ibatis.annotations.Many; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Result; |
||||||
|
import org.apache.ibatis.annotations.Results; |
||||||
|
import org.apache.ibatis.annotations.Select; |
||||||
|
import org.apache.ibatis.annotations.Update; |
||||||
|
|
||||||
|
import vip.xumy.admin.sys.pojo.Dictionary; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2019年12月6日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Mapper |
||||||
|
public interface IDictTypeMapper { |
||||||
|
|
||||||
|
@Results(id = "typeRM", value = { @Result(property = "code", column = "type_code"), |
||||||
|
@Result(property = "name", column = "type_name"), @Result(property = "desc", column = "type_desc"), |
||||||
|
@Result(property = "status", column = "type_status"), |
||||||
|
@Result(property = "children", column = "{parent=type_code}", javaType = List.class, many = @Many(select = "com.sprt.admin.sys.mapper.IDictionaryMapper.queryDict")) }) |
||||||
|
@Select({ "<script>", "SELECT * FROM dict_type ", "<where>", |
||||||
|
"<if test='code != null'> AND type_code = #{code} </if>", |
||||||
|
"<if test='name != null'> AND type_name like CONCAT('%',#{name},'%') </if>", |
||||||
|
"<if test='status != null'> AND type_status = #{status} </if>", "</where>", "ORDER BY type_name ASC", |
||||||
|
"</script>" }) |
||||||
|
List<Dictionary> queryType(Dictionary example); |
||||||
|
|
||||||
|
@Insert({ |
||||||
|
"INSERT INTO dict_type (type_code, type_name, type_desc, type_status) VALUES (#{code}, #{name}, #{desc}, #{status})" }) |
||||||
|
void insertType(Dictionary type); |
||||||
|
|
||||||
|
@Update({ |
||||||
|
"UPDATE dict_type SET type_name = #{name}, type_desc = #{desc}, type_status = #{status} WHERE type_code = #{code}" }) |
||||||
|
void updateType(Dictionary type); |
||||||
|
|
||||||
|
@Delete({ "DELETE FROM dict_type WHERE type_code = #{code}" }) |
||||||
|
void deleteType(String code); |
||||||
|
|
||||||
|
} |
@ -1,31 +0,0 @@ |
|||||||
package vip.xumy.admin.sys.service; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
import vip.xumy.admin.sys.pojo.SysConfig; |
|
||||||
|
|
||||||
public interface IConfigService { |
|
||||||
|
|
||||||
public String queryValueByKey(String cfgKey); |
|
||||||
|
|
||||||
/** |
|
||||||
* Query the configuration by the key. |
|
||||||
* Return the default value as provided if no item found. |
|
||||||
* @param cfgKey |
|
||||||
* @param defaultVal |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
String getStringConfig(String cfgKey, String defaultVal); |
|
||||||
|
|
||||||
long getLongConfig(String key, long defValue); |
|
||||||
|
|
||||||
Integer getIntConfig(String key, Integer defValue); |
|
||||||
|
|
||||||
public List<SysConfig> queryPageByExample(SysConfig example); |
|
||||||
|
|
||||||
public void update(SysConfig sysConfig); |
|
||||||
|
|
||||||
public void updateCfg(String key, String value, String userId); |
|
||||||
|
|
||||||
|
|
||||||
} |
|
@ -1,35 +0,0 @@ |
|||||||
package vip.xumy.admin.sys.service; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
import java.util.Map; |
|
||||||
|
|
||||||
import vip.xumy.admin.sys.pojo.Dictionary; |
|
||||||
import vip.xumy.core.exception.CoreException; |
|
||||||
import vip.xumy.core.pojo.com.Entry; |
|
||||||
|
|
||||||
/** Ownership belongs to the company |
|
||||||
* author:mengyxu |
|
||||||
* date:2019年12月6日 |
|
||||||
*/ |
|
||||||
|
|
||||||
public interface IDictionaryService { |
|
||||||
|
|
||||||
List<Dictionary> queryType(Dictionary example); |
|
||||||
|
|
||||||
void save(Dictionary dist); |
|
||||||
|
|
||||||
void update(Dictionary dist); |
|
||||||
|
|
||||||
void delete(Dictionary dict) throws CoreException; |
|
||||||
|
|
||||||
Map<String, List<Dictionary>> getDicts(String[] codes); |
|
||||||
|
|
||||||
List<Dictionary> getDict(String code); |
|
||||||
|
|
||||||
List<Entry<String, String>> queryProvince(); |
|
||||||
|
|
||||||
List<Entry<String, String>> queryCity(String parent); |
|
||||||
|
|
||||||
List<Entry<String, String>> queryCounty(String parent); |
|
||||||
|
|
||||||
} |
|
@ -1,23 +0,0 @@ |
|||||||
package vip.xumy.admin.sys.service; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
import java.util.Map; |
|
||||||
|
|
||||||
import vip.xumy.admin.sys.pojo.ActionLog; |
|
||||||
|
|
||||||
/** Ownership belongs to the company |
|
||||||
* author:mengyxu |
|
||||||
* date:2019年12月5日 |
|
||||||
*/ |
|
||||||
|
|
||||||
public interface ILogService { |
|
||||||
|
|
||||||
List<ActionLog> queryActionLog(ActionLog example); |
|
||||||
|
|
||||||
void insertActionLog(ActionLog log); |
|
||||||
|
|
||||||
void insertActionLogs(List<ActionLog> logs); |
|
||||||
|
|
||||||
Map<String, String> getTypeMap(); |
|
||||||
|
|
||||||
} |
|
@ -1,24 +0,0 @@ |
|||||||
package vip.xumy.admin.sys.service; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
import vip.xumy.admin.sys.pojo.UserItem; |
|
||||||
|
|
||||||
/** Ownership belongs to the company |
|
||||||
* author:mengyxu |
|
||||||
* date:2020年3月17日 |
|
||||||
*/ |
|
||||||
|
|
||||||
public interface IUserItemService { |
|
||||||
|
|
||||||
List<UserItem> queryByExample(UserItem example); |
|
||||||
|
|
||||||
void save(UserItem item); |
|
||||||
|
|
||||||
void save(List<UserItem> items); |
|
||||||
|
|
||||||
void read(Integer id); |
|
||||||
|
|
||||||
void dealWith(Integer id); |
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,25 @@ |
|||||||
|
package vip.xumy.admin.um.conf; |
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan; |
||||||
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||||
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
||||||
|
import org.springframework.context.annotation.ComponentScan; |
||||||
|
|
||||||
|
|
||||||
|
@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class) |
||||||
|
@ComponentScan(value = "com.sprt.admin.um", useDefaultFilters = true) |
||||||
|
@MapperScan("com.sprt.admin.um.mapper") |
||||||
|
public class UMInitializer extends SpringBootServletInitializer { |
||||||
|
|
||||||
|
@Override |
||||||
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { |
||||||
|
return builder.sources(UMInitializer.class); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
package vip.xumy.admin; |
package vip.xumy.admin.um.controller; |
||||||
|
|
||||||
import org.springframework.stereotype.Controller; |
import org.springframework.stereotype.Controller; |
||||||
import org.springframework.web.bind.annotation.PathVariable; |
import org.springframework.web.bind.annotation.PathVariable; |
@ -0,0 +1,104 @@ |
|||||||
|
package vip.xumy.admin.verify.conf; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Iterator; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.http.MediaType; |
||||||
|
import org.springframework.http.converter.HttpMessageConverter; |
||||||
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry; |
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.serializer.SerializerFeature; |
||||||
|
import com.alibaba.fastjson.support.config.FastJsonConfig; |
||||||
|
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; |
||||||
|
|
||||||
|
@Configuration |
||||||
|
public class BaseConfigurer implements WebMvcConfigurer { |
||||||
|
@Autowired |
||||||
|
private LoginInteceptor loginInteceptor; |
||||||
|
|
||||||
|
/** |
||||||
|
* 跨域支持 |
||||||
|
* |
||||||
|
* @param registry |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void addCorsMappings(CorsRegistry registry) { |
||||||
|
registry.addMapping("/**").allowedOrigins("*").allowedHeaders("*").allowCredentials(true).allowedMethods("*") |
||||||
|
.maxAge(3600 * 24); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 登录拦截器 |
||||||
|
* |
||||||
|
* @param registry |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void addInterceptors(InterceptorRegistry registry) { |
||||||
|
List<String> patterns = new ArrayList<>(); |
||||||
|
patterns.add("/"); |
||||||
|
patterns.add("/um/**"); |
||||||
|
patterns.add("/public/**"); |
||||||
|
patterns.add("/css/**"); |
||||||
|
patterns.add("/fonts/**"); |
||||||
|
patterns.add("/js/**"); |
||||||
|
patterns.add("/image/**"); |
||||||
|
patterns.add("/*.html"); |
||||||
|
patterns.add("/*.ico"); |
||||||
|
registry.addInterceptor(loginInteceptor).addPathPatterns("/**").excludePathPatterns(patterns); |
||||||
|
WebMvcConfigurer.super.addInterceptors(registry); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 默认JSON解析器从Jackson改为FastJson |
||||||
|
* |
||||||
|
* @param registry |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { |
||||||
|
Iterator<HttpMessageConverter<?>> iterator = converters.iterator(); |
||||||
|
while (iterator.hasNext()) { |
||||||
|
HttpMessageConverter<?> converter = iterator.next(); |
||||||
|
if (converter instanceof MappingJackson2HttpMessageConverter) { |
||||||
|
iterator.remove(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 升级最新版本需加======解决报错:Content-Type' cannot contain wildcard type '*
|
||||||
|
|
||||||
|
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); |
||||||
|
List<MediaType> supportedMediaTypes = new ArrayList<>(); |
||||||
|
supportedMediaTypes.add(MediaType.APPLICATION_JSON); |
||||||
|
supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8); |
||||||
|
supportedMediaTypes.add(MediaType.APPLICATION_ATOM_XML); |
||||||
|
supportedMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED); |
||||||
|
supportedMediaTypes.add(MediaType.APPLICATION_OCTET_STREAM); |
||||||
|
supportedMediaTypes.add(MediaType.APPLICATION_PDF); |
||||||
|
supportedMediaTypes.add(MediaType.APPLICATION_RSS_XML); |
||||||
|
supportedMediaTypes.add(MediaType.APPLICATION_XHTML_XML); |
||||||
|
supportedMediaTypes.add(MediaType.APPLICATION_XML); |
||||||
|
supportedMediaTypes.add(MediaType.IMAGE_GIF); |
||||||
|
supportedMediaTypes.add(MediaType.IMAGE_JPEG); |
||||||
|
supportedMediaTypes.add(MediaType.IMAGE_PNG); |
||||||
|
supportedMediaTypes.add(MediaType.TEXT_EVENT_STREAM); |
||||||
|
supportedMediaTypes.add(MediaType.TEXT_HTML); |
||||||
|
supportedMediaTypes.add(MediaType.TEXT_MARKDOWN); |
||||||
|
supportedMediaTypes.add(MediaType.TEXT_PLAIN); |
||||||
|
supportedMediaTypes.add(MediaType.TEXT_XML); |
||||||
|
fastConverter.setSupportedMediaTypes(supportedMediaTypes); |
||||||
|
|
||||||
|
// 2、添加fastjson的配置信息,比如 是否要格式化返回json数据
|
||||||
|
FastJsonConfig fastJsonConfig = new FastJsonConfig(); |
||||||
|
fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat); |
||||||
|
// 3、在convert中添加配置信息.
|
||||||
|
fastConverter.setFastJsonConfig(fastJsonConfig); |
||||||
|
// 4、将convert添加到converters当中.
|
||||||
|
converters.add(fastConverter); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
package vip.xumy.admin.verify.conf; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
|
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
import org.springframework.web.servlet.HandlerInterceptor; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
|
||||||
|
import lombok.extern.log4j.Log4j2; |
||||||
|
import vip.xumy.admin.verify.controller.PublicController; |
||||||
|
import vip.xumy.core.pojo.com.AjaxResponse; |
||||||
|
|
||||||
|
/** |
||||||
|
* 权限验证拦截器 |
||||||
|
* @author v_mengyxu |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Log4j2 |
||||||
|
@Component |
||||||
|
public class LoginInteceptor implements HandlerInterceptor { |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) throws Exception { |
||||||
|
//判断是否登录
|
||||||
|
Object user = request.getSession().getAttribute(PublicController.KEY); |
||||||
|
if(user == null) { |
||||||
|
log.debug("Login interceptor : preHandle ..."); |
||||||
|
response.setContentType("application/json;charset:UTF-8"); |
||||||
|
response.getWriter().write(JSON.toJSONString(new AjaxResponse(false, "session timeout"))); |
||||||
|
return false; |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
package vip.xumy.admin.verify.conf; |
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan; |
||||||
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||||
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
||||||
|
import org.springframework.context.annotation.ComponentScan; |
||||||
|
|
||||||
|
|
||||||
|
@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class) |
||||||
|
@ComponentScan(value = "vip.xumy.admin.verify", useDefaultFilters = true) |
||||||
|
@MapperScan("vip.xumy.admin.verify.mapper") |
||||||
|
public class VerifyInitializer extends SpringBootServletInitializer { |
||||||
|
|
||||||
|
@Override |
||||||
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { |
||||||
|
return builder.sources(VerifyInitializer.class); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,52 @@ |
|||||||
|
package vip.xumy.admin.verify.controller; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
import vip.xumy.admin.verify.pojo.User; |
||||||
|
import vip.xumy.admin.verify.service.UserService; |
||||||
|
import vip.xumy.core.pojo.com.AjaxResponse; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2020年10月28日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@RestController |
||||||
|
@RequestMapping("public") |
||||||
|
public class PublicController { |
||||||
|
public final static String KEY = "user"; |
||||||
|
@Autowired |
||||||
|
private UserService userService; |
||||||
|
|
||||||
|
@RequestMapping(value = "login", method = RequestMethod.POST) |
||||||
|
public AjaxResponse login(@RequestBody User param, HttpServletRequest request) { |
||||||
|
User user = userService.login(param); |
||||||
|
if (user == null) { |
||||||
|
return new AjaxResponse(false, "登录失败,用户名或密码错误"); |
||||||
|
} |
||||||
|
request.getSession().setAttribute(KEY, user); |
||||||
|
return new AjaxResponse(true, "登录成功"); |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value = "logout", method = RequestMethod.GET) |
||||||
|
public AjaxResponse logout(HttpServletRequest request) { |
||||||
|
request.getSession().removeAttribute(KEY); |
||||||
|
return new AjaxResponse(true, "登出成功"); |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value = "info", method = RequestMethod.GET) |
||||||
|
public User login(HttpServletRequest request) { |
||||||
|
Object user = request.getSession().getAttribute(KEY); |
||||||
|
if (user == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return (User) user; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package vip.xumy.admin.verify.mapper; |
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Result; |
||||||
|
import org.apache.ibatis.annotations.Results; |
||||||
|
import org.apache.ibatis.annotations.Select; |
||||||
|
import org.apache.ibatis.annotations.Update; |
||||||
|
|
||||||
|
import vip.xumy.admin.verify.pojo.User; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2020年10月28日 |
||||||
|
*/ |
||||||
|
|
||||||
|
public interface IUserMapper { |
||||||
|
|
||||||
|
@Select({ "SELECT * FROM user WHERE user_id = #{userId} AND password = #{password}" }) |
||||||
|
@Results({ @Result(property = "userId", column = "user_id") }) |
||||||
|
User login(User param); |
||||||
|
|
||||||
|
@Update({ "UPDATE user SET password = #{newPwd} WHERE user_id = #{userId} AND password = #{password}" }) |
||||||
|
int updatePassword(User param); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package vip.xumy.admin.verify.pojo; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2020年10月28日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public class User { |
||||||
|
|
||||||
|
private String userId; |
||||||
|
private String name; |
||||||
|
@JSONField(serialize = false) |
||||||
|
private String password; |
||||||
|
private String desc; |
||||||
|
private String permission; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
package vip.xumy.admin.verify.service; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import vip.xumy.admin.verify.mapper.IUserMapper; |
||||||
|
import vip.xumy.admin.verify.pojo.User; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author:mengyxu |
||||||
|
* @date:2020年10月31日 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Service |
||||||
|
public class UserService { |
||||||
|
@Autowired |
||||||
|
private IUserMapper userMapper; |
||||||
|
|
||||||
|
public User login(User param) { |
||||||
|
return userMapper.login(param); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,77 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
|
||||||
<mapper namespace="vip.xumy.admin.sys.mapper.IActionLogMapper"> |
|
||||||
|
|
||||||
<sql id="base_column"> |
|
||||||
id,type,module,user_id,login_ip,time,context |
|
||||||
</sql> |
|
||||||
|
|
||||||
<resultMap type="vip.xumy.admin.sys.pojo.ActionLog" id="logRM"> |
|
||||||
<id column="id" property="id"/> |
|
||||||
<result column="type" property="type"/> |
|
||||||
<result column="module" property="module"/> |
|
||||||
<result column="user_id" property="userId"/> |
|
||||||
<result column="login_ip" property="loginIp"/> |
|
||||||
<result column="time" property="time"/> |
|
||||||
<result column="context" property="context"/> |
|
||||||
</resultMap> |
|
||||||
|
|
||||||
<select id="queryByExample" parameterType="vip.xumy.admin.sys.pojo.ActionLog" resultMap="logRM"> |
|
||||||
SELECT |
|
||||||
<include refid="base_column"/> |
|
||||||
FROM |
|
||||||
sys_action_log |
|
||||||
<where> |
|
||||||
<if test="type != null and type != ''"> |
|
||||||
AND type = #{type} |
|
||||||
</if> |
|
||||||
<if test="module != null and module != ''"> |
|
||||||
AND module = #{module} |
|
||||||
</if> |
|
||||||
<if test="userId != null and userId != ''"> |
|
||||||
AND user_id like CONCAT('%',#{userId},'%') |
|
||||||
</if> |
|
||||||
<if test="context != null and context != ''"> |
|
||||||
AND context like CONCAT('%',#{context},'%') |
|
||||||
</if> |
|
||||||
<if test="startTime != null and startTime != ''"> |
|
||||||
AND time >= #{startTime} |
|
||||||
</if> |
|
||||||
<if test="endTime != null and endTime != ''"> |
|
||||||
AND #{endTime} > time |
|
||||||
</if> |
|
||||||
</where> |
|
||||||
ORDER BY time DESC |
|
||||||
</select> |
|
||||||
|
|
||||||
<insert id="insert" parameterType="vip.xumy.admin.sys.pojo.ActionLog"> |
|
||||||
INSERT INTO sys_action_log |
|
||||||
(<include refid="base_column"/>) |
|
||||||
VALUES ( |
|
||||||
#{id}, |
|
||||||
#{type}, |
|
||||||
#{module}, |
|
||||||
#{userId}, |
|
||||||
#{loginIp}, |
|
||||||
#{time}, |
|
||||||
#{context} |
|
||||||
) |
|
||||||
</insert> |
|
||||||
<insert id="insertBatch" parameterType="java.util.List"> |
|
||||||
INSERT INTO BusinessLog |
|
||||||
(<include refid="base_column"/>) |
|
||||||
VALUES |
|
||||||
<foreach collection="list" item="log" separator=","> |
|
||||||
( |
|
||||||
#{log.id}, |
|
||||||
#{log.type}, |
|
||||||
#{log.module}, |
|
||||||
#{log.userId}, |
|
||||||
#{log.loginIp}, |
|
||||||
#{log.time}, |
|
||||||
#{log.context} |
|
||||||
) |
|
||||||
</foreach> |
|
||||||
</insert> |
|
||||||
|
|
||||||
</mapper> |
|
@ -1,66 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||||
<!DOCTYPE mapper |
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|
||||||
<mapper namespace="vip.xumy.admin.sys.mapper.IConfigMapper"> |
|
||||||
|
|
||||||
<sql id="baseColumn"> |
|
||||||
cfg_key, |
|
||||||
cfg_name, |
|
||||||
cfg_value, |
|
||||||
cfg_type, |
|
||||||
cfg_desc, |
|
||||||
cfg_status, |
|
||||||
update_time, |
|
||||||
update_user |
|
||||||
</sql> |
|
||||||
|
|
||||||
<resultMap type="vip.xumy.admin.sys.pojo.SysConfig" id="cfgResultMap"> |
|
||||||
<result column="cfg_key" property="cfgKey"/> |
|
||||||
<result column="cfg_name" property="cfgName"/> |
|
||||||
<result column="cfg_value" property="cfgValue"/> |
|
||||||
<result column="cfg_type" property="cfgType"/> |
|
||||||
<result column="cfg_desc" property="cfgDesc"/> |
|
||||||
<result column="cfg_status" property="cfgStatus"/> |
|
||||||
<result column="update_time" property="updateTime"/> |
|
||||||
<result column="update_user" property="updateUser"/> |
|
||||||
</resultMap> |
|
||||||
|
|
||||||
|
|
||||||
<select id="queryValueByKey" parameterType="java.lang.String" resultType="java.lang.String"> |
|
||||||
SELECT cfg_value FROM sys_config WHERE cfg_key = #{cfgKey} AND cfg_status != 'I' |
|
||||||
</select> |
|
||||||
|
|
||||||
<select id="queryByExample" parameterType="vip.xumy.admin.sys.pojo.SysConfig" resultMap="cfgResultMap"> |
|
||||||
SELECT |
|
||||||
<include refid="baseColumn"/> |
|
||||||
FROM |
|
||||||
sys_config |
|
||||||
<where> |
|
||||||
<if test="cfgKey != null and cfgKey !=''"> |
|
||||||
AND cfg_key = #{cfgKey} |
|
||||||
</if> |
|
||||||
<if test="cfgStatus != null and cfgStatus !=''"> |
|
||||||
AND cfg_status = #{cfgStatus} |
|
||||||
</if> |
|
||||||
<if test="cfgName != null and cfgName !=''"> |
|
||||||
AND cfg_name like CONCAT('%',#{cfgName},'%') |
|
||||||
</if> |
|
||||||
</where> |
|
||||||
</select> |
|
||||||
|
|
||||||
<update id="update" parameterType="vip.xumy.admin.sys.pojo.SysConfig"> |
|
||||||
UPDATE |
|
||||||
sys_config |
|
||||||
SET |
|
||||||
cfg_name = #{cfgName}, |
|
||||||
cfg_value = #{cfgValue}, |
|
||||||
cfg_desc = #{cfgDesc}, |
|
||||||
cfg_status = #{cfgStatus}, |
|
||||||
update_time = NOW(), |
|
||||||
update_user = #{updateUser} |
|
||||||
WHERE |
|
||||||
cfg_key = #{cfgKey} |
|
||||||
</update> |
|
||||||
|
|
||||||
</mapper> |
|
@ -1,153 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||||
<!DOCTYPE mapper |
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|
||||||
<mapper namespace="vip.xumy.admin.sys.mapper.IDictionaryMapper"> |
|
||||||
|
|
||||||
<sql id="typeColumn"> |
|
||||||
type_code, |
|
||||||
type_name, |
|
||||||
type_desc, |
|
||||||
type_status |
|
||||||
</sql> |
|
||||||
|
|
||||||
<sql id="dictColumn"> |
|
||||||
dict_id, |
|
||||||
dict_code, |
|
||||||
dict_name, |
|
||||||
dict_desc, |
|
||||||
dict_parent, |
|
||||||
dict_status |
|
||||||
</sql> |
|
||||||
|
|
||||||
<resultMap type="vip.xumy.admin.sys.pojo.Dictionary" id="typeRM"> |
|
||||||
<result column="type_code" property="key"/> |
|
||||||
<result column="type_code" property="code"/> |
|
||||||
<result column="type_name" property="name"/> |
|
||||||
<result column="type_desc" property="desc"/> |
|
||||||
<result column="type_status" property="status"/> |
|
||||||
|
|
||||||
<collection property="children" column="{parent=type_code}" select="queryDict"/> |
|
||||||
</resultMap> |
|
||||||
|
|
||||||
<resultMap type="vip.xumy.admin.sys.pojo.Dictionary" id="dictRM"> |
|
||||||
<id column="dict_id" property="id"/> |
|
||||||
<result column="dict_id" property="key"/> |
|
||||||
<result column="dict_code" property="code"/> |
|
||||||
<result column="dict_name" property="name"/> |
|
||||||
<result column="dict_desc" property="desc"/> |
|
||||||
<result column="dict_parent" property="parent"/> |
|
||||||
<result column="dict_status" property="status"/> |
|
||||||
</resultMap> |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<select id="queryType" resultMap="typeRM" parameterType="vip.xumy.admin.sys.pojo.Dictionary"> |
|
||||||
SELECT |
|
||||||
<include refid="typeColumn"/> |
|
||||||
FROM |
|
||||||
sys_dict_type |
|
||||||
<where> |
|
||||||
<if test="code != null and code != ''"> |
|
||||||
AND type_code = #{code} |
|
||||||
</if> |
|
||||||
<if test="name != null and name != ''"> |
|
||||||
AND type_name like CONCAT('%',#{name},'%') |
|
||||||
</if> |
|
||||||
<if test="status != null and status != ''"> |
|
||||||
AND type_status = #{status} |
|
||||||
</if> |
|
||||||
</where> |
|
||||||
ORDER BY type_name ASC |
|
||||||
</select> |
|
||||||
|
|
||||||
<select id="queryDict" resultMap="dictRM" parameterType="vip.xumy.admin.sys.pojo.Dictionary"> |
|
||||||
SELECT |
|
||||||
<include refid="dictColumn"/> |
|
||||||
FROM |
|
||||||
sys_dictionary |
|
||||||
<where> |
|
||||||
<if test="id != null"> |
|
||||||
AND dict_id = #{id} |
|
||||||
</if> |
|
||||||
<if test="parent != null and parent != ''"> |
|
||||||
AND dict_parent = #{parent} |
|
||||||
</if> |
|
||||||
<if test="status != null and status != ''"> |
|
||||||
AND dict_status = #{status} |
|
||||||
</if> |
|
||||||
</where> |
|
||||||
ORDER BY dict_id ASC |
|
||||||
</select> |
|
||||||
|
|
||||||
<insert id="insertDict" parameterType="vip.xumy.admin.sys.pojo.Dictionary" > |
|
||||||
INSERT INTO sys_dictionary |
|
||||||
(<include refid="dictColumn"></include>) |
|
||||||
VALUES |
|
||||||
( |
|
||||||
#{id}, |
|
||||||
#{code}, |
|
||||||
#{name}, |
|
||||||
#{desc}, |
|
||||||
#{parent}, |
|
||||||
#{status} |
|
||||||
) |
|
||||||
</insert> |
|
||||||
|
|
||||||
<insert id="insertType" parameterType="vip.xumy.admin.sys.pojo.Dictionary"> |
|
||||||
INSERT INTO sys_dict_type |
|
||||||
(<include refid="typeColumn"></include>) |
|
||||||
VALUES |
|
||||||
( |
|
||||||
#{code}, |
|
||||||
#{name}, |
|
||||||
#{desc}, |
|
||||||
#{status} |
|
||||||
) |
|
||||||
</insert> |
|
||||||
|
|
||||||
<update id="updateDict" parameterType="vip.xumy.admin.sys.pojo.Dictionary"> |
|
||||||
UPDATE sys_dictionary SET |
|
||||||
dict_code = #{code}, |
|
||||||
dict_name = #{name}, |
|
||||||
dict_desc = #{desc}, |
|
||||||
dict_parent = #{parent}, |
|
||||||
dict_status = #{status} |
|
||||||
WHERE |
|
||||||
dict_id = #{id} |
|
||||||
</update> |
|
||||||
|
|
||||||
<update id="updateType" parameterType="vip.xumy.admin.sys.pojo.Dictionary"> |
|
||||||
UPDATE sys_dict_type SET |
|
||||||
type_name = #{name}, |
|
||||||
type_desc = #{desc}, |
|
||||||
type_status = #{status} |
|
||||||
WHERE |
|
||||||
type_code = #{code} |
|
||||||
</update> |
|
||||||
|
|
||||||
<delete id="deleteType" parameterType="java.lang.String"> |
|
||||||
DELETE FROM sys_dict_type WHERE type_code = #{code} |
|
||||||
</delete> |
|
||||||
|
|
||||||
<delete id="deleteDict" parameterType="java.lang.Integer"> |
|
||||||
DELETE FROM sys_dictionary WHERE dict_id = #{id} |
|
||||||
</delete> |
|
||||||
|
|
||||||
<delete id="deleteDicts" parameterType="java.lang.String"> |
|
||||||
DELETE FROM sys_dictionary WHERE dict_parent = #{parent} |
|
||||||
</delete> |
|
||||||
|
|
||||||
<select id="queryProvince" resultType="vip.xumy.core.pojo.com.Entry"> |
|
||||||
select code as 'key', name as 'value' from province |
|
||||||
</select> |
|
||||||
|
|
||||||
<select id="queryCity" resultType="vip.xumy.core.pojo.com.Entry" parameterType="java.lang.String"> |
|
||||||
select code as 'key', name as 'value' from city where provinceCode = #{parent} |
|
||||||
</select> |
|
||||||
|
|
||||||
<select id="queryCounty" resultType="vip.xumy.core.pojo.com.Entry" parameterType="java.lang.String"> |
|
||||||
select countycode as 'key', countyname as 'value' from county where cityCode = #{parent} |
|
||||||
</select> |
|
||||||
|
|
||||||
</mapper> |
|
@ -1,95 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
|
||||||
<mapper namespace="vip.xumy.admin.sys.mapper.IUserItemMapper"> |
|
||||||
|
|
||||||
<sql id="base_column"> |
|
||||||
id,user_id,item_name,item_desc,item_type,item_flag,add_user,add_time,status |
|
||||||
</sql> |
|
||||||
|
|
||||||
<resultMap type="vip.xumy.admin.sys.pojo.UserItem" id="itemRM"> |
|
||||||
<id column="id" property="id"/> |
|
||||||
<result column="user_id" property="userId"/> |
|
||||||
<result column="item_name" property="itemName"/> |
|
||||||
<result column="item_desc" property="itemDesc"/> |
|
||||||
<result column="item_type" property="itemType"/> |
|
||||||
<result column="item_flag" property="itemFlag"/> |
|
||||||
<result column="add_user" property="addUser"/> |
|
||||||
<result column="add_time" property="addTime"/> |
|
||||||
<result column="status" property="status"/> |
|
||||||
</resultMap> |
|
||||||
|
|
||||||
<select id="queryByExample" parameterType="vip.xumy.admin.sys.pojo.UserItem" resultMap="itemRM"> |
|
||||||
SELECT |
|
||||||
<include refid="base_column"/> |
|
||||||
FROM |
|
||||||
sys_user_item |
|
||||||
<where> |
|
||||||
<if test="id != null and id != ''"> |
|
||||||
AND id = #{id} |
|
||||||
</if> |
|
||||||
<if test="userId != null and userId != ''"> |
|
||||||
AND user_id = #{userId} |
|
||||||
</if> |
|
||||||
<if test="itemType != null and itemType != ''"> |
|
||||||
AND item_type = #{itemType} |
|
||||||
</if> |
|
||||||
<if test="itemFlag != null and itemFlag != ''"> |
|
||||||
AND item_flag = #{itemFlag} |
|
||||||
</if> |
|
||||||
<if test="addUser != null and addUser != ''"> |
|
||||||
AND add_user = #{addUser} |
|
||||||
</if> |
|
||||||
<if test="status != null"> |
|
||||||
AND status = #{status} |
|
||||||
</if> |
|
||||||
</where> |
|
||||||
ORDER BY status ASC, add_time DESC |
|
||||||
<if test="limitStart != null"> |
|
||||||
LIMIT #{limitStart},#{size} |
|
||||||
</if> |
|
||||||
</select> |
|
||||||
|
|
||||||
<insert id="insert" parameterType="vip.xumy.admin.sys.pojo.UserItem"> |
|
||||||
INSERT INTO sys_user_item |
|
||||||
(<include refid="base_column"/>) |
|
||||||
VALUES ( |
|
||||||
#{id}, |
|
||||||
#{userId}, |
|
||||||
#{itemName}, |
|
||||||
#{itemDesc}, |
|
||||||
#{itemType}, |
|
||||||
#{itemFlag}, |
|
||||||
#{addUser}, |
|
||||||
#{addTime}, |
|
||||||
'0' |
|
||||||
) |
|
||||||
</insert> |
|
||||||
|
|
||||||
<insert id="insertBatch" parameterType="java.util.List"> |
|
||||||
INSERT INTO sys_user_item |
|
||||||
(<include refid="base_column"/>) |
|
||||||
VALUES |
|
||||||
<foreach collection="list" item="item" separator=","> |
|
||||||
( |
|
||||||
#{item.id}, |
|
||||||
#{item.userId}, |
|
||||||
#{item.itemName}, |
|
||||||
#{item.itemDesc}, |
|
||||||
#{item.itemType}, |
|
||||||
#{item.itemFlag}, |
|
||||||
#{item.addUser}, |
|
||||||
#{item.addTime}, |
|
||||||
'0' |
|
||||||
) |
|
||||||
</foreach> |
|
||||||
</insert> |
|
||||||
|
|
||||||
<update id="update" parameterType="vip.xumy.admin.sys.pojo.UserItem"> |
|
||||||
UPDATE sys_user_item |
|
||||||
SET |
|
||||||
status = #{status} |
|
||||||
WHERE |
|
||||||
id = #{id} |
|
||||||
</update> |
|
||||||
|
|
||||||
</mapper> |
|
Loading…
Reference in new issue