Hbulid代码
按地区:
山西
三亚
内蒙古
西藏
陕西
全部
{{scenic.name}} {{scenic.level}}
{{scenic.tname}}
{{scenic.pname}}{{scenic.cname}}{{scenic.dname}}
门票:{{scenic.ticket}}元/人
详情
修改
删除
添加景点
批量删除
添加
重置
景区名称
{{detailScenicForm.name}}
景区等级
{{detailScenicForm.level}}
景区风格
{{detailScenicForm.tname}}
所属地区
{{detailScenicForm.pname}}{{detailScenicForm.cname}}{{detailScenicForm.dname}}
门票
{{detailScenicForm.ticket}}
景区图片
景区介绍
{{detailScenicForm.introduction}}
返回
更新
重置
idea代码
@RestController
@RequestMapping("/scenic")
public class ScenicController {
@Autowired
private IScenicService iScenicService;
@RequestMapping("/list")
public ResultApi list(Page page , ScenicVo vo){
return ResultApi.success(iScenicService.selectPageVo(page,vo));
}
@RequestMapping("/insert")
public ResultApi insert(@RequestBody Scenic scenic){
return ResultApi.success(iScenicService.save(scenic));
}
@RequestMapping("/update")
public ResultApi update(@RequestBody Scenic scenic){
return ResultApi.success(iScenicService.updateById(scenic));
}
@RequestMapping("/delete")
public ResultApi delete(Integer ids[]){
try {
System.out.println(ids+"*******");
iScenicService.removeByIds(Arrays.asList(ids));
System.out.println(ids);
return ResultApi.success(true);
}catch (Exception e){
e.printStackTrace();
}
return ResultApi.error(false);
}
}
图片上传controller
//返回的都是json类型 等效于@Controller @ResponseBody
@RestController
public class UploadController {
@RequestMapping("/upload")
private ResultApi upload(MultipartFile file){
if(!file.isEmpty()){
//原始文件名称
String originalFilename = file.getOriginalFilename();
//文件名的唯一性
String fileName = UUID.randomUUID()+"_"+originalFilename;
//设置上传的路劲
File destFile = new File("D:/pic/", fileName);
//判断目录是否存在
if(!destFile.getParentFile().exists()){
//则创建目录
destFile.getParentFile().mkdir();
}
//保存文件
try{
file.transferTo(destFile);
return ResultApi.success("http://localhost:91/img/"+fileName);
}catch (IOException e){
e.printStackTrace();
}
}
return ResultApi.error(null);
}
}
递归获取三级联动数据
@RestController
@RequestMapping("/district")
public class DistrictController {
@Autowired
private IDistrictService iDistrictService;
@RequestMapping("/findAll")
public List findAll(){
return iDistrictService.findAll();
}
}
三级联动需要的实体类
@Data
public class DistrictVo implements Serializable {
private static final long serialVersionUID=1L;
//记录省市县的id
private Integer id;
//映射省市县的名称
private String name;
private List list;
}
主表需要的实体类
@Data
public class ScenicVo extends Scenic {
private String pname;
private String cname;
private String dname;
private String tname;
private Integer sorted;
private Integer provinceId;
private String levelId;
private Integer typeId;
}
三级联动sql Mapper
主表sql Mapper