提交 4b9bc6a1 authored 作者: 吴德鹏's avatar 吴德鹏

国家管理

上级 99dec99f
package com.platform.controller;
import com.platform.annotation.IgnoreAuth;
import com.platform.entity.CountryEntity;
import com.platform.service.CountryService;
import com.platform.utils.PageUtils;
......@@ -62,6 +63,7 @@ public class CountryController {
/**
* 保存
*/
@IgnoreAuth
@RequestMapping("/save")
@RequiresPermissions("country:save")
@ResponseBody
......
......@@ -8,7 +8,7 @@ import java.util.Date;
* 表名 country
*
* @author lipengjun
* @date 2020-08-27 19:16:32
* @date 2021-01-14 08:18:53
*/
public class CountryEntity implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -21,6 +21,18 @@ public class CountryEntity implements Serializable {
* 国家名称
*/
private String countryName;
/**
* 国家(中文)
*/
private String countryCname;
/**
* 区号
*/
private String areaCode;
/**
* 国旗
*/
private String nationalFlag;
/**
* 状态 0:删除 1:正常
*/
......@@ -60,6 +72,45 @@ public class CountryEntity implements Serializable {
public String getCountryName() {
return countryName;
}
/**
* 设置:国家(中文)
*/
public void setCountryCname(String countryCname) {
this.countryCname = countryCname;
}
/**
* 获取:国家(中文)
*/
public String getCountryCname() {
return countryCname;
}
/**
* 设置:区号
*/
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
/**
* 获取:区号
*/
public String getAreaCode() {
return areaCode;
}
/**
* 设置:国旗
*/
public void setNationalFlag(String nationalFlag) {
this.nationalFlag = nationalFlag;
}
/**
* 获取:国旗
*/
public String getNationalFlag() {
return nationalFlag;
}
/**
* 设置:状态 0:删除 1:正常
*/
......
......@@ -6,15 +6,21 @@
<resultMap type="com.platform.entity.CountryEntity" id="countryMap">
<result property="id" column="id"/>
<result property="countryName" column="country_name"/>
<result property="countryCname" column="country_cname"/>
<result property="areaCode" column="area_code"/>
<result property="nationalFlag" column="national_flag"/>
<result property="status" column="status"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<select id="queryObject" resultType="com.platform.entity.CountryEntity">
<select id="queryObject" resultType="com.platform.entity.CountryEntity">
select
`id`,
`country_name`,
`country_cname`,
`area_code`,
`national_flag`,
`status`,
`create_time`,
`update_time`
......@@ -22,74 +28,86 @@
where id = #{id}
</select>
<select id="queryList" resultType="com.platform.entity.CountryEntity">
select
`id`,
`country_name`,
`status`,
`create_time`,
`update_time`
from country
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<select id="queryList" resultType="com.platform.entity.CountryEntity">
select
`id`,
`country_name`,
`country_cname`,
`area_code`,
`national_flag`,
`status`,
`create_time`,
`update_time`
from country
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND (country_name LIKE concat('%',#{name},'%') or country_cname LIKE concat('%',#{name},'%'))
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by id desc
</otherwise>
<otherwise>
order by isnull(sort), sort asc ,country_name asc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from country
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<insert id="save" parameterType="com.platform.entity.CountryEntity">
</select>
<select id="queryTotal" resultType="int">
select count(*) from country
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND (country_name LIKE concat('%',#{name},'%') or country_cname LIKE concat('%',#{name},'%'))
</if>
</select>
<insert id="save" parameterType="com.platform.entity.CountryEntity">
insert into country(
`id`,
`country_name`,
`country_cname`,
`area_code`,
`national_flag`,
`status`,
`create_time`,
`update_time`)
values(
#{id},
#{countryName},
#{countryCname},
#{areaCode},
#{nationalFlag},
#{status},
#{createTime},
#{updateTime})
</insert>
<update id="update" parameterType="com.platform.entity.CountryEntity">
update country
<set>
<if test="countryName != null">`country_name` = #{countryName}, </if>
<if test="status != null">`status` = #{status}, </if>
<if test="createTime != null">`create_time` = #{createTime}, </if>
<if test="updateTime != null">`update_time` = #{updateTime}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
<update id="update" parameterType="com.platform.entity.CountryEntity">
update country
<set>
<if test="countryName != null">`country_name` = #{countryName},</if>
<if test="countryCname != null">`country_cname` = #{countryCname},</if>
<if test="areaCode != null">`area_code` = #{areaCode},</if>
<if test="nationalFlag != null">`national_flag` = #{nationalFlag},</if>
<if test="status != null">`status` = #{status},</if>
<if test="createTime != null">`create_time` = #{createTime},</if>
<if test="updateTime != null">`update_time` = #{updateTime}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
delete from country where id = #{value}
</delete>
<delete id="deleteBatch">
delete from country where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
<delete id="deleteBatch">
delete from country where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
......@@ -33,8 +33,35 @@
<Card v-show="!showList">
<p slot="title">{{title}}</p>
<i-form ref="formValidate" :model="country" :rules="ruleValidate" :label-width="80">
<Form-item label="国家名称" prop="countryName">
<i-input v-model="country.countryName" placeholder="国家名称"/>
<Form-item label="国家(英文)" prop="countryName" style="width: 800px">
<i-input v-model="country.countryName" placeholder="国家(英文)"/>
</Form-item>
<Form-item label="国家(中文)" prop="countryCname" style="width: 800px">
<i-input v-model="country.countryCname" placeholder="国家(中文)" />
</Form-item>
<Form-item label="区号" prop="areaCode" style="width: 800px">
<i-input v-model="country.areaCode" placeholder="区号"/>
</Form-item>
<!-- <Form-item label="国旗" prop="nationalFlag" style="width: 800px">-->
<!-- <i-input v-model="country.nationalFlag" placeholder="国旗"/>-->
<!-- </Form-item>-->
<Form-item label="国旗" prop="nationalFlag" >
<!-- <i-input v-model="xPicture.pictureUrl" placeholder="图片地址"/> -->
<upload
multiple
action="../api/osstest/uploadtest"
:before-upload="handleBeforeUpload"
:on-success="vhandleSuccess" :show-upload-list="false" accept="image/jpeg, image/png">
<i-button icon="ios-cloud-upload-outline">请选择图片</i-button>
</upload>
<div id="imgWrapper" style="display: flex;position: relative;">
<div v-for="item in uploadList" style="margin-left: 5px;" :data-img-path="item">
<img :src="item" width="100" height="100" id="itemImg">
<i class="ivu-icon ivu-icon-ios-trash-outline"
style="cursor:pointer;display: flex;font-size: 24px;position: relative;left:11px"
@click="delImg1(item)"></i>
</div>
</div>
</Form-item>
<Form-item>
<i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
......
......@@ -2,101 +2,183 @@ $(function () {
$("#jqGrid").Grid({
url: '../country/list',
colModel: [
{label: 'id', name: 'id', index: 'id', key: true, hidden: true},
{label: '国家名称', name: 'countryName', index: 'country_name', width: 80},
{label: '状态', name: 'status', index: 'status', width: 80,formatter:statusFormat1},
{label: '创建时间', name: 'createTime', index: 'create_time', width: 80}
]
{label: 'id', name: 'id', index: 'id', key: true, hidden: true},
{label: '国旗', name: 'nationalFlag', index: 'national_flag', width: 80, formatter: imageFormat},
{label: '国家(英文)', name: 'countryName', index: 'country_name', width: 80},
{label: '国家(中文)', name: 'countryCname', index: 'country_cname', width: 80},
{label: '区号', name: 'areaCode', index: 'area_code', width: 80},
{label: '状态', name: 'status', index: 'status', width: 80, formatter: statusFormat1},
{label: '创建时间', name: 'createTime', index: 'create_time', width: 80}
]
});
});
let vm = new Vue({
el: '#rrapp',
data: {
el: '#rrapp',
data: {
uploadList: [],
showList: true,
title: null,
country: {},
ruleValidate: {
name: [
{required: true, message: '名称不能为空', trigger: 'blur'}
]
},
q: {
name: ''
}
},
methods: {
query: function () {
vm.reload();
},
add: function () {
vm.showList = false;
vm.title = "新增";
vm.country = {};
},
update: function (event) {
country: {},
ruleValidate: {
name: [
{required: true, message: '名称不能为空', trigger: 'blur'}
]
},
q: {
name: ''
}
},
methods: {
query: function () {
vm.reload();
},
add: function () {
vm.showList = false;
vm.title = "新增";
vm.country = {};
},
update: function (event) {
let id = getSelectedRow("#jqGrid");
if (id == null) {
return;
}
vm.showList = false;
if (id == null) {
return;
}
vm.showList = false;
vm.title = "修改";
vm.getInfo(id);
},
saveOrUpdate: function (event) {
},
saveOrUpdate: function (event) {
let url = vm.country.id == null ? "../country/save" : "../country/update";
vm.country.nationalFlag = vm.uploadList[0];
Ajax.request({
url: url,
url: url,
params: JSON.stringify(vm.country),
type: "POST",
contentType: "application/json",
contentType: "application/json",
successCallback: function (r) {
alert('操作成功', function (index) {
vm.reload();
});
}
});
},
del: function (event) {
});
},
del: function (event) {
let ids = getSelectedRows("#jqGrid");
if (ids == null){
return;
}
if (ids == null) {
return;
}
confirm('确定要删除选中的记录?', function () {
confirm('确定要删除选中的记录?', function () {
Ajax.request({
url: "../country/delete",
url: "../country/delete",
params: JSON.stringify(ids),
type: "POST",
contentType: "application/json",
contentType: "application/json",
successCallback: function () {
alert('操作成功', function (index) {
vm.reload();
});
}
});
});
},
getInfo: function(id){
}
});
});
},
vhandleSuccess(response, file, fileList) {
// "http://diaosaas-prod.oss-cn-shenzhen.aliyuncs.com/education/155728894307110106.jpg"
console.log('shangchuan', response)
vm.uploadList.push(response);
$("#itemImg").show();
},
handleSuccess(response, file, fileList) {
// "http://diaosaas-prod.oss-cn-shenzhen.aliyuncs.com/education/155728894307110106.jpg"
vm.uploadList1.push(response);
$("#skuImg").show();
},
handleBeforeUpload(file) {
// 上传图片大小不超过5M
if (file.size > 5 * 1024 * 1024) {
alert('请上传不超过5M的图片');
return false;
}
// const check = this.uploadList.length < 1;
// if (!check) {
// this.$Notice.warning({
// title: '最多只能上传一张图片'
// });
// return false;
// }
// 限制上传文件的宽高
// return this.checkImageWH(file,750,320);
},
// 限制上传图片的宽高
checkImageWH: function (file, width, height) {
let self = this;
return new Promise(function (resolve, reject) {
let filereader = new FileReader();
filereader.onload = e => {
let src = e.target.result;
const image = new Image();
image.onload = function () {
if (width && image.width != width) {
self.$Notice.error({
title: '请上传宽为' + width + "的图片",
});
reject();
} else if (height && image.height != height) {
self.$Notice.error({
title: '请上传高为' + height + "的图片",
});
reject();
} else {
resolve();
}
};
image.onerror = reject;
image.src = src;
};
filereader.readAsDataURL(file);
});
},
// 删除上传图片
delImg1: function (url) {
if (vm.title != "详情") {
vm.uploadList.remove(url);
console.log(url);
Ajax.request({
url: "../api/upload/delFile?url=" + url,
async: false,
type: "POST",
contentType: "application/json",
successCallback: function (resultData) {
// console.log(resultData);
iview.Message.success(resultData.success);
}
});
}
},
getInfo: function (id) {
vm.uploadList=[];
Ajax.request({
url: "../country/info/"+id,
url: "../country/info/" + id,
async: true,
successCallback: function (r) {
vm.country = r.country;
vm.uploadList.push(vm.country.nationalFlag);
}
});
},
reload: function (event) {
vm.showList = true;
},
reload: function (event) {
vm.showList = true;
let page = $("#jqGrid").jqGrid('getGridParam', 'page');
$("#jqGrid").jqGrid('setGridParam', {
$("#jqGrid").jqGrid('setGridParam', {
postData: {'name': vm.q.name},
page: page
}).trigger("reloadGrid");
vm.handleReset('formValidate');
},
reloadSearch: function() {
},
reloadSearch: function () {
vm.q = {
name: ''
};
......@@ -110,5 +192,5 @@ let vm = new Vue({
handleReset: function (name) {
handleResetForm(this, name);
}
}
}
});
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论