基于javaweb+mysql的ssm+maven社区居民户籍管理平台(java+ssm+vue+js+tomcat)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM+Maven社区居民户籍管理平台(java+ssm+vue+js+tomcat)
管理员
admin 123456
居民
居民账号1 123456
居民账号2 123456
居民账号3 123456
居民账号4 123456
居民账号5 123456
居民账号6 123456
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody JuminEntity jumin){
//ValidatorUtils.validateEntity(jumin);
JuminEntity user = juminService.selectOne(new EntityWrapper<JuminEntity>().eq("juminzhanghao", jumin.getJuminzhanghao()));
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
jumin.setId(uId);
juminService.insert(jumin);
return R.ok();
}
/**
* 退出
*/
@RequestMapping("/logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
JuminEntity user = juminService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
JuminEntity user = juminService.selectOne(new EntityWrapper<JuminEntity>().eq("juminzhanghao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
juminService.updateById(user);
return R.ok("密码已重置为:123456");
}
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
HujibiangengEntity hujibiangeng = hujibiangengService.selectById(id);
return R.ok().put("data", hujibiangeng);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
HujibiangengEntity hujibiangeng = hujibiangengService.selectById(id);
return R.ok().put("data", hujibiangeng);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody HujibiangengEntity hujibiangeng, HttpServletRequest request){
hujibiangeng.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(hujibiangeng);
hujibiangengService.insert(hujibiangeng);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody HujibiangengEntity hujibiangeng, HttpServletRequest request){
hujibiangeng.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(hujibiangeng);
hujibiangengService.insert(hujibiangeng);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
JuminEntity user = juminService.selectOne(new EntityWrapper<JuminEntity>().eq("juminzhanghao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
juminService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,JuminEntity jumin,
HttpServletRequest request){
EntityWrapper<JuminEntity> ew = new EntityWrapper<JuminEntity>();
PageUtils page = juminService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, jumin), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,JuminEntity jumin,
HttpServletRequest request){
EntityWrapper<JuminEntity> ew = new EntityWrapper<JuminEntity>();
PageUtils page = juminService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, jumin), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( JuminEntity jumin){
EntityWrapper<JuminEntity> ew = new EntityWrapper<JuminEntity>();
ew.allEq(MPUtil.allEQMapPre( jumin, "jumin"));
return R.ok().put("data", juminService.selectListView(ew));
}
JuminEntity user = juminService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
JuminEntity user = juminService.selectOne(new EntityWrapper<JuminEntity>().eq("juminzhanghao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
juminService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,JuminEntity jumin,
HttpServletRequest request){
EntityWrapper<JuminEntity> ew = new EntityWrapper<JuminEntity>();
PageUtils page = juminService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, jumin), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,JuminEntity jumin,
HttpServletRequest request){
EntityWrapper<JuminEntity> ew = new EntityWrapper<JuminEntity>();
PageUtils page = juminService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, jumin), params), params));
return R.ok().put("data", page);
/**
* 迁移信息
* 后端接口
* @email
*/
@RestController
@RequestMapping("/qianyixinxi")
public class QianyixinxiController {
@Autowired
private QianyixinxiService qianyixinxiService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,QianyixinxiEntity qianyixinxi,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("jumin")) {
qianyixinxi.setJuminzhanghao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<QianyixinxiEntity> ew = new EntityWrapper<QianyixinxiEntity>();
PageUtils page = qianyixinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, qianyixinxi), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,QianyixinxiEntity qianyixinxi,
HttpServletRequest request){
EntityWrapper<QianyixinxiEntity> ew = new EntityWrapper<QianyixinxiEntity>();
PageUtils page = qianyixinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, qianyixinxi), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( QianyixinxiEntity qianyixinxi){
EntityWrapper<QianyixinxiEntity> ew = new EntityWrapper<QianyixinxiEntity>();
int count = teshuquntiService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
/**
}
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("jumin")) {
wrapper.eq("juminzhanghao", (String)request.getSession().getAttribute("username"));
}
int count = juzhuzhengxinxiService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
@Autowired
private ConfigService configService;
/**
* 上传文件
*/
@RequestMapping("/upload")
public R upload(@RequestParam("file") MultipartFile file, String type,HttpServletRequest request) throws Exception {
if (file.isEmpty()) {
throw new EIException("上传文件不能为空");
}
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
String fileName = new Date().getTime()+"."+fileExt;
File dest = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+fileName);
file.transferTo(dest);
/**
* 如果使用idea或者eclipse重启项目,发现之前上传的图片或者文件丢失,将下面一行代码注释打开
* 请将以下的"D:\\ssmpiv99\\src\\main\\webapp\\upload"替换成你本地项目的upload路径,
* 并且项目路径不能存在中文、空格等特殊字符
*/
// FileUtils.copyFile(dest, new File("D:\\ssmpiv99\\src\\main\\webapp\\upload"+"/"+fileName)); /**修改了路径以后请将该行最前面的//注释去掉**/
if(StringUtils.isNotBlank(type) && type.equals("1")) {
ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
if(configEntity==null) {
configEntity = new ConfigEntity();
configEntity.setName("faceFile");
configEntity.setValue(fileName);
} else {
configEntity.setValue(fileName);
}
configService.insertOrUpdate(configEntity);
}
return R.ok().put("file", fileName);
}
/**
* 下载文件
*/
@IgnoreAuth
@RequestMapping("/download")
public void download(@RequestParam String fileName, HttpServletRequest request, HttpServletResponse response) {
try {
File file = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+fileName);
if (file.exists()) {
response.reset();
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName+"\"");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setContentType("application/octet-stream; charset=UTF-8");
IOUtils.write(FileUtils.readFileToByteArray(file), response.getOutputStream());
}
// ValidatorUtils.validateEntity(config);
configService.updateById(config);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
configService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}
/**
* 权限(Token)验证
*/
@Component
public class AuthorizationInterceptor implements HandlerInterceptor {
public static final String LOGIN_TOKEN_KEY = "Token";
@Autowired
private TokenService tokenService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//支持跨域请求
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
/**
* 迁移信息
* 后端接口
* @email
*/
@RestController
@RequestMapping("/qianyixinxi")
public class QianyixinxiController {
@Autowired
private QianyixinxiService qianyixinxiService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,QianyixinxiEntity qianyixinxi,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("jumin")) {
qianyixinxi.setJuminzhanghao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<QianyixinxiEntity> ew = new EntityWrapper<QianyixinxiEntity>();
PageUtils page = qianyixinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, qianyixinxi), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,QianyixinxiEntity qianyixinxi,
/**
* 通用接口
*/
@RestController
public class CommonController{
@Autowired
private CommonService commonService;
private static AipFace client = null;
@Autowired
private ConfigService configService;
/**
* 获取table表中的column列表(联动接口)
* @param table
* @param column
* @return
*/
@IgnoreAuth
@RequestMapping("/option/{tableName}/{columnName}")
public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,String level,String parent) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("column", columnName);
if(StringUtils.isNotBlank(level)) {
params.put("level", level);
}
if(StringUtils.isNotBlank(parent)) {
params.put("parent", parent);
}
List<String> data = commonService.getOption(params);
return R.ok().put("data", data);
}
/**
* 根据table中的column获取单条记录
* @param table
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody QuntileibieEntity quntileibie, HttpServletRequest request){
//ValidatorUtils.validateEntity(quntileibie);
quntileibieService.updateById(quntileibie);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
quntileibieService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
}
}
/**
* 迁移信息
* 后端接口
* @email
HttpServletRequest request){
EntityWrapper<QuntileibieEntity> ew = new EntityWrapper<QuntileibieEntity>();
PageUtils page = quntileibieService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, quntileibie), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,QuntileibieEntity quntileibie,
HttpServletRequest request){
EntityWrapper<QuntileibieEntity> ew = new EntityWrapper<QuntileibieEntity>();
PageUtils page = quntileibieService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, quntileibie), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( QuntileibieEntity quntileibie){
EntityWrapper<QuntileibieEntity> ew = new EntityWrapper<QuntileibieEntity>();
ew.allEq(MPUtil.allEQMapPre( quntileibie, "quntileibie"));
return R.ok().put("data", quntileibieService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(QuntileibieEntity quntileibie){
EntityWrapper< QuntileibieEntity> ew = new EntityWrapper< QuntileibieEntity>();
ew.allEq(MPUtil.allEQMapPre( quntileibie, "quntileibie"));
QuntileibieView quntileibieView = quntileibieService.selectView(ew);
return R.ok("查询群体类别成功").put("data", quntileibieView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
QuntileibieEntity quntileibie = quntileibieService.selectById(id);
return R.ok().put("data", quntileibie);
}
/**
* 并且项目路径不能存在中文、空格等特殊字符
*/
// FileUtils.copyFile(dest, new File("D:\\ssmpiv99\\src\\main\\webapp\\upload"+"/"+fileName)); /**修改了路径以后请将该行最前面的//注释去掉**/
if(StringUtils.isNotBlank(type) && type.equals("1")) {
ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
if(configEntity==null) {
configEntity = new ConfigEntity();
configEntity.setName("faceFile");
configEntity.setValue(fileName);
} else {
configEntity.setValue(fileName);
}
configService.insertOrUpdate(configEntity);
}
return R.ok().put("file", fileName);
}
/**
* 下载文件
*/
@IgnoreAuth
@RequestMapping("/download")
public void download(@RequestParam String fileName, HttpServletRequest request, HttpServletResponse response) {
try {
File file = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+fileName);
if (file.exists()) {
response.reset();
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName+"\"");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setContentType("application/octet-stream; charset=UTF-8");
IOUtils.write(FileUtils.readFileToByteArray(file), response.getOutputStream());
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<JuzhuzhengxinxiEntity> wrapper = new EntityWrapper<JuzhuzhengxinxiEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("jumin")) {
wrapper.eq("juminzhanghao", (String)request.getSession().getAttribute("username"));
}
int count = juzhuzhengxinxiService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
HujibiangengEntity hujibiangeng = hujibiangengService.selectById(id);
return R.ok().put("data", hujibiangeng);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody HujibiangengEntity hujibiangeng, HttpServletRequest request){
hujibiangeng.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(hujibiangeng);
hujibiangengService.insert(hujibiangeng);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody HujibiangengEntity hujibiangeng, HttpServletRequest request){
hujibiangeng.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(hujibiangeng);
hujibiangengService.insert(hujibiangeng);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody HujibiangengEntity hujibiangeng, HttpServletRequest request){
//ValidatorUtils.validateEntity(hujibiangeng);
hujibiangengService.updateById(hujibiangeng);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){