基于springboot智慧外贸平台源码和论文

网络的广泛应用给生活带来了十分的便利。所以把智慧外贸管理与现在网络相结合,利用java技术建设智慧外贸平台,实现智慧外贸的信息化。则对于进一步提高智慧外贸管理发展,丰富智慧外贸管理经验能起到不少的促进作用。

智慧外贸平台能够通过互联网得到广泛的、全面的宣传,让尽可能多的用户了解和熟知智慧外贸平台的便捷高效,不仅为群众提供了服务,而且也推广了自己,让更多的群众了解自己。对于智慧外贸而言,若拥有自己的系统,通过系统得到更好的管理,同时提升了形象。

系统设计的现状和趋势,从需求、结构、数据库等方面的设计到系统的实现,分别管理员,买家和商家实现。论文的内容从系统的设计、描述、实现、分析、测试方面来表明开发的过程。本系统根据现实情况来选择一种可行的开发方案,借助java编程语言和MySQL数据库等实现系统的全部功能,接下来对系统进行测试,测试系统是否有漏洞和测试用户权限来完善系统最终系统完成达到相关标准。

关键字:智慧外贸 java  MySQL数据库

基于springboot智慧外贸平台源码和论文376

演示视频:

基于springboot智慧外贸平台源码和论文

Abstract

The wide application of network has brought great convenience to life. Therefore, the combination of smart foreign trade management and the current network, the use of Java technology to build a smart foreign trade platform, to achieve the information of smart foreign trade. For further improve the development of wisdom foreign trade management, rich wisdom foreign trade management experience can play a lot of promoting role.

Smart foreign trade platform can be widely and comprehensively publicized through the Internet, so that as many users as possible can understand and be familiar with the convenience and efficiency of smart foreign trade platform, not only provide services for the masses, but also promote themselves, so that more people know themselves. For intelligent foreign trade, if we have our own system, we can get better management through the system and improve our image.

The present situation and trend of the system design, from the requirements, structure, database and other aspects of the design to the realization of the system, respectively for the realization of the administrator, the buyer and the business. The content of the paper shows the development process from the aspects of system design, description, implementation, analysis and testing. The system according to the reality to choose a feasible development plan, with the help of Java programming language and MySQL database to achieve all the functions of the system, then the system is tested, test whether the system has vulnerabilities and test user permissions to improve the system, the final system to achieve relevant standards.

Keywords: wisdom foreign trade Java MySQL database

表4-1关单信息

字段名称

类型

长度

字段说明

主键

默认值

id

bigint

主键

主键

addtime

timestamp

创建时间

CURRENT_TIMESTAMP

guandanbianhao

varchar

200

关单编号

shangjiazhanghao

varchar

200

商家账号

shangjiaxingming

varchar

200

商家姓名

shangpinmingcheng

varchar

200

商品名称

shangpinfenlei

varchar

200

商品分类

guandanshijian

date

关单时间

guandanbeizhu

longtext

4294967295

关单备注

maijiazhanghao

varchar

200

买家账号

maijiaxingming

varchar

200

买家姓名

表4-2商品信息评论表

字段名称

类型

长度

字段说明

主键

默认值

id

bigint

主键

主键

addtime

timestamp

创建时间

CURRENT_TIMESTAMP

refid

bigint

关联表id

userid

bigint

用户id

nickname

varchar

200

用户名

content

longtext

4294967295

评论内容

reply

longtext

4294967295

回复内容

表4-3token表

字段名称

类型

长度

字段说明

主键

默认值

id

bigint

主键

主键

userid

bigint

用户id

username

varchar

100

用户名

tablename

varchar

100

表名

role

varchar

100

角色

token

varchar

200

密码

addtime

timestamp

新增时间

CURRENT_TIMESTAMP

expiratedtime

timestamp

过期时间

CURRENT_TIMESTAMP

表4-4运单信息

字段名称

类型

长度

字段说明

主键

默认值

id

bigint

主键

主键

addtime

timestamp

创建时间

CURRENT_TIMESTAMP

yundanhao

varchar

200

运单号

shangjiazhanghao

varchar

200

商家账号

shangjiaxingming

varchar

200

商家姓名

shangpinmingcheng

varchar

200

商品名称

shangpinfenlei

varchar

200

商品分类

dengjishijian

datetime

登记时间

yundanneirong

longtext

4294967295

运单内容

maijiazhanghao

varchar

200

买家账号

maijiaxingming

varchar

200

买家姓名

表4-5订单信息

字段名称

类型

长度

字段说明

主键

默认值

id

bigint

主键

主键

addtime

timestamp

创建时间

CURRENT_TIMESTAMP

dingdanbianhao

varchar

200

订单编号

shangjiazhanghao

varchar

200

商家账号

shangjiaxingming

varchar

200

商家姓名

shangpinmingcheng

varchar

200

商品名称

shangpinfenlei

varchar

200

商品分类

gengxinshijian

datetime

更新时间

dingdanxiangqing

longtext

4294967295

订单详情

maijiazhanghao

varchar

200

买家账号

maijiaxingming

varchar

200

买家姓名

表4-6收藏表

字段名称

类型

长度

字段说明

主键

默认值

id

bigint

主键

主键

addtime

timestamp

创建时间

CURRENT_TIMESTAMP

userid

bigint

用户id

refid

bigint

收藏id

tablename

varchar

200

表名

name

varchar

200

收藏名称

picture

varchar

200

收藏图片

type

varchar

200

类型(1:收藏,21:赞,22:踩)

1

inteltype

varchar

200

推荐类型


package com.controller;import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;/*** 业务人员* 后端接口* @author* @email
*/
@RestController
@Controller
@RequestMapping("/yewurenyuan")
public class YewurenyuanController {private static final Logger logger = LoggerFactory.getLogger(YewurenyuanController.class);private static final String TABLE_NAME = "yewurenyuan";@Autowiredprivate YewurenyuanService yewurenyuanService;@Autowiredprivate TokenService tokenService;@Autowiredprivate BaoxiuService baoxiuService;//报修@Autowiredprivate BaoxiuCommentbackService baoxiuCommentbackService;//报修评价@Autowiredprivate BaoxiuFenpeiService baoxiuFenpeiService;//报修分配@Autowiredprivate DictionaryService dictionaryService;//字典@Autowiredprivate FeiyongService feiyongService;//宽带缴费@Autowiredprivate ForumService forumService;//论坛@Autowiredprivate GonggaoService gonggaoService;//公告@Autowiredprivate KuandaiService kuandaiService;//宽带@Autowiredprivate KuandaiCollectionService kuandaiCollectionService;//宽带收藏@Autowiredprivate KuandaiLiuyanService kuandaiLiuyanService;//宽带留言@Autowiredprivate KuandaiOrderService kuandaiOrderService;//宽带开户@Autowiredprivate KuandaiYuyueService kuandaiYuyueService;//宽带预约安装@Autowiredprivate QianyiYuyueService qianyiYuyueService;//迁移申请@Autowiredprivate YonghuService yonghuService;//用户@Autowiredprivate UsersService usersService;//管理员/*** 后端列表*/@RequestMapping("/page")public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永不会进入");else if("用户".equals(role))params.put("yonghuId",request.getSession().getAttribute("userId"));else if("业务人员".equals(role))params.put("yewurenyuanId",request.getSession().getAttribute("userId"));CommonUtil.checkMap(params);PageUtils page = yewurenyuanService.queryPage(params);//字典表数据转换List<YewurenyuanView> list =(List<YewurenyuanView>)page.getList();for(YewurenyuanView c:list){//修改对应字典表字段dictionaryService.dictionaryConvert(c, request);}return R.ok().put("data", page);}/*** 后端详情*/@RequestMapping("/info/{id}")public R info(@PathVariable("id") Long id, HttpServletRequest request){logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);YewurenyuanEntity yewurenyuan = yewurenyuanService.selectById(id);if(yewurenyuan !=null){//entity转viewYewurenyuanView view = new YewurenyuanView();BeanUtils.copyProperties( yewurenyuan , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody YewurenyuanEntity yewurenyuan, HttpServletRequest request){logger.debug("save方法:,,Controller:{},,yewurenyuan:{}",this.getClass().getName(),yewurenyuan.toString());String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永远不会进入");Wrapper<YewurenyuanEntity> queryWrapper = new EntityWrapper<YewurenyuanEntity>().eq("username", yewurenyuan.getUsername()).or().eq("yewurenyuan_phone", yewurenyuan.getYewurenyuanPhone()).or().eq("yewurenyuan_id_number", yewurenyuan.getYewurenyuanIdNumber());logger.info("sql语句:"+queryWrapper.getSqlSegment());YewurenyuanEntity yewurenyuanEntity = yewurenyuanService.selectOne(queryWrapper);if(yewurenyuanEntity==null){yewurenyuan.setCreateTime(new Date());yewurenyuan.setPassword("123456");yewurenyuanService.insert(yewurenyuan);return R.ok();}else {return R.error(511,"账户或者业务人员手机号或者业务人员身份证号已经被使用");}}/*** 后端修改*/@RequestMapping("/update")public R update(@RequestBody YewurenyuanEntity yewurenyuan, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {logger.debug("update方法:,,Controller:{},,yewurenyuan:{}",this.getClass().getName(),yewurenyuan.toString());YewurenyuanEntity oldYewurenyuanEntity = yewurenyuanService.selectById(yewurenyuan.getId());//查询原先数据String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");if("".equals(yewurenyuan.getYewurenyuanPhoto()) || "null".equals(yewurenyuan.getYewurenyuanPhoto())){yewurenyuan.setYewurenyuanPhoto(null);}yewurenyuanService.updateById(yewurenyuan);//根据id更新return R.ok();}/*** 删除*/@RequestMapping("/delete")public R delete(@RequestBody Integer[] ids, HttpServletRequest request){logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());List<YewurenyuanEntity> oldYewurenyuanList =yewurenyuanService.selectBatchIds(Arrays.asList(ids));//要删除的数据yewurenyuanService.deleteBatchIds(Arrays.asList(ids));return R.ok();}/*** 批量上传*/@RequestMapping("/batchInsert")public R save( String fileName, HttpServletRequest request){logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");try {List<YewurenyuanEntity> yewurenyuanList = new ArrayList<>();//上传的东西Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段Date date = new Date();int lastIndexOf = fileName.lastIndexOf(".");if(lastIndexOf == -1){return R.error(511,"该文件没有后缀");}else{String suffix = fileName.substring(lastIndexOf);if(!".xls".equals(suffix)){return R.error(511,"只支持后缀为xls的excel文件");}else{URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径File file = new File(resource.getFile());if(!file.exists()){return R.error(511,"找不到上传文件,请联系管理员");}else{List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件dataList.remove(0);//删除第一行,因为第一行是提示for(List<String> data:dataList){//循环YewurenyuanEntity yewurenyuanEntity = new YewurenyuanEntity();
//                            yewurenyuanEntity.setUsername(data.get(0));                    //账户 要改的
//                            //yewurenyuanEntity.setPassword("123456");//密码
//                            yewurenyuanEntity.setYewurenyuanName(data.get(0));                    //业务人员姓名 要改的
//                            yewurenyuanEntity.setYewurenyuanPhone(data.get(0));                    //业务人员手机号 要改的
//                            yewurenyuanEntity.setYewurenyuanIdNumber(data.get(0));                    //业务人员身份证号 要改的
//                            yewurenyuanEntity.setYewurenyuanPhoto("");//详情和图片
//                            yewurenyuanEntity.setSexTypes(Integer.valueOf(data.get(0)));   //性别 要改的
//                            yewurenyuanEntity.setNewMoney(data.get(0));                    //余额 要改的
//                            yewurenyuanEntity.setYewurenyuanEmail(data.get(0));                    //业务人员邮箱 要改的
//                            yewurenyuanEntity.setCreateTime(date);//时间yewurenyuanList.add(yewurenyuanEntity);//把要查询是否重复的字段放入map中//账户if(seachFields.containsKey("username")){List<String> username = seachFields.get("username");username.add(data.get(0));//要改的}else{List<String> username = new ArrayList<>();username.add(data.get(0));//要改的seachFields.put("username",username);}//业务人员手机号if(seachFields.containsKey("yewurenyuanPhone")){List<String> yewurenyuanPhone = seachFields.get("yewurenyuanPhone");yewurenyuanPhone.add(data.get(0));//要改的}else{List<String> yewurenyuanPhone = new ArrayList<>();yewurenyuanPhone.add(data.get(0));//要改的seachFields.put("yewurenyuanPhone",yewurenyuanPhone);}//业务人员身份证号if(seachFields.containsKey("yewurenyuanIdNumber")){List<String> yewurenyuanIdNumber = seachFields.get("yewurenyuanIdNumber");yewurenyuanIdNumber.add(data.get(0));//要改的}else{List<String> yewurenyuanIdNumber = new ArrayList<>();yewurenyuanIdNumber.add(data.get(0));//要改的seachFields.put("yewurenyuanIdNumber",yewurenyuanIdNumber);}}//查询是否重复//账户List<YewurenyuanEntity> yewurenyuanEntities_username = yewurenyuanService.selectList(new EntityWrapper<YewurenyuanEntity>().in("username", seachFields.get("username")));if(yewurenyuanEntities_username.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(YewurenyuanEntity s:yewurenyuanEntities_username){repeatFields.add(s.getUsername());}return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());}//业务人员手机号List<YewurenyuanEntity> yewurenyuanEntities_yewurenyuanPhone = yewurenyuanService.selectList(new EntityWrapper<YewurenyuanEntity>().in("yewurenyuan_phone", seachFields.get("yewurenyuanPhone")));if(yewurenyuanEntities_yewurenyuanPhone.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(YewurenyuanEntity s:yewurenyuanEntities_yewurenyuanPhone){repeatFields.add(s.getYewurenyuanPhone());}return R.error(511,"数据库的该表中的 [业务人员手机号] 字段已经存在 存在数据为:"+repeatFields.toString());}//业务人员身份证号List<YewurenyuanEntity> yewurenyuanEntities_yewurenyuanIdNumber = yewurenyuanService.selectList(new EntityWrapper<YewurenyuanEntity>().in("yewurenyuan_id_number", seachFields.get("yewurenyuanIdNumber")));if(yewurenyuanEntities_yewurenyuanIdNumber.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(YewurenyuanEntity s:yewurenyuanEntities_yewurenyuanIdNumber){repeatFields.add(s.getYewurenyuanIdNumber());}return R.error(511,"数据库的该表中的 [业务人员身份证号] 字段已经存在 存在数据为:"+repeatFields.toString());}yewurenyuanService.insertBatch(yewurenyuanList);return R.ok();}}}}catch (Exception e){e.printStackTrace();return R.error(511,"批量插入数据异常,请联系管理员");}}/*** 登录*/@IgnoreAuth@RequestMapping(value = "/login")public R login(String username, String password, String captcha, HttpServletRequest request) {YewurenyuanEntity yewurenyuan = yewurenyuanService.selectOne(new EntityWrapper<YewurenyuanEntity>().eq("username", username));if(yewurenyuan==null || !yewurenyuan.getPassword().equals(password))return R.error("账号或密码不正确");String token = tokenService.generateToken(yewurenyuan.getId(),username, "yewurenyuan", "业务人员");R r = R.ok();r.put("token", token);r.put("role","业务人员");r.put("username",yewurenyuan.getYewurenyuanName());r.put("tableName","yewurenyuan");r.put("userId",yewurenyuan.getId());return r;}/*** 注册*/@IgnoreAuth@PostMapping(value = "/register")public R register(@RequestBody YewurenyuanEntity yewurenyuan, HttpServletRequest request) {
//    	ValidatorUtils.validateEntity(user);Wrapper<YewurenyuanEntity> queryWrapper = new EntityWrapper<YewurenyuanEntity>().eq("username", yewurenyuan.getUsername()).or().eq("yewurenyuan_phone", yewurenyuan.getYewurenyuanPhone()).or().eq("yewurenyuan_id_number", yewurenyuan.getYewurenyuanIdNumber());YewurenyuanEntity yewurenyuanEntity = yewurenyuanService.selectOne(queryWrapper);if(yewurenyuanEntity != null)return R.error("账户或者业务人员手机号或者业务人员身份证号已经被使用");yewurenyuan.setNewMoney(0.0);yewurenyuan.setCreateTime(new Date());yewurenyuanService.insert(yewurenyuan);return R.ok();}/*** 重置密码*/@GetMapping(value = "/resetPassword")public R resetPassword(Integer  id, HttpServletRequest request) {YewurenyuanEntity yewurenyuan = yewurenyuanService.selectById(id);yewurenyuan.setPassword("123456");yewurenyuanService.updateById(yewurenyuan);return R.ok();}/*** 修改密码*/@GetMapping(value = "/updatePassword")public R updatePassword(String  oldPassword, String  newPassword, HttpServletRequest request) {YewurenyuanEntity yewurenyuan = yewurenyuanService.selectById((Integer)request.getSession().getAttribute("userId"));if(newPassword == null){return R.error("新密码不能为空") ;}if(!oldPassword.equals(yewurenyuan.getPassword())){return R.error("原密码输入错误");}if(newPassword.equals(yewurenyuan.getPassword())){return R.error("新密码不能和原密码一致") ;}yewurenyuan.setPassword(newPassword);yewurenyuanService.updateById(yewurenyuan);return R.ok();}/*** 忘记密码*/@IgnoreAuth@RequestMapping(value = "/resetPass")public R resetPass(String username, HttpServletRequest request) {YewurenyuanEntity yewurenyuan = yewurenyuanService.selectOne(new EntityWrapper<YewurenyuanEntity>().eq("username", username));if(yewurenyuan!=null){yewurenyuan.setPassword("123456");yewurenyuanService.updateById(yewurenyuan);return R.ok();}else{return R.error("账号不存在");}}/*** 获取用户的session用户信息*/@RequestMapping("/session")public R getCurrYewurenyuan(HttpServletRequest request){Integer id = (Integer)request.getSession().getAttribute("userId");YewurenyuanEntity yewurenyuan = yewurenyuanService.selectById(id);if(yewurenyuan !=null){//entity转viewYewurenyuanView view = new YewurenyuanView();BeanUtils.copyProperties( yewurenyuan , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 退出*/@GetMapping(value = "logout")public R logout(HttpServletRequest request) {request.getSession().invalidate();return R.ok("退出成功");}/*** 前端列表*/@IgnoreAuth@RequestMapping("/list")public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));CommonUtil.checkMap(params);PageUtils page = yewurenyuanService.queryPage(params);//字典表数据转换List<YewurenyuanView> list =(List<YewurenyuanView>)page.getList();for(YewurenyuanView c:list)dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段return R.ok().put("data", page);}/*** 前端详情*/@RequestMapping("/detail/{id}")public R detail(@PathVariable("id") Long id, HttpServletRequest request){logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);YewurenyuanEntity yewurenyuan = yewurenyuanService.selectById(id);if(yewurenyuan !=null){//entity转viewYewurenyuanView view = new YewurenyuanView();BeanUtils.copyProperties( yewurenyuan , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 前端保存*/@RequestMapping("/add")public R add(@RequestBody YewurenyuanEntity yewurenyuan, HttpServletRequest request){logger.debug("add方法:,,Controller:{},,yewurenyuan:{}",this.getClass().getName(),yewurenyuan.toString());Wrapper<YewurenyuanEntity> queryWrapper = new EntityWrapper<YewurenyuanEntity>().eq("username", yewurenyuan.getUsername()).or().eq("yewurenyuan_phone", yewurenyuan.getYewurenyuanPhone()).or().eq("yewurenyuan_id_number", yewurenyuan.getYewurenyuanIdNumber())
//            .notIn("yewurenyuan_types", new Integer[]{102});logger.info("sql语句:"+queryWrapper.getSqlSegment());YewurenyuanEntity yewurenyuanEntity = yewurenyuanService.selectOne(queryWrapper);if(yewurenyuanEntity==null){yewurenyuan.setCreateTime(new Date());yewurenyuan.setPassword("123456");yewurenyuanService.insert(yewurenyuan);return R.ok();}else {return R.error(511,"账户或者业务人员手机号或者业务人员身份证号已经被使用");}}}

 


package com.controller;import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;/*** 用户* 后端接口* @author* @email
*/
@RestController
@Controller
@RequestMapping("/yonghu")
public class YonghuController {private static final Logger logger = LoggerFactory.getLogger(YonghuController.class);private static final String TABLE_NAME = "yonghu";@Autowiredprivate YonghuService yonghuService;@Autowiredprivate TokenService tokenService;@Autowiredprivate DictionaryService dictionaryService;//字典@Autowiredprivate ForumService forumService;//交流论坛@Autowiredprivate GonggaoService gonggaoService;//公告资讯@Autowiredprivate HanfuService hanfuService;//汉服信息@Autowiredprivate HanfuCollectionService hanfuCollectionService;//汉服收藏@Autowiredprivate HanfuCommentbackService hanfuCommentbackService;//汉服评价@Autowiredprivate HanfuOrderService hanfuOrderService;//汉服租赁@Autowiredprivate UsersService usersService;//管理员/*** 后端列表*/@RequestMapping("/page")public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永不会进入");else if("用户".equals(role))params.put("yonghuId",request.getSession().getAttribute("userId"));CommonUtil.checkMap(params);PageUtils page = yonghuService.queryPage(params);//字典表数据转换List<YonghuView> list =(List<YonghuView>)page.getList();for(YonghuView c:list){//修改对应字典表字段dictionaryService.dictionaryConvert(c, request);}return R.ok().put("data", page);}/*** 后端详情*/@RequestMapping("/info/{id}")public R info(@PathVariable("id") Long id, HttpServletRequest request){logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);YonghuEntity yonghu = yonghuService.selectById(id);if(yonghu !=null){//entity转viewYonghuView view = new YonghuView();BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){logger.debug("save方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永远不会进入");Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>().eq("username", yonghu.getUsername()).or().eq("yonghu_phone", yonghu.getYonghuPhone()).or().eq("yonghu_id_number", yonghu.getYonghuIdNumber());logger.info("sql语句:"+queryWrapper.getSqlSegment());YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);if(yonghuEntity==null){yonghu.setCreateTime(new Date());yonghu.setPassword("123456");yonghuService.insert(yonghu);return R.ok();}else {return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");}}/*** 后端修改*/@RequestMapping("/update")public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {logger.debug("update方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());YonghuEntity oldYonghuEntity = yonghuService.selectById(yonghu.getId());//查询原先数据String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");if("".equals(yonghu.getYonghuPhoto()) || "null".equals(yonghu.getYonghuPhoto())){yonghu.setYonghuPhoto(null);}yonghuService.updateById(yonghu);//根据id更新return R.ok();}/*** 删除*/@RequestMapping("/delete")public R delete(@RequestBody Integer[] ids, HttpServletRequest request){logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());List<YonghuEntity> oldYonghuList =yonghuService.selectBatchIds(Arrays.asList(ids));//要删除的数据yonghuService.deleteBatchIds(Arrays.asList(ids));return R.ok();}/*** 批量上传*/@RequestMapping("/batchInsert")public R save( String fileName, HttpServletRequest request){logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))try {List<YonghuEntity> yonghuList = new ArrayList<>();//上传的东西Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段Date date = new Date();int lastIndexOf = fileName.lastIndexOf(".");if(lastIndexOf == -1){return R.error(511,"该文件没有后缀");}else{String suffix = fileName.substring(lastIndexOf);if(!".xls".equals(suffix)){return R.error(511,"只支持后缀为xls的excel文件");}else{URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径File file = new File(resource.getFile());if(!file.exists()){return R.error(511,"找不到上传文件,请联系管理员");}else{List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件dataList.remove(0);//删除第一行,因为第一行是提示for(List<String> data:dataList){//循环YonghuEntity yonghuEntity = new YonghuEntity();
//                            yonghuEntity.setUsername(data.get(0));                    //账户 要改的
//                            yonghuEntity.setPassword("123456");//密码
//                            yonghuEntity.setYonghuUuidNumber(data.get(0));                    //用户编号 要改的
//                            yonghuEntity.setYonghuName(data.get(0));                    //用户姓名 要改的
//                            yonghuEntity.setYonghuPhone(data.get(0));                    //用户手机号 要改的
//                            yonghuEntity.setYonghuIdNumber(data.get(0));                    //用户身份证号 要改的
//                            yonghuEntity.setYonghuPhoto("");//详情和图片
//                            yonghuEntity.setSexTypes(Integer.valueOf(data.get(0)));   //性别 要改的
//                            yonghuEntity.setNewMoney(data.get(0));                    //余额 要改的
//                            yonghuEntity.setYonghuEmail(data.get(0));                    //用户邮箱 要改的
//                            yonghuEntity.setCreateTime(date);//时间yonghuList.add(yonghuEntity);//把要查询是否重复的字段放入map中//账户if(seachFields.containsKey("username")){List<String> username = seachFields.get("username");username.add(data.get(0));//要改的}else{List<String> username = new ArrayList<>();username.add(data.get(0));//要改的seachFields.put("username",username);}//用户编号if(seachFields.containsKey("yonghuUuidNumber")){List<String> yonghuUuidNumber = seachFields.get("yonghuUuidNumber");yonghuUuidNumber.add(data.get(0));//要改的}else{List<String> yonghuUuidNumber = new ArrayList<>();yonghuUuidNumber.add(data.get(0));//要改的seachFields.put("yonghuUuidNumber",yonghuUuidNumber);}//用户手机号if(seachFields.containsKey("yonghuPhone")){List<String> yonghuPhone = seachFields.get("yonghuPhone");yonghuPhone.add(data.get(0));//要改的}else{List<String> yonghuPhone = new ArrayList<>();yonghuPhone.add(data.get(0));//要改的seachFields.put("yonghuPhone",yonghuPhone);}//用户身份证号if(seachFields.containsKey("yonghuIdNumber")){List<String> yonghuIdNumber = seachFields.get("yonghuIdNumber");yonghuIdNumber.add(data.get(0));//要改的}else{List<String> yonghuIdNumber = new ArrayList<>();yonghuIdNumber.add(data.get(0));//要改的seachFields.put("yonghuIdNumber",yonghuIdNumber);}}//查询是否重复//账户List<YonghuEntity> yonghuEntities_username = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("username", seachFields.get("username")));if(yonghuEntities_username.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(YonghuEntity s:yonghuEntities_username){repeatFields.add(s.getUsername());}return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());}//用户编号List<YonghuEntity> yonghuEntities_yonghuUuidNumber = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_uuid_number", seachFields.get("yonghuUuidNumber")));if(yonghuEntities_yonghuUuidNumber.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(YonghuEntity s:yonghuEntities_yonghuUuidNumber){repeatFields.add(s.getYonghuUuidNumber());}return R.error(511,"数据库的该表中的 [用户编号] 字段已经存在 存在数据为:"+repeatFields.toString());}//用户手机号List<YonghuEntity> yonghuEntities_yonghuPhone = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_phone", seachFields.get("yonghuPhone")));if(yonghuEntities_yonghuPhone.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(YonghuEntity s:yonghuEntities_yonghuPhone){repeatFields.add(s.getYonghuPhone());}return R.error(511,"数据库的该表中的 [用户手机号] 字段已经存在 存在数据为:"+repeatFields.toString());}//用户身份证号List<YonghuEntity> yonghuEntities_yonghuIdNumber = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_id_number", seachFields.get("yonghuIdNumber")));if(yonghuEntities_yonghuIdNumber.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(YonghuEntity s:yonghuEntities_yonghuIdNumber){repeatFields.add(s.getYonghuIdNumber());}return R.error(511,"数据库的该表中的 [用户身份证号] 字段已经存在 存在数据为:"+repeatFields.toString());}yonghuService.insertBatch(yonghuList);return R.ok();}}}}catch (Exception e){e.printStackTrace();return R.error(511,"批量插入数据异常,请联系管理员");}}/*** 登录*/@IgnoreAuth@RequestMapping(value = "/login")public R login(String username, String password, String captcha, HttpServletRequest request) {YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));if(yonghu==null || !yonghu.getPassword().equals(password))return R.error("账号或密码不正确");String token = tokenService.generateToken(yonghu.getId(),username, "yonghu", "用户");R r = R.ok();r.put("token", token);r.put("role","用户");r.put("username",yonghu.getYonghuName());r.put("tableName","yonghu");r.put("userId",yonghu.getId());return r;}/*** 注册*/@IgnoreAuth@PostMapping(value = "/register")public R register(@RequestBody YonghuEntity yonghu, HttpServletRequest request) {
//    	ValidatorUtils.validateEntity(user);Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>().eq("username", yonghu.getUsername()).or().eq("yonghu_phone", yonghu.getYonghuPhone()).or().eq("yonghu_id_number", yonghu.getYonghuIdNumber());YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);if(yonghuEntity != null)return R.error("账户或者用户手机号或者用户身份证号已经被使用");yonghu.setYonghuUuidNumber(String.valueOf(new Date().getTime()));yonghu.setNewMoney(0.0);yonghu.setCreateTime(new Date());yonghuService.insert(yonghu);return R.ok();}/*** 重置密码*/@GetMapping(value = "/resetPassword")public R resetPassword(Integer  id, HttpServletRequest request) {YonghuEntity yonghu = yonghuService.selectById(id);yonghu.setPassword("123456");yonghuService.updateById(yonghu);return R.ok();}/*** 修改密码*/@GetMapping(value = "/updatePassword")public R updatePassword(String  oldPassword, String  newPassword, HttpServletRequest request) {YonghuEntity yonghu = yonghuService.selectById((Integer)request.getSession().getAttribute("userId"));if(newPassword == null){return R.error("新密码不能为空") ;}if(!oldPassword.equals(yonghu.getPassword())){return R.error("原密码输入错误");}if(newPassword.equals(yonghu.getPassword())){return R.error("新密码不能和原密码一致") ;}yonghu.setPassword(newPassword);yonghuService.updateById(yonghu);return R.ok();}/*** 忘记密码*/@IgnoreAuth@RequestMapping(value = "/resetPass")public R resetPass(String username, HttpServletRequest request) {YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));if(yonghu!=null){yonghu.setPassword("123456");yonghuService.updateById(yonghu);return R.ok();}else{return R.error("账号不存在");}}/*** 获取用户的session用户信息*/@RequestMapping("/session")public R getCurrYonghu(HttpServletRequest request){Integer id = (Integer)request.getSession().getAttribute("userId");YonghuEntity yonghu = yonghuService.selectById(id);if(yonghu !=null){//entity转viewYonghuView view = new YonghuView();BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 退出*/@GetMapping(value = "logout")public R logout(HttpServletRequest request) {request.getSession().invalidate();return R.ok("退出成功");}/*** 前端列表*/@IgnoreAuth@RequestMapping("/list")public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));CommonUtil.checkMap(params);PageUtils page = yonghuService.queryPage(params);//字典表数据转换List<YonghuView> list =(List<YonghuView>)page.getList();for(YonghuView c:list)dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段return R.ok().put("data", page);}/*** 前端详情*/@RequestMapping("/detail/{id}")public R detail(@PathVariable("id") Integer id, HttpServletRequest request){logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);YonghuEntity yonghu = yonghuService.selectById(id);if(yonghu !=null){//entity转viewYonghuView view = new YonghuView();BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 前端保存*/@RequestMapping("/add")public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){logger.debug("add方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>().eq("username", yonghu.getUsername()).or().eq("yonghu_phone", yonghu.getYonghuPhone()).or().eq("yonghu_id_number", yonghu.getYonghuIdNumber())
//            .notIn("yonghu_types", new Integer[]{102});logger.info("sql语句:"+queryWrapper.getSqlSegment());YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);if(yonghuEntity==null){yonghu.setCreateTime(new Date());yonghu.setPassword("123456");yonghuService.insert(yonghu);return R.ok();}else {return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");}}}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/258590.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

leetcode206. 反转链表

leetcode206. 反转链表 题目 代码 新链表逐个存储 提取单个节点&#xff0c;添加到新链表的头结点处 class Solution:def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:new_node Nonecurrent headwhile current:rest current.nexttemp_head …

【2024】如何订阅Netflix奈飞?Netflix奈飞购买教程

【2024】如何订阅Netflix奈飞&#xff1f;Netflix奈飞购买教程 Netflix奈飞作为全球领先的在线流媒体平台之一&#xff0c;拥有丰富的影视资源和独家内容&#xff0c;成为了人们追剧的热门选择。本文将为您介绍如何订阅Netflix奈飞&#xff0c;并提供详细的购买教程&#xff0…

详解结构体内存对齐及结构体如何实现位段~

目录 ​编辑 一&#xff1a;结构体内存对齐 1.1对齐规则 1.2.为什么存在内存对齐 1.3修改默认对齐数 二.结构体实现位段 2.1什么是位段 2.2位段的内存分配 2.3位段的跨平台问题 2.4位段的应用 2.5位段使用的注意事项 三.完结散花 悟已往之不谏&#xff0c;知来者犹可…

Springboot+vue的社区养老服务平台(有报告)。Javaee项目,springboot vue前后端分离项目

演示视频&#xff1a; Springbootvue的社区养老服务平台&#xff08;有报告&#xff09;。Javaee项目&#xff0c;springboot vue前后端分离项目 项目介绍&#xff1a; 本文设计了一个基于Springbootvue的前后端分离的社区养老服务平台&#xff0c;采用M&#xff08;model&…

IT行业顶级证书盘点:提升职业含金量的必备证书

IT行业有哪些证书含金量高? 在竞争激烈的IT行业&#xff0c;持有一些知名的顶级证书可以显著提升个人的职业含金量和竞争力。本文将盘点IT行业中那些含金量高的顶级证书&#xff0c;并介绍它们的考试内容、培训途径以及对职业发展的重要性&#xff0c;帮助读者更好地规划自己…

设计模式Python实现

过年在家瞎折腾&#xff0c;闲着无聊看到设计模式&#xff0c;于是就想着用Python实现一下。 简单工厂 根据传入的参数决定创建出哪一种产品类的实例。 class CashFactory:def createCashAdapter(self, type):if type "满100减20":return CashReturn(100, 20)elif…

Netty中的适配器、Handler共享和资源管理

ChannelHandler的适配器 有一些适配器类可以将编写自定义的ChannelHandler所需要的工作降到最低限度&#xff0c; 因为它们提供了定义在对应接口中的所有方法的默认实现。因为有时会忽略那些不感兴趣的 事件&#xff0c;所以Netty提供了抽象积累ChannelInboundHandlerAdapter(…

云计算基础-虚拟机迁移原理

什么是虚拟机迁移 虚拟机迁移是指将正在运行的虚拟机实例从一个物理服务器&#xff08;或主机&#xff09;迁移到另一个物理服务器&#xff08;或主机&#xff09;的过程&#xff0c;而不会中断虚拟机的运行。 虚拟机拟机迁移分类虚 热迁移&#xff1a;开机状态下迁移 冷迁…

计算机毕业设计SSM基于的高校学习资源共享系统

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; vue mybatis Maven mysql5.7或8.0等等组成&#xff0c;B…

深入学习Pandas:数据连接、合并、加入、添加、重构函数的全面指南【第72篇—python:数据连接】

深入学习Pandas&#xff1a;数据连接、合并、加入、添加、重构函数的全面指南 Pandas是Python中最强大且广泛使用的数据处理库之一&#xff0c;提供了丰富的函数和工具&#xff0c;以便更轻松地处理和分析数据。在本文中&#xff0c;我们将深入探讨Pandas中一系列数据连接、合…

LabVIEW开发DUP实时监控系统

LabVIEW开发DUP实时监控系统 该项目采用虚拟仪器设计理念&#xff0c;以LabVIEW作为核心技术平台&#xff0c;开发了一套磁控溅射过程的实时监控系统。实现过程中关键参数的全面数据采集与处理&#xff0c;建立完整的历史数据库&#xff0c;以支持涂层技术的改进和系统向模糊控…

Python算法题集_LRU 缓存

Python算法题集_LRU 缓存 题146&#xff1a;LRU 缓存1. 示例说明2. 题目解析- 题意分解- 优化思路- 测量工具 3. 代码展开1) 标准求解【队列字典】2) 改进版一【有序字典】3) 改进版二【双向链表字典】 4. 最优算法 本文为Python算法题集之一的代码示例 题146&#xff1a;LRU …

论文阅读:《Deep Learning-Based Human Pose Estimation: A Survey》——Part 1:2D HPE

目录 人体姿态识别概述 论文框架 HPE分类 人体建模模型 二维单人姿态估计 回归方法 目前发展 优化 基于热图的方法 基于CNN的几个网络 利用身体结构信息提供构建HPE网络 视频序列中的人体姿态估计 2D多人姿态识别 方法 自上而下 自下而上 2D HPE 总结 数据集…

前端小案例——购买电影票(HTML+CSS+JS, 附源码)

一、前言 实现功能&#xff1a; 这段代码实现了一个简单的电影票选座购买的功能界面。 在页面上展示了一个电影院的座位布局&#xff0c;以及右侧显示了电影信息、选座情况、票价、总计等内容。 用户可以通过点击座位来选择购买电影票&#xff0c;每个座位的状态会在点击时改…

18-k8s控制器资源-cronjob控制器

job控制器是执行完一次任务&#xff0c;就结束&#xff1b; cronjob控制器&#xff0c;是基于job控制器&#xff0c;定期频率性执行任务&#xff1b;等同于linux系统中的crontab一样&#xff1b; 1&#xff0c;编辑cronjob资源清单 [rootk8s231 pi]# vim cronjob.yaml apiVers…

《小强升职记:时间管理故事书》阅读笔记

目录 前言 一、你的时间都去哪儿了 1.1 你真的很忙吗 1.2 如何记录和分析时间日志 1.3 如何找到自己的价值观 二、无压工作法 2.1 传说中的“四象限法则 2.2 衣柜整理法 三、行动时遇到问题怎么办&#xff1f; 3.1 臣服与拖延 3.2 如何做到要事第一&#xff1f; 3.…

[OPEN SQL] 更新数据

UPDATE语句用于更新数据库表中的数据 本次操作使用的数据库表为SCUSTOM&#xff0c;其字段内容如下所示 航班用户(SCUSTOM) 需要操作更新以下数据 1.更新单条数据 语法格式 UPDATE <dbtab> FROM <wa>. UPDATE <dbtab> FROM TABLE <itab>. UPDATE &l…

Github 2024-02-17 开源项目日报 Top10

根据Github Trendings的统计&#xff0c;今日(2024-02-17统计)共有10个项目上榜。根据开发语言中项目的数量&#xff0c;汇总情况如下&#xff1a; 开发语言项目数量Python项目4TypeScript项目3Rust项目2Jupyter Notebook项目1PowerShell项目1JavaScript项目1 Black&#xff…

【C++ STL】你真的了解string吗?浅谈string的底层实现

文章目录 底层结构概述扩容机制浅拷贝与深拷贝插入和删除的效率浅谈VS和g的优化总结 底层结构概述 string可以帮助我们很好地管理字符串&#xff0c;但是你真的了解她吗&#xff1f;事实上&#xff0c;string的设计是非常复杂的&#xff0c;拥有上百个接口&#xff0c;但最常用…

力扣题目训练(12)

2024年2月5日力扣题目训练 2024年2月5日力扣题目训练476. 数字的补数482. 密钥格式化485. 最大连续 1 的个数148. 排序链表164. 最大间距 2024年2月5日力扣题目训练 2024年2月5日第十二天编程训练&#xff0c;今天主要是进行一些题训练&#xff0c;包括简单题3道、中等题2道和…