提交 0092aba7 作者: dingtalk_nnkplh

代码优化

上级 6b8fa8f1
......@@ -114,56 +114,42 @@ public class TbSchoolController extends BaseController
/**
* 新增保存学校信息
*/
// @RequiresPermissions("system:school:add")
// @Log(title = "学校信息", businessType = BusinessType.INSERT)
// @PostMapping("/add")
// @ResponseBody
// public AjaxResult addSave(@RequestParam(value="schoolLogo",required=false) MultipartFile file,@RequestParam(value="backgroundImage",required=false) MultipartFile file1)
// {
// TbSchool tbSchool =new TbSchool();
// try {
// if (file != null && file1 != null) {
// // 上传文件路径
// String filePath = RuoYiConfig.getUploadPath();
// // 上传并返回新文件名称
// String fileName = null;
// fileName = FileUploadUtils.upload(filePath, file);
// tbSchool.setSchoolLogo(fileName);
// fileName = FileUploadUtils.upload(filePath, file1);
// tbSchool.setBackgroundImage(fileName);
// tbSchool.setCreator(getUserId());
// tbSchool.setCheckStatus(1);
// setParameters(tbSchool,getRequest());
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
// return toAjax(tbSchoolService.insertTbSchool(tbSchool));
// }
@RequiresPermissions("system:school:add")
@Log(title = "学校信息", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@RequestParam(value="schoolLogo",required=false) MultipartFile file,@RequestParam(value="backgroundImage",required=false) MultipartFile file1)
public AjaxResult addSave(TbSchool tbSchool)
{
TbSchool tbSchool =new TbSchool();
try {
if (file != null && file1 != null) {
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = null;
fileName = FileUploadUtils.upload(filePath, file);
tbSchool.setSchoolLogo(fileName);
fileName = FileUploadUtils.upload(filePath, file1);
tbSchool.setBackgroundImage(fileName);
tbSchool.setCreator(getUserId());
tbSchool.setCheckStatus(1);
// tbSchool.setSchoolCnName(getRequest().getParameter("schoolCnName"));
// tbSchool.setSchoolEnName(getRequest().getParameter("schoolEnName"));
// tbSchool.setSchoolCnCountry(getRequest().getParameter("schoolCnCountry"));
// tbSchool.setSchoolCnCity(getRequest().getParameter("schoolCnCity"));
// tbSchool.setSchoolEnCountry(getRequest().getParameter("schoolEnCountry"));
// tbSchool.setSchoolEnCity(getRequest().getParameter("schoolEnCity"));
// tbSchool.setSchoolType(ServletUtils.getParameterToInt("schoolType"));
// tbSchool.setSchoolCampus(getRequest().getParameter("schoolCampus"));
// tbSchool.setQsWorld(ServletUtils.getParameterToInt("qsWorld"));
// tbSchool.setQsArea(ServletUtils.getParameterToInt("qsArea"));
// tbSchool.setSchoolIntroduction(getRequest().getParameter("schoolIntroduction"));
// tbSchool.setSchoolArea(Float.parseFloat(getRequest().getParameter("schoolArea")));
// tbSchool.setLiveType(getRequest().getParameter("liveType"));
// tbSchool.setAirportPickup(getRequest().getParameter("airportPickup"));
// tbSchool.setQsEmployability(ServletUtils.getParameterToInt("qsEmployability"));
// tbSchool.setEmploymentRate(getRequest().getParameter("employmentRate"));
// tbSchool.setTeachingLanguage(getRequest().getParameter("teachingLanguage"));
// tbSchool.setInternship(getRequest().getParameter("internship"));
// tbSchool.setGovAuth(getRequest().getParameter("govAuth"));
setParameters(tbSchool,getRequest());
}
} catch (IOException e) {
e.printStackTrace();
}
tbSchool.setCreator(getUserId());
return toAjax(tbSchoolService.insertTbSchool(tbSchool));
}
// public AjaxResult addSave(TbSchool tbSchool)
// {
// return toAjax(tbSchoolService.insertTbSchool(tbSchool));
// }
/**
* 修改学校信息
......@@ -184,49 +170,40 @@ public class TbSchoolController extends BaseController
@Log(title = "学校信息", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@RequestParam(value="schoolLogo",required=false) MultipartFile file,
@RequestParam(value="backgroundImage",required=false) MultipartFile file1)
public AjaxResult editSave(TbSchool tbSchool)
{
TbSchool tbSchool =new TbSchool();
try {
tbSchool.setId(Long.parseLong(getRequest().getParameter("id")));
setParameters(tbSchool,getRequest());
// tbSchool.setSchoolCnName(getRequest().getParameter("schoolCnName"));
// tbSchool.setSchoolEnName(getRequest().getParameter("schoolEnName"));
// tbSchool.setSchoolCnCountry(getRequest().getParameter("schoolCnCountry"));
// tbSchool.setSchoolCnCity(getRequest().getParameter("schoolCnCity"));
// tbSchool.setSchoolEnCountry(getRequest().getParameter("schoolEnCountry"));
// tbSchool.setSchoolEnCity(getRequest().getParameter("schoolEnCity"));
// tbSchool.setSchoolType(Integer.parseInt(getRequest().getParameter("schoolType")));
// tbSchool.setSchoolCampus(getRequest().getParameter("schoolCampus"));
// tbSchool.setQsWorld(ServletUtils.getParameterToInt("qsWorld"));
// tbSchool.setQsArea(ServletUtils.getParameterToInt("qsArea"));
// tbSchool.setSchoolIntroduction(getRequest().getParameter("schoolIntroduction"));
// tbSchool.setSchoolArea(Float.parseFloat(getRequest().getParameter("schoolArea")));
// tbSchool.setLiveType(getRequest().getParameter("liveType"));
// tbSchool.setAirportPickup(getRequest().getParameter("airportPickup"));
tbSchool.setModifiedBy(getUserId());
if (file != null) {
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = null;
fileName = FileUploadUtils.upload(filePath, file);
tbSchool.setSchoolLogo(fileName);
}
if (file1 != null) {
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = null;
fileName = FileUploadUtils.upload(filePath, file1);
tbSchool.setBackgroundImage(fileName);
}
} catch (IOException e) {
e.printStackTrace();
}
tbSchool.setModifiedBy(getUserId());
return toAjax(tbSchoolService.updateTbSchool(tbSchool));
}
// public AjaxResult editSave(@RequestParam(value="schoolLogo",required=false) MultipartFile file,
// @RequestParam(value="backgroundImage",required=false) MultipartFile file1)
// {
// TbSchool tbSchool =new TbSchool();
// try {
// tbSchool.setId(Long.parseLong(getRequest().getParameter("id")));
// setParameters(tbSchool,getRequest());
// tbSchool.setModifiedBy(getUserId());
// if (file != null) {
// // 上传文件路径
// String filePath = RuoYiConfig.getUploadPath();
// // 上传并返回新文件名称
// String fileName = null;
// fileName = FileUploadUtils.upload(filePath, file);
// tbSchool.setSchoolLogo(fileName);
// }
// if (file1 != null) {
// // 上传文件路径
// String filePath = RuoYiConfig.getUploadPath();
// // 上传并返回新文件名称
// String fileName = null;
// fileName = FileUploadUtils.upload(filePath, file1);
// tbSchool.setBackgroundImage(fileName);
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
// return toAjax(tbSchoolService.updateTbSchool(tbSchool));
// }
public void setParameters(TbSchool tbSchool, HttpServletRequest request){
tbSchool.setSchoolCnName(request.getParameter("schoolCnName"));
......@@ -249,10 +226,7 @@ public class TbSchoolController extends BaseController
tbSchool.setInternship(getRequest().getParameter("internship"));
tbSchool.setGovAuth(getRequest().getParameter("govAuth"));
}
// public AjaxResult editSave(TbSchool tbSchool)
// {
// return toAjax(tbSchoolService.updateTbSchool(tbSchool));
// }
/**
* 删除学校信息
......
......@@ -2,6 +2,9 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('审核学校信息')" />
<th:block th:include="include :: select2-css" />
<th:block th:include="include :: bootstrap-select-css" />
<th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
......@@ -44,6 +47,36 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">学校详细地址(英文):</label>
<div class="col-sm-8">
<input name="address" id="address" th:field="*{address}" class="form-control" type="text" disabled="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">经度:</label>
<div class="col-sm-8">
<input name="lng" id="lng" th:field="*{lng}" class="form-control" type="text" disabled="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">纬度:</label>
<div class="col-sm-8">
<input name="lat" id="lat" th:field="*{lat}" class="form-control" type="text" disabled="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">电话:</label>
<div class="col-sm-8">
<input name="phone" id="phone" th:field="*{phone}" class="form-control" type="text" disabled="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">网址:</label>
<div class="col-sm-8">
<input name="website" id="website" th:field="*{website}" class="form-control" type="text" disabled="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">学校类型:</label>
<div class="col-sm-8">
<input id="schoolTypeDesc" th:field="*{schoolTypeDesc}" class="form-control" type="text" disabled="true">
......@@ -113,23 +146,21 @@
</select>
</div>
</div>
<div class="form-group">
<div class="form-group">
<label class="col-sm-3 control-label is-required">学校logo:</label>
<input type="hidden" id="schoolLogo" th:field="*{schoolLogo}">
<div class="col-sm-8">
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-new thumbnail" style="width: 400px; height: 200px;">
<img id="imgId1" th:src="*{schoolLogo}" disabled="true"/>
</div>
<div class="file-loading">
<input id="singleFile" name="file" type="file" disabled="true">
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">学校图片:</label>
<label class="col-sm-3 control-label is-required">学校背景图:</label>
<input type="hidden" id="backgroundImage" th:field="*{backgroundImage}">
<div class="col-sm-8">
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-new thumbnail" style="width: 400px; height: 200px;">
<img id="imgId2" th:src="*{backgroundImage}" disabled="true"/>
</div>
<div class="file-loading">
<input id="singleFile1" name="file" type="file" disabled="true">
</div>
</div>
</div>
......@@ -137,7 +168,7 @@
<div class="form-group">
<label class="col-sm-3 control-label is-required">住宿类型:</label>
<div class="col-sm-8">
<select id="liveType1" class="form-control select2-multiple" multiple disabled="true">
<select id="liveType1" class="form-control select2-multiple" disabled="true" multiple>
</select>
</div>
</div>
......@@ -167,6 +198,9 @@
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: bootstrap-select-js" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<script th:inline="javascript">
var prefix = ctx + "system/schoolCheck";
$("#form-school-edit").validate({
......@@ -227,6 +261,92 @@
$.operate.save(prefix + "/editCheckStatus", $('#form-school-edit').serialize()+"&checkStatus="+$('#checkStatus')[0].value);
}
}
initUpload();
initUpload1();
//初始化方法
function initUpload() {
var logoUrl = $("#schoolLogo").val();//拿到图片路径
var preList = new Array();
var initialPreviewConfig = new Array();
//设置初始化区域值
if (logoUrl != null && logoUrl != ''){
var a = {
// caption : '主图'+(i+1),
// width: '120px',
url: '/common/del',
// key: i,
extra: {url: logoUrl}
}
preList.push(logoUrl);
initialPreviewConfig.push(a);
}
$("#singleFile").fileinput({
language: 'zh', //设置语言
uploadUrl: "/common/upload", //上传的地址,改成自己的
allowedFileExtensions:['bmp', 'gif', 'jpg', 'jpeg', 'png'],//接收的文件后缀
initialPreviewAsData:true,
initialPreview:preList,//预览图片
uploadAsync: true, //默认异步上传
showUpload: true, //是否显示上传按钮
showRemove : false, //显示移除按钮
showPreview : true, //是否显示预览
showCaption: false,//是否显示标题
browseClass: "btn btn-primary", //按钮样式
dropZoneEnabled: false,//是否显示拖拽区域
maxFileCount: 1, //表示允许同时上传的最大文件个数
maxFileSize:10 *1024 *1024,
messages: {maxFileSize:'文件上传的最大大小为 10MB',acceptFileTypes:'此文件是不支持的图片格式' },
enctype: 'multipart/form-data',
validateInitialCount:true,
msgFilesTooMany:5,
autoReplace:false,
initialPreviewConfig:initialPreviewConfig
});
}
function initUpload1() {
var logoUrl = $("#backgroundImage").val();//拿到图片路径
var preList = new Array();
var initialPreviewConfig = new Array();
//设置初始化区域值
if (logoUrl != null && logoUrl != ''){
var a = {
// caption : '主图'+(i+1),
// width: '120px',
url: '/common/del',
// key: i,
extra: {url: logoUrl}
}
preList.push(logoUrl);
initialPreviewConfig.push(a);
}
$("#singleFile1").fileinput({
language: 'zh', //设置语言
uploadUrl: "/common/upload", //上传的地址,改成自己的
allowedFileExtensions:['bmp', 'gif', 'jpg', 'jpeg', 'png'],//接收的文件后缀
initialPreviewAsData:true,
initialPreview:preList,//预览图片
uploadAsync: true, //默认异步上传
showUpload: true, //是否显示上传按钮
showRemove : false, //显示移除按钮
showPreview : true, //是否显示预览
showCaption: false,//是否显示标题
browseClass: "btn btn-primary", //按钮样式
dropZoneEnabled: false,//是否显示拖拽区域
maxFileCount: 1, //表示允许同时上传的最大文件个数
maxFileSize:10 *1024 *1024,
messages: {maxFileSize:'文件上传的最大大小为 10MB',acceptFileTypes:'此文件是不支持的图片格式' },
enctype: 'multipart/form-data',
validateInitialCount:true,
msgFilesTooMany:5,
autoReplace:false,
initialPreviewConfig:initialPreviewConfig
});
}
</script>
</body>
</html>
\ No newline at end of file
......@@ -128,6 +128,22 @@ public class TbSchool extends BaseEntity
*/
private String govAuth;
/**
* 经度
*/
private String lng;
/**
* 维度
*/
private String lat;
private String address;
private String phone;
private String website;
public String getSchoolIntroduction() {
return schoolIntroduction;
}
......@@ -353,6 +369,46 @@ public class TbSchool extends BaseEntity
this.govAuth = govAuth;
}
public String getLng() {
return lng;
}
public void setLng(String lng) {
this.lng = lng;
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getWebsite() {
return website;
}
public void setWebsite(String website) {
this.website = website;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......
......@@ -35,6 +35,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="teachingLanguage" column="teaching_language" />
<result property="internship" column="internship" />
<result property="govAuth" column="gov_auth" />
<result property="lng" column="lng" />
<result property="lat" column="lat" />
<result property="address" column="address" />
<result property="phone" column="phone" />
<result property="website" column="website" />
</resultMap>
<sql id="selectTbSchoolVo">
......@@ -42,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
school_en_city, school_type, school_logo,school_campus,creator, create_time,modified_by,update_time,
checker,check_time,check_status,check_result,background_image,qs_world,
school_introduction,qs_area,school_area,live_type,airport_pickup,employment_rate,qs_employability,
teaching_language,internship,gov_auth
teaching_language,internship,gov_auth,lng,lat,address,phone,website
from tb_school
</sql>
......@@ -82,13 +87,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
school_cn_name,school_en_name,school_cn_country,school_cn_city,school_en_country,
school_en_city,school_logo,school_type,school_campus,creator,qs_world,background_image,
school_introduction,qs_area,school_area,live_type,airport_pickup, create_time, check_status,
employment_rate,qs_employability,teaching_language,internship,gov_auth
employment_rate,qs_employability,teaching_language,internship,gov_auth,lng,lat,address,phone,website
)
values (
#{schoolCnName},#{schoolEnName},#{schoolCnCountry},#{schoolCnCity},#{schoolEnCountry},
#{schoolEnCity},#{schoolLogo},#{schoolType},#{schoolCampus},#{creator},#{qsWorld},
#{backgroundImage},#{schoolIntroduction},#{qsArea},#{schoolArea},#{liveType},#{airportPickup},
sysdate(),1,#{employmentRate},#{qsEmployability},#{teachingLanguage},#{internship},#{govAuth}
sysdate(),1,#{employmentRate},#{qsEmployability},#{teachingLanguage},#{internship},#{govAuth},
#{lng},#{lat},#{address},#{phone},#{website}
)
</insert>
......@@ -117,6 +123,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="teachingLanguage != null and teachingLanguage != ''">teaching_language = #{teachingLanguage},</if>
<if test="internship != null and internship != ''">internship = #{internship},</if>
<if test="govAuth != null and govAuth != ''">gov_auth = #{govAuth},</if>
<if test="lng != null and lng != ''">lng = #{lng},</if>
<if test="lat != null and lat != ''">lat = #{lat},</if>
<if test="address != null and address != ''">address = #{address},</if>
<if test="phone != null and phone != ''">phone = #{phone},</if>
<if test="website != null and website != ''">website = #{website},</if>
update_time = sysdate(),check_status=1,check_result=null,check_time=null,checker=null
</trim>
where id = #{id}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论