From 3c7386736be99cb328637453f967bfc36a0d1d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=B8=E5=B0=8F=E9=9B=A8?= <13709381+you-xiaoyu02@user.noreply.gitee.com> Date: Thu, 27 Jun 2024 09:38:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=94=A8=E6=88=B7=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=90=8E=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/controller/CommonController.java | 248 ++++++++++++++++ .../java/com/controller/ConfigController.java | 111 +++++++ .../java/com/controller/UserController.java | 170 +++++++++++ .../java/com/controller/YonghuController.java | 280 ++++++++++++++++++ src/main/java/com/dao/CommonDao.java | 26 ++ src/main/java/com/dao/ConfigDao.java | 12 + src/main/java/com/dao/TokenDao.java | 22 ++ src/main/java/com/dao/UserDao.java | 22 ++ src/main/java/com/dao/YonghuDao.java | 32 ++ src/main/java/com/entity/ConfigEntity.java | 53 ++++ src/main/java/com/entity/EIException.java | 52 ++++ src/main/java/com/entity/TokenEntity.java | 132 +++++++++ src/main/java/com/entity/UserEntity.java | 77 +++++ src/main/java/com/entity/YonghuEntity.java | 217 ++++++++++++++ .../java/com/entity/model/YonghuModel.java | 179 +++++++++++ src/main/java/com/entity/view/YonghuView.java | 35 +++ src/main/java/com/entity/vo/YonghuVO.java | 178 +++++++++++ src/main/java/com/service/CommonService.java | 20 ++ src/main/java/com/service/ConfigService.java | 16 + src/main/java/com/service/TokenService.java | 26 ++ src/main/java/com/service/UserService.java | 25 ++ src/main/java/com/service/YonghuService.java | 35 +++ .../com/service/impl/CommonServiceImpl.java | 59 ++++ .../com/service/impl/ConfigServiceImpl.java | 33 +++ .../com/service/impl/TokenServiceImpl.java | 79 +++++ .../com/service/impl/UserServiceImpl.java | 49 +++ .../com/service/impl/YonghuServiceImpl.java | 62 ++++ src/main/resources/mapper/CommonDao.xml | 57 ++++ src/main/resources/mapper/ConfigDao.xml | 5 + src/main/resources/mapper/TokenDao.xml | 13 + src/main/resources/mapper/UserDao.xml | 13 + src/main/resources/mapper/YonghuDao.xml | 42 +++ 32 files changed, 2380 insertions(+) create mode 100644 src/main/java/com/controller/CommonController.java create mode 100644 src/main/java/com/controller/ConfigController.java create mode 100644 src/main/java/com/controller/UserController.java create mode 100644 src/main/java/com/controller/YonghuController.java create mode 100644 src/main/java/com/dao/CommonDao.java create mode 100644 src/main/java/com/dao/ConfigDao.java create mode 100644 src/main/java/com/dao/TokenDao.java create mode 100644 src/main/java/com/dao/UserDao.java create mode 100644 src/main/java/com/dao/YonghuDao.java create mode 100644 src/main/java/com/entity/ConfigEntity.java create mode 100644 src/main/java/com/entity/EIException.java create mode 100644 src/main/java/com/entity/TokenEntity.java create mode 100644 src/main/java/com/entity/UserEntity.java create mode 100644 src/main/java/com/entity/YonghuEntity.java create mode 100644 src/main/java/com/entity/model/YonghuModel.java create mode 100644 src/main/java/com/entity/view/YonghuView.java create mode 100644 src/main/java/com/entity/vo/YonghuVO.java create mode 100644 src/main/java/com/service/CommonService.java create mode 100644 src/main/java/com/service/ConfigService.java create mode 100644 src/main/java/com/service/TokenService.java create mode 100644 src/main/java/com/service/UserService.java create mode 100644 src/main/java/com/service/YonghuService.java create mode 100644 src/main/java/com/service/impl/CommonServiceImpl.java create mode 100644 src/main/java/com/service/impl/ConfigServiceImpl.java create mode 100644 src/main/java/com/service/impl/TokenServiceImpl.java create mode 100644 src/main/java/com/service/impl/UserServiceImpl.java create mode 100644 src/main/java/com/service/impl/YonghuServiceImpl.java create mode 100644 src/main/resources/mapper/CommonDao.xml create mode 100644 src/main/resources/mapper/ConfigDao.xml create mode 100644 src/main/resources/mapper/TokenDao.xml create mode 100644 src/main/resources/mapper/UserDao.xml create mode 100644 src/main/resources/mapper/YonghuDao.xml diff --git a/src/main/java/com/controller/CommonController.java b/src/main/java/com/controller/CommonController.java new file mode 100644 index 0000000..1bf66d7 --- /dev/null +++ b/src/main/java/com/controller/CommonController.java @@ -0,0 +1,248 @@ +package com.controller; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.ResourceUtils; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.annotation.IgnoreAuth; +import com.baidu.aip.face.AipFace; +import com.baidu.aip.face.MatchRequest; +import com.baidu.aip.util.Base64Util; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.mapper.Wrapper; +import com.entity.ConfigEntity; +import com.service.CommonService; +import com.service.ConfigService; +import com.utils.BaiduUtil; +import com.utils.FileUtil; +import com.utils.R; + +/** + * 通用接口 + */ +@RestController +public class CommonController{ + @Autowired + private CommonService commonService; + + @Autowired + private ConfigService configService; + + private static AipFace client = null; + + private static String BAIDU_DITU_AK = null; + + @RequestMapping("/location") + public R location(String lng,String lat) { + if(BAIDU_DITU_AK==null) { + BAIDU_DITU_AK = configService.selectOne(new EntityWrapper().eq("name", "baidu_ditu_ak")).getValue(); + if(BAIDU_DITU_AK==null) { + return R.error("请在配置管理中正确配置baidu_ditu_ak"); + } + } + Map map = BaiduUtil.getCityByLonLat(BAIDU_DITU_AK, lng, lat); + return R.ok().put("data", map); + } + + /** + * 人脸比对 + * + * @param face1 人脸1 + * @param face2 人脸2 + * @return + */ + @RequestMapping("/matchFace") + public R matchFace(String face1, String face2) { + if(client==null) { + /*String AppID = configService.selectOne(new EntityWrapper().eq("name", "AppID")).getValue();*/ + String APIKey = configService.selectOne(new EntityWrapper().eq("name", "APIKey")).getValue(); + String SecretKey = configService.selectOne(new EntityWrapper().eq("name", "SecretKey")).getValue(); + String token = BaiduUtil.getAuth(APIKey, SecretKey); + if(token==null) { + return R.error("请在配置管理中正确配置APIKey和SecretKey"); + } + client = new AipFace(null, APIKey, SecretKey); + client.setConnectionTimeoutInMillis(2000); + client.setSocketTimeoutInMillis(60000); + } + JSONObject res = null; + try { + File file1 = new File(ResourceUtils.getFile("classpath:static/upload").getAbsolutePath()+"/"+face1); + File file2 = new File(ResourceUtils.getFile("classpath:static/upload").getAbsolutePath()+"/"+face2); + String img1 = Base64Util.encode(FileUtil.FileToByte(file1)); + String img2 = Base64Util.encode(FileUtil.FileToByte(file2)); + MatchRequest req1 = new MatchRequest(img1, "BASE64"); + MatchRequest req2 = new MatchRequest(img2, "BASE64"); + ArrayList requests = new ArrayList(); + requests.add(req1); + requests.add(req2); + res = client.match(requests); + System.out.println(res.get("result")); + } catch (FileNotFoundException e) { + e.printStackTrace(); + return R.error("文件不存在"); + } catch (IOException e) { + e.printStackTrace(); + } + return R.ok().put("data", com.alibaba.fastjson.JSONObject.parse(res.get("result").toString())); + } + + /** + * 获取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 params = new HashMap(); + 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 data = commonService.getOption(params); + return R.ok().put("data", data); + } + + /** + * 根据table中的column获取单条记录 + * @param table + * @param column + * @return + */ + @IgnoreAuth + @RequestMapping("/follow/{tableName}/{columnName}") + public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, @RequestParam String columnValue) { + Map params = new HashMap(); + params.put("table", tableName); + params.put("column", columnName); + params.put("columnValue", columnValue); + Map result = commonService.getFollowByOption(params); + return R.ok().put("data", result); + } + + /** + * 修改table表的sfsh状态 + * @param table + * @param map + * @return + */ + @RequestMapping("/sh/{tableName}") + public R sh(@PathVariable("tableName") String tableName, @RequestBody Map map) { + map.put("table", tableName); + commonService.sh(map); + return R.ok(); + } + + /** + * 获取需要提醒的记录数 + * @param tableName + * @param columnName + * @param type 1:数字 2:日期 + * @param map + * @return + */ + @IgnoreAuth + @RequestMapping("/remind/{tableName}/{columnName}/{type}") + public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, + @PathVariable("type") String type,@RequestParam Map map) { + map.put("table", tableName); + 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)); + } + } + + int count = commonService.remindCount(map); + return R.ok().put("count", count); + } + + /** + * 单列求和 + */ + @IgnoreAuth + @RequestMapping("/cal/{tableName}/{columnName}") + public R cal(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) { + Map params = new HashMap(); + params.put("table", tableName); + params.put("column", columnName); + Map result = commonService.selectCal(params); + return R.ok().put("data", result); + } + + /** + * 分组统计 + */ + @IgnoreAuth + @RequestMapping("/group/{tableName}/{columnName}") + public R group(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) { + Map params = new HashMap(); + params.put("table", tableName); + params.put("column", columnName); + List> result = commonService.selectGroup(params); + return R.ok().put("data", result); + } + + /** + * (按值统计) + */ + @IgnoreAuth + @RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}") + public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName) { + Map params = new HashMap(); + params.put("table", tableName); + params.put("xColumn", xColumnName); + params.put("yColumn", yColumnName); + List> result = commonService.selectValue(params); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + for(Map m : result) { + for(String k : m.keySet()) { + if(m.get(k) instanceof Date) { + m.put(k, sdf.format((Date)m.get(k))); + } + } + } + return R.ok().put("data", result); + } + +} diff --git a/src/main/java/com/controller/ConfigController.java b/src/main/java/com/controller/ConfigController.java new file mode 100644 index 0000000..6e9f123 --- /dev/null +++ b/src/main/java/com/controller/ConfigController.java @@ -0,0 +1,111 @@ + +package com.controller; + + +import java.util.Arrays; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.annotation.IgnoreAuth; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.entity.ConfigEntity; +import com.service.ConfigService; +import com.utils.PageUtils; +import com.utils.R; +import com.utils.ValidatorUtils; + +/** + * 登录相关 + */ +@RequestMapping("config") +@RestController +public class ConfigController{ + + @Autowired + private ConfigService configService; + + /** + * 列表 + */ + @RequestMapping("/page") + public R page(@RequestParam Map params,ConfigEntity config){ + EntityWrapper ew = new EntityWrapper(); + PageUtils page = configService.queryPage(params); + return R.ok().put("data", page); + } + + /** + * 列表 + */ + @IgnoreAuth + @RequestMapping("/list") + public R list(@RequestParam Map params,ConfigEntity config){ + EntityWrapper ew = new EntityWrapper(); + PageUtils page = configService.queryPage(params); + return R.ok().put("data", page); + } + + /** + * 信息 + */ + @RequestMapping("/info/{id}") + public R info(@PathVariable("id") String id){ + ConfigEntity config = configService.selectById(id); + return R.ok().put("data", config); + } + + /** + * 详情 + */ + @IgnoreAuth + @RequestMapping("/detail/{id}") + public R detail(@PathVariable("id") String id){ + ConfigEntity config = configService.selectById(id); + return R.ok().put("data", config); + } + + /** + * 根据name获取信息 + */ + @RequestMapping("/info") + public R infoByName(@RequestParam String name){ + ConfigEntity config = configService.selectOne(new EntityWrapper().eq("name", "faceFile")); + return R.ok().put("data", config); + } + + /** + * 保存 + */ + @PostMapping("/save") + public R save(@RequestBody ConfigEntity config){ +// ValidatorUtils.validateEntity(config); + configService.insert(config); + return R.ok(); + } + + /** + * 修改 + */ + @RequestMapping("/update") + public R update(@RequestBody ConfigEntity config){ +// 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(); + } +} diff --git a/src/main/java/com/controller/UserController.java b/src/main/java/com/controller/UserController.java new file mode 100644 index 0000000..b87f60b --- /dev/null +++ b/src/main/java/com/controller/UserController.java @@ -0,0 +1,170 @@ + +package com.controller; + + +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import com.annotation.IgnoreAuth; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.entity.TokenEntity; +import com.entity.UserEntity; +import com.service.TokenService; +import com.service.UserService; +import com.utils.CommonUtil; +import com.utils.MPUtil; +import com.utils.PageUtils; +import com.utils.R; +import com.utils.ValidatorUtils; + +/** + * 登录相关 + */ +@RequestMapping("users") +@RestController +public class UserController{ + + @Autowired + private UserService userService; + + @Autowired + private TokenService tokenService; + + /** + * 登录 + */ + @IgnoreAuth + @PostMapping(value = "/login") + public R login(String username, String password, String captcha, HttpServletRequest request) { + UserEntity user = userService.selectOne(new EntityWrapper().eq("username", username)); + if(user==null || !user.getPassword().equals(password)) { + return R.error("账号或密码不正确"); + } + String token = tokenService.generateToken(user.getId(),username, "users", user.getRole()); + return R.ok().put("token", token); + } + + /** + * 注册 + */ + @IgnoreAuth + @PostMapping(value = "/register") + public R register(@RequestBody UserEntity user){ +// ValidatorUtils.validateEntity(user); + if(userService.selectOne(new EntityWrapper().eq("username", user.getUsername())) !=null) { + return R.error("用户已存在"); + } + userService.insert(user); + return R.ok(); + } + + /** + * 退出 + */ + @GetMapping(value = "logout") + public R logout(HttpServletRequest request) { + request.getSession().invalidate(); + return R.ok("退出成功"); + } + + /** + * 密码重置 + */ + @IgnoreAuth + @RequestMapping(value = "/resetPass") + public R resetPass(String username, HttpServletRequest request){ + UserEntity user = userService.selectOne(new EntityWrapper().eq("username", username)); + if(user==null) { + return R.error("账号不存在"); + } + user.setPassword("123456"); + userService.update(user,null); + return R.ok("密码已重置为:123456"); + } + + /** + * 列表 + */ + @RequestMapping("/page") + public R page(@RequestParam Map params,UserEntity user){ + EntityWrapper ew = new EntityWrapper(); + PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params)); + return R.ok().put("data", page); + } + + /** + * 列表 + */ + @RequestMapping("/list") + public R list( UserEntity user){ + EntityWrapper ew = new EntityWrapper(); + ew.allEq(MPUtil.allEQMapPre( user, "user")); + return R.ok().put("data", userService.selectListView(ew)); + } + + /** + * 信息 + */ + @RequestMapping("/info/{id}") + public R info(@PathVariable("id") String id){ + UserEntity user = userService.selectById(id); + return R.ok().put("data", user); + } + + /** + * 获取用户的session用户信息 + */ + @RequestMapping("/session") + public R getCurrUser(HttpServletRequest request){ + Long id = (Long)request.getSession().getAttribute("userId"); + UserEntity user = userService.selectById(id); + return R.ok().put("data", user); + } + + /** + * 保存 + */ + @PostMapping("/save") + public R save(@RequestBody UserEntity user){ +// ValidatorUtils.validateEntity(user); + if(userService.selectOne(new EntityWrapper().eq("username", user.getUsername())) !=null) { + return R.error("用户已存在"); + } + userService.insert(user); + return R.ok(); + } + + /** + * 修改 + */ + @RequestMapping("/update") + public R update(@RequestBody UserEntity user){ +// ValidatorUtils.validateEntity(user); + userService.updateById(user);//全部更新 + return R.ok(); + } + + /** + * 删除 + */ + @RequestMapping("/delete") + public R delete(@RequestBody Long[] ids){ + userService.deleteBatchIds(Arrays.asList(ids)); + return R.ok(); + } +} diff --git a/src/main/java/com/controller/YonghuController.java b/src/main/java/com/controller/YonghuController.java new file mode 100644 index 0000000..83205ce --- /dev/null +++ b/src/main/java/com/controller/YonghuController.java @@ -0,0 +1,280 @@ +package com.controller; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Map; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Date; +import java.util.List; +import javax.servlet.http.HttpServletRequest; + +import com.utils.ValidatorUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.mapper.Wrapper; +import com.annotation.IgnoreAuth; + +import com.entity.YonghuEntity; +import com.entity.view.YonghuView; + +import com.service.YonghuService; +import com.service.TokenService; +import com.utils.PageUtils; +import com.utils.R; +import com.utils.MD5Util; +import com.utils.MPUtil; +import com.utils.CommonUtil; + + +/** + * 用户 + * 后端接口 + * @author + * @email + */ +@RestController +@RequestMapping("/yonghu") +public class YonghuController { + @Autowired + private YonghuService yonghuService; + + @Autowired + private TokenService tokenService; + + /** + * 登录 + */ + @IgnoreAuth + @RequestMapping(value = "/login") + public R login(String username, String password, String captcha, HttpServletRequest request) { + YonghuEntity user = yonghuService.selectOne(new EntityWrapper().eq("yonghuming", username)); + if(user==null || !user.getMima().equals(password)) { + return R.error("账号或密码不正确"); + } + + String token = tokenService.generateToken(user.getId(), username,"yonghu", "用户" ); + return R.ok().put("token", token); + } + + /** + * 注册 + */ + @IgnoreAuth + @RequestMapping("/register") + public R register(@RequestBody YonghuEntity yonghu){ + //ValidatorUtils.validateEntity(yonghu); + YonghuEntity user = yonghuService.selectOne(new EntityWrapper().eq("yonghuming", yonghu.getYonghuming())); + if(user!=null) { + return R.error("注册用户已存在"); + } + Long uId = new Date().getTime(); + yonghu.setId(uId); + yonghuService.insert(yonghu); + 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"); + YonghuEntity user = yonghuService.selectById(id); + return R.ok().put("data", user); + } + + /** + * 密码重置 + */ + @IgnoreAuth + @RequestMapping(value = "/resetPass") + public R resetPass(String username, HttpServletRequest request){ + YonghuEntity user = yonghuService.selectOne(new EntityWrapper().eq("yonghuming", username)); + if(user==null) { + return R.error("账号不存在"); + } + user.setMima("123456"); + yonghuService.updateById(user); + return R.ok("密码已重置为:123456"); + } + + + /** + * 后端列表 + */ + @RequestMapping("/page") + public R page(@RequestParam Map params,YonghuEntity yonghu, HttpServletRequest request){ + EntityWrapper ew = new EntityWrapper(); + PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params)); + + return R.ok().put("data", page); + } + + /** + * 前端列表 + */ + @RequestMapping("/list") + public R list(@RequestParam Map params,YonghuEntity yonghu, HttpServletRequest request){ + EntityWrapper ew = new EntityWrapper(); + PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params)); + return R.ok().put("data", page); + } + + /** + * 列表 + */ + @RequestMapping("/lists") + public R list( YonghuEntity yonghu){ + EntityWrapper ew = new EntityWrapper(); + ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu")); + return R.ok().put("data", yonghuService.selectListView(ew)); + } + + /** + * 查询 + */ + @RequestMapping("/query") + public R query(YonghuEntity yonghu){ + EntityWrapper< YonghuEntity> ew = new EntityWrapper< YonghuEntity>(); + ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu")); + YonghuView yonghuView = yonghuService.selectView(ew); + return R.ok("查询用户成功").put("data", yonghuView); + } + + /** + * 后端详情 + */ + @RequestMapping("/info/{id}") + public R info(@PathVariable("id") Long id){ + YonghuEntity yonghu = yonghuService.selectById(id); + return R.ok().put("data", yonghu); + } + + /** + * 前端详情 + */ + @RequestMapping("/detail/{id}") + public R detail(@PathVariable("id") Long id){ + YonghuEntity yonghu = yonghuService.selectById(id); + return R.ok().put("data", yonghu); + } + + + + + /** + * 后端保存 + */ + @RequestMapping("/save") + public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){ + yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); + //ValidatorUtils.validateEntity(yonghu); + YonghuEntity user = yonghuService.selectOne(new EntityWrapper().eq("yonghuming", yonghu.getYonghuming())); + if(user!=null) { + return R.error("用户已存在"); + } + yonghu.setId(new Date().getTime()); + yonghuService.insert(yonghu); + return R.ok(); + } + + /** + * 前端保存 + */ + @RequestMapping("/add") + public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){ + yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); + //ValidatorUtils.validateEntity(yonghu); + YonghuEntity user = yonghuService.selectOne(new EntityWrapper().eq("yonghuming", yonghu.getYonghuming())); + if(user!=null) { + return R.error("用户已存在"); + } + yonghu.setId(new Date().getTime()); + yonghuService.insert(yonghu); + return R.ok(); + } + + /** + * 修改 + */ + @RequestMapping("/update") + public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){ + //ValidatorUtils.validateEntity(yonghu); + yonghuService.updateById(yonghu);//全部更新 + return R.ok(); + } + + + /** + * 删除 + */ + @RequestMapping("/delete") + public R delete(@RequestBody Long[] ids){ + yonghuService.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 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)); + } + } + + Wrapper wrapper = new EntityWrapper(); + if(map.get("remindstart")!=null) { + wrapper.ge(columnName, map.get("remindstart")); + } + if(map.get("remindend")!=null) { + wrapper.le(columnName, map.get("remindend")); + } + + + int count = yonghuService.selectCount(wrapper); + return R.ok().put("count", count); + } + + + +} diff --git a/src/main/java/com/dao/CommonDao.java b/src/main/java/com/dao/CommonDao.java new file mode 100644 index 0000000..bf3656e --- /dev/null +++ b/src/main/java/com/dao/CommonDao.java @@ -0,0 +1,26 @@ + +package com.dao; + +import java.util.List; +import java.util.Map; + +/** + * 通用接口 + */ +public interface CommonDao{ + List getOption(Map params); + + Map getFollowByOption(Map params); + + List getFollowByOption2(Map params); + + void sh(Map params); + + int remindCount(Map params); + + Map selectCal(Map params); + + List> selectGroup(Map params); + + List> selectValue(Map params); +} diff --git a/src/main/java/com/dao/ConfigDao.java b/src/main/java/com/dao/ConfigDao.java new file mode 100644 index 0000000..3b1a357 --- /dev/null +++ b/src/main/java/com/dao/ConfigDao.java @@ -0,0 +1,12 @@ + +package com.dao; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.entity.ConfigEntity; + +/** + * 配置 + */ +public interface ConfigDao extends BaseMapper { + +} diff --git a/src/main/java/com/dao/TokenDao.java b/src/main/java/com/dao/TokenDao.java new file mode 100644 index 0000000..0634193 --- /dev/null +++ b/src/main/java/com/dao/TokenDao.java @@ -0,0 +1,22 @@ + +package com.dao; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.baomidou.mybatisplus.mapper.Wrapper; +import com.baomidou.mybatisplus.plugins.pagination.Pagination; +import com.entity.TokenEntity; + +/** + * token + */ +public interface TokenDao extends BaseMapper { + + List selectListView(@Param("ew") Wrapper wrapper); + + List selectListView(Pagination page,@Param("ew") Wrapper wrapper); + +} diff --git a/src/main/java/com/dao/UserDao.java b/src/main/java/com/dao/UserDao.java new file mode 100644 index 0000000..0d8556e --- /dev/null +++ b/src/main/java/com/dao/UserDao.java @@ -0,0 +1,22 @@ + +package com.dao; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.baomidou.mybatisplus.mapper.Wrapper; +import com.baomidou.mybatisplus.plugins.pagination.Pagination; +import com.entity.UserEntity; + +/** + * 用户 + */ +public interface UserDao extends BaseMapper { + + List selectListView(@Param("ew") Wrapper wrapper); + + List selectListView(Pagination page,@Param("ew") Wrapper wrapper); + +} diff --git a/src/main/java/com/dao/YonghuDao.java b/src/main/java/com/dao/YonghuDao.java new file mode 100644 index 0000000..4a2125f --- /dev/null +++ b/src/main/java/com/dao/YonghuDao.java @@ -0,0 +1,32 @@ +package com.dao; + +import com.entity.YonghuEntity; +import com.baomidou.mybatisplus.mapper.BaseMapper; +import java.util.List; +import com.baomidou.mybatisplus.mapper.Wrapper; +import com.baomidou.mybatisplus.plugins.pagination.Pagination; + +import org.apache.ibatis.annotations.Param; +import com.entity.vo.YonghuVO; +import com.entity.view.YonghuView; + + +/** + * 用户 + * + * @author + * @email + */ +public interface YonghuDao extends BaseMapper { + + List selectListVO(@Param("ew") Wrapper wrapper); + + YonghuVO selectVO(@Param("ew") Wrapper wrapper); + + List selectListView(@Param("ew") Wrapper wrapper); + + List selectListView(Pagination page,@Param("ew") Wrapper wrapper); + + YonghuView selectView(@Param("ew") Wrapper wrapper); + +} diff --git a/src/main/java/com/entity/ConfigEntity.java b/src/main/java/com/entity/ConfigEntity.java new file mode 100644 index 0000000..57872be --- /dev/null +++ b/src/main/java/com/entity/ConfigEntity.java @@ -0,0 +1,53 @@ +package com.entity; + +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; + +/** +* 类说明 : +*/ +@TableName("config") +public class ConfigEntity implements Serializable{ +private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + private Long id; + + /** + * key + */ + private String name; + + /** + * value + */ + private String value; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/main/java/com/entity/EIException.java b/src/main/java/com/entity/EIException.java new file mode 100644 index 0000000..2ebfb56 --- /dev/null +++ b/src/main/java/com/entity/EIException.java @@ -0,0 +1,52 @@ + +package com.entity; + +/** + * 自定义异常 + */ +public class EIException extends RuntimeException { + private static final long serialVersionUID = 1L; + + private String msg; + private int code = 500; + + public EIException(String msg) { + super(msg); + this.msg = msg; + } + + public EIException(String msg, Throwable e) { + super(msg, e); + this.msg = msg; + } + + public EIException(String msg, int code) { + super(msg); + this.msg = msg; + this.code = code; + } + + public EIException(String msg, int code, Throwable e) { + super(msg, e); + this.msg = msg; + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + +} diff --git a/src/main/java/com/entity/TokenEntity.java b/src/main/java/com/entity/TokenEntity.java new file mode 100644 index 0000000..a0f6489 --- /dev/null +++ b/src/main/java/com/entity/TokenEntity.java @@ -0,0 +1,132 @@ +package com.entity; + +import java.io.Serializable; +import java.util.Date; + +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; + +/** + * token表 + */ +@TableName("token") +public class TokenEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 用户id + */ + private Long userid; + + /** + * 用户名 + */ + private String username; + + /** + * 表名 + */ + private String tablename; + + /** + * 角色 + */ + private String role; + + /** + * token + */ + private String token; + + /** + * 过期时间 + */ + private Date expiratedtime; + + /** + * 新增时间 + */ + private Date addtime; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getUserid() { + return userid; + } + + public void setUserid(Long userid) { + this.userid = userid; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getToken() { + return token; + } + + public String getTablename() { + return tablename; + } + + public void setTablename(String tablename) { + this.tablename = tablename; + } + + public void setToken(String token) { + this.token = token; + } + + public Date getExpiratedtime() { + return expiratedtime; + } + + public void setExpiratedtime(Date expiratedtime) { + this.expiratedtime = expiratedtime; + } + + public Date getAddtime() { + return addtime; + } + + public void setAddtime(Date addtime) { + this.addtime = addtime; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public TokenEntity(Long userid, String username, String tablename,String role, String token, Date expiratedtime) { + super(); + this.userid = userid; + this.username = username; + this.tablename = tablename; + this.role = role; + this.token = token; + this.expiratedtime = expiratedtime; + } + + public TokenEntity() { + } + +} diff --git a/src/main/java/com/entity/UserEntity.java b/src/main/java/com/entity/UserEntity.java new file mode 100644 index 0000000..1b6fb62 --- /dev/null +++ b/src/main/java/com/entity/UserEntity.java @@ -0,0 +1,77 @@ +package com.entity; + +import java.io.Serializable; +import java.util.Date; + +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; + +/** + * 用户 + */ +@TableName("users") +public class UserEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 用户账号 + */ + private String username; + + /** + * 密码 + */ + private String password; + + /** + * 用户类型 + */ + private String role; + + private Date addtime; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public Date getAddtime() { + return addtime; + } + + public void setAddtime(Date addtime) { + this.addtime = addtime; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + +} diff --git a/src/main/java/com/entity/YonghuEntity.java b/src/main/java/com/entity/YonghuEntity.java new file mode 100644 index 0000000..9439395 --- /dev/null +++ b/src/main/java/com/entity/YonghuEntity.java @@ -0,0 +1,217 @@ +package com.entity; + +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableName; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.lang.reflect.InvocationTargetException; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +import org.springframework.format.annotation.DateTimeFormat; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.beanutils.BeanUtils; +import com.baomidou.mybatisplus.annotations.TableField; +import com.baomidou.mybatisplus.enums.FieldFill; +import com.baomidou.mybatisplus.enums.IdType; + + +/** + * 用户 + * 数据库通用操作实体类(普通增删改查) + * @author + * @email + */ +@TableName("yonghu") +public class YonghuEntity implements Serializable { + private static final long serialVersionUID = 1L; + + + public YonghuEntity() { + + } + + public YonghuEntity(T t) { + try { + BeanUtils.copyProperties(this, t); + } catch (IllegalAccessException | InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 主键id + */ + @TableId + private Long id; + /** + * 用户名 + */ + + private String yonghuming; + + /** + * 密码 + */ + + private String mima; + + /** + * 姓名 + */ + + private String xingming; + + /** + * 头像 + */ + + private String touxiang; + + /** + * 性别 + */ + + private String xingbie; + + /** + * 职业 + */ + + private String zhiye; + + /** + * 联系电话 + */ + + private String lianxidianhua; + + /** + * 身份证 + */ + + private String shenfenzheng; + + + @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") + @DateTimeFormat + private Date addtime; + + public Date getAddtime() { + return addtime; + } + public void setAddtime(Date addtime) { + this.addtime = addtime; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + /** + * 设置:用户名 + */ + public void setYonghuming(String yonghuming) { + this.yonghuming = yonghuming; + } + /** + * 获取:用户名 + */ + public String getYonghuming() { + return yonghuming; + } + /** + * 设置:密码 + */ + public void setMima(String mima) { + this.mima = mima; + } + /** + * 获取:密码 + */ + public String getMima() { + return mima; + } + /** + * 设置:姓名 + */ + public void setXingming(String xingming) { + this.xingming = xingming; + } + /** + * 获取:姓名 + */ + public String getXingming() { + return xingming; + } + /** + * 设置:头像 + */ + public void setTouxiang(String touxiang) { + this.touxiang = touxiang; + } + /** + * 获取:头像 + */ + public String getTouxiang() { + return touxiang; + } + /** + * 设置:性别 + */ + public void setXingbie(String xingbie) { + this.xingbie = xingbie; + } + /** + * 获取:性别 + */ + public String getXingbie() { + return xingbie; + } + /** + * 设置:职业 + */ + public void setZhiye(String zhiye) { + this.zhiye = zhiye; + } + /** + * 获取:职业 + */ + public String getZhiye() { + return zhiye; + } + /** + * 设置:联系电话 + */ + public void setLianxidianhua(String lianxidianhua) { + this.lianxidianhua = lianxidianhua; + } + /** + * 获取:联系电话 + */ + public String getLianxidianhua() { + return lianxidianhua; + } + /** + * 设置:身份证 + */ + public void setShenfenzheng(String shenfenzheng) { + this.shenfenzheng = shenfenzheng; + } + /** + * 获取:身份证 + */ + public String getShenfenzheng() { + return shenfenzheng; + } + +} diff --git a/src/main/java/com/entity/model/YonghuModel.java b/src/main/java/com/entity/model/YonghuModel.java new file mode 100644 index 0000000..7a9f8e6 --- /dev/null +++ b/src/main/java/com/entity/model/YonghuModel.java @@ -0,0 +1,179 @@ +package com.entity.model; + +import com.entity.YonghuEntity; + +import com.baomidou.mybatisplus.annotations.TableName; +import java.util.Date; +import org.springframework.format.annotation.DateTimeFormat; + +import com.fasterxml.jackson.annotation.JsonFormat; +import java.io.Serializable; + + +/** + * 用户 + * 接收传参的实体类 + *(实际开发中配合移动端接口开发手动去掉些没用的字段, 后端一般用entity就够用了) + * 取自ModelAndView 的model名称 + * @author + * @email + */ +public class YonghuModel implements Serializable { + private static final long serialVersionUID = 1L; + + + /** + * 密码 + */ + + private String mima; + + /** + * 姓名 + */ + + private String xingming; + + /** + * 头像 + */ + + private String touxiang; + + /** + * 性别 + */ + + private String xingbie; + + /** + * 职业 + */ + + private String zhiye; + + /** + * 联系电话 + */ + + private String lianxidianhua; + + /** + * 身份证 + */ + + private String shenfenzheng; + + + /** + * 设置:密码 + */ + + public void setMima(String mima) { + this.mima = mima; + } + + /** + * 获取:密码 + */ + public String getMima() { + return mima; + } + + + /** + * 设置:姓名 + */ + + public void setXingming(String xingming) { + this.xingming = xingming; + } + + /** + * 获取:姓名 + */ + public String getXingming() { + return xingming; + } + + + /** + * 设置:头像 + */ + + public void setTouxiang(String touxiang) { + this.touxiang = touxiang; + } + + /** + * 获取:头像 + */ + public String getTouxiang() { + return touxiang; + } + + + /** + * 设置:性别 + */ + + public void setXingbie(String xingbie) { + this.xingbie = xingbie; + } + + /** + * 获取:性别 + */ + public String getXingbie() { + return xingbie; + } + + + /** + * 设置:职业 + */ + + public void setZhiye(String zhiye) { + this.zhiye = zhiye; + } + + /** + * 获取:职业 + */ + public String getZhiye() { + return zhiye; + } + + + /** + * 设置:联系电话 + */ + + public void setLianxidianhua(String lianxidianhua) { + this.lianxidianhua = lianxidianhua; + } + + /** + * 获取:联系电话 + */ + public String getLianxidianhua() { + return lianxidianhua; + } + + + /** + * 设置:身份证 + */ + + public void setShenfenzheng(String shenfenzheng) { + this.shenfenzheng = shenfenzheng; + } + + /** + * 获取:身份证 + */ + public String getShenfenzheng() { + return shenfenzheng; + } + +} diff --git a/src/main/java/com/entity/view/YonghuView.java b/src/main/java/com/entity/view/YonghuView.java new file mode 100644 index 0000000..a335703 --- /dev/null +++ b/src/main/java/com/entity/view/YonghuView.java @@ -0,0 +1,35 @@ +package com.entity.view; + +import com.entity.YonghuEntity; + +import com.baomidou.mybatisplus.annotations.TableName; +import org.apache.commons.beanutils.BeanUtils; +import java.lang.reflect.InvocationTargetException; + +import java.io.Serializable; + + +/** + * 用户 + * 后端返回视图实体辅助类 + * (通常后端关联的表或者自定义的字段需要返回使用) + * @author + * @email + */ +@TableName("yonghu") +public class YonghuView extends YonghuEntity implements Serializable { + private static final long serialVersionUID = 1L; + + public YonghuView(){ + } + + public YonghuView(YonghuEntity yonghuEntity){ + try { + BeanUtils.copyProperties(this, yonghuEntity); + } catch (IllegalAccessException | InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } +} diff --git a/src/main/java/com/entity/vo/YonghuVO.java b/src/main/java/com/entity/vo/YonghuVO.java new file mode 100644 index 0000000..2008dab --- /dev/null +++ b/src/main/java/com/entity/vo/YonghuVO.java @@ -0,0 +1,178 @@ +package com.entity.vo; + +import com.entity.YonghuEntity; + +import com.baomidou.mybatisplus.annotations.TableName; +import java.util.Date; +import org.springframework.format.annotation.DateTimeFormat; + +import com.fasterxml.jackson.annotation.JsonFormat; +import java.io.Serializable; + + +/** + * 用户 + * 手机端接口返回实体辅助类 + * (主要作用去除一些不必要的字段) + * @author + * @email + */ +public class YonghuVO implements Serializable { + private static final long serialVersionUID = 1L; + + + /** + * 密码 + */ + + private String mima; + + /** + * 姓名 + */ + + private String xingming; + + /** + * 头像 + */ + + private String touxiang; + + /** + * 性别 + */ + + private String xingbie; + + /** + * 职业 + */ + + private String zhiye; + + /** + * 联系电话 + */ + + private String lianxidianhua; + + /** + * 身份证 + */ + + private String shenfenzheng; + + + /** + * 设置:密码 + */ + + public void setMima(String mima) { + this.mima = mima; + } + + /** + * 获取:密码 + */ + public String getMima() { + return mima; + } + + + /** + * 设置:姓名 + */ + + public void setXingming(String xingming) { + this.xingming = xingming; + } + + /** + * 获取:姓名 + */ + public String getXingming() { + return xingming; + } + + + /** + * 设置:头像 + */ + + public void setTouxiang(String touxiang) { + this.touxiang = touxiang; + } + + /** + * 获取:头像 + */ + public String getTouxiang() { + return touxiang; + } + + + /** + * 设置:性别 + */ + + public void setXingbie(String xingbie) { + this.xingbie = xingbie; + } + + /** + * 获取:性别 + */ + public String getXingbie() { + return xingbie; + } + + + /** + * 设置:职业 + */ + + public void setZhiye(String zhiye) { + this.zhiye = zhiye; + } + + /** + * 获取:职业 + */ + public String getZhiye() { + return zhiye; + } + + + /** + * 设置:联系电话 + */ + + public void setLianxidianhua(String lianxidianhua) { + this.lianxidianhua = lianxidianhua; + } + + /** + * 获取:联系电话 + */ + public String getLianxidianhua() { + return lianxidianhua; + } + + + /** + * 设置:身份证 + */ + + public void setShenfenzheng(String shenfenzheng) { + this.shenfenzheng = shenfenzheng; + } + + /** + * 获取:身份证 + */ + public String getShenfenzheng() { + return shenfenzheng; + } + +} diff --git a/src/main/java/com/service/CommonService.java b/src/main/java/com/service/CommonService.java new file mode 100644 index 0000000..beacdbe --- /dev/null +++ b/src/main/java/com/service/CommonService.java @@ -0,0 +1,20 @@ +package com.service; + +import java.util.List; +import java.util.Map; + +public interface CommonService { + List getOption(Map params); + + Map getFollowByOption(Map params); + + void sh(Map params); + + int remindCount(Map params); + + Map selectCal(Map params); + + List> selectGroup(Map params); + + List> selectValue(Map params); +} diff --git a/src/main/java/com/service/ConfigService.java b/src/main/java/com/service/ConfigService.java new file mode 100644 index 0000000..e883440 --- /dev/null +++ b/src/main/java/com/service/ConfigService.java @@ -0,0 +1,16 @@ + +package com.service; + +import java.util.Map; + +import com.baomidou.mybatisplus.service.IService; +import com.entity.ConfigEntity; +import com.utils.PageUtils; + + +/** + * 系统用户 + */ +public interface ConfigService extends IService { + PageUtils queryPage(Map params); +} diff --git a/src/main/java/com/service/TokenService.java b/src/main/java/com/service/TokenService.java new file mode 100644 index 0000000..74e60f1 --- /dev/null +++ b/src/main/java/com/service/TokenService.java @@ -0,0 +1,26 @@ + +package com.service; + +import java.util.List; +import java.util.Map; + +import com.baomidou.mybatisplus.mapper.Wrapper; +import com.baomidou.mybatisplus.service.IService; +import com.entity.TokenEntity; +import com.utils.PageUtils; + + +/** + * token + */ +public interface TokenService extends IService { + PageUtils queryPage(Map params); + + List selectListView(Wrapper wrapper); + + PageUtils queryPage(Map params,Wrapper wrapper); + + String generateToken(Long userid,String username,String tableName, String role); + + TokenEntity getTokenEntity(String token); +} diff --git a/src/main/java/com/service/UserService.java b/src/main/java/com/service/UserService.java new file mode 100644 index 0000000..37429aa --- /dev/null +++ b/src/main/java/com/service/UserService.java @@ -0,0 +1,25 @@ + +package com.service; + +import java.util.List; +import java.util.Map; + +import org.apache.ibatis.annotations.Param; + +import com.baomidou.mybatisplus.mapper.Wrapper; +import com.baomidou.mybatisplus.service.IService; +import com.entity.UserEntity; +import com.utils.PageUtils; + + +/** + * 系统用户 + */ +public interface UserService extends IService { + PageUtils queryPage(Map params); + + List selectListView(Wrapper wrapper); + + PageUtils queryPage(Map params,Wrapper wrapper); + +} diff --git a/src/main/java/com/service/YonghuService.java b/src/main/java/com/service/YonghuService.java new file mode 100644 index 0000000..844f55a --- /dev/null +++ b/src/main/java/com/service/YonghuService.java @@ -0,0 +1,35 @@ +package com.service; + +import com.baomidou.mybatisplus.mapper.Wrapper; +import com.baomidou.mybatisplus.service.IService; +import com.utils.PageUtils; +import com.entity.YonghuEntity; +import java.util.List; +import java.util.Map; +import com.entity.vo.YonghuVO; +import org.apache.ibatis.annotations.Param; +import com.entity.view.YonghuView; + + +/** + * 用户 + * + * @author + * @email + */ +public interface YonghuService extends IService { + + PageUtils queryPage(Map params); + + List selectListVO(Wrapper wrapper); + + YonghuVO selectVO(@Param("ew") Wrapper wrapper); + + List selectListView(Wrapper wrapper); + + YonghuView selectView(@Param("ew") Wrapper wrapper); + + PageUtils queryPage(Map params,Wrapper wrapper); + +} + diff --git a/src/main/java/com/service/impl/CommonServiceImpl.java b/src/main/java/com/service/impl/CommonServiceImpl.java new file mode 100644 index 0000000..ef4a293 --- /dev/null +++ b/src/main/java/com/service/impl/CommonServiceImpl.java @@ -0,0 +1,59 @@ + +package com.service.impl; + + +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.dao.CommonDao; +import com.service.CommonService; + + +/** + * 系统用户 + */ +@Service("commonService") +public class CommonServiceImpl implements CommonService { + + @Autowired + private CommonDao commonDao; + + @Override + public List getOption(Map params) { + return commonDao.getOption(params); + } + + @Override + public Map getFollowByOption(Map params) { + return commonDao.getFollowByOption(params); + } + + @Override + public void sh(Map params) { + commonDao.sh(params); + } + + @Override + public int remindCount(Map params) { + return commonDao.remindCount(params); + } + + @Override + public Map selectCal(Map params) { + return commonDao.selectCal(params); + } + + @Override + public List> selectGroup(Map params) { + return commonDao.selectGroup(params); + } + + @Override + public List> selectValue(Map params) { + return commonDao.selectValue(params); + } + +} diff --git a/src/main/java/com/service/impl/ConfigServiceImpl.java b/src/main/java/com/service/impl/ConfigServiceImpl.java new file mode 100644 index 0000000..1e1df1e --- /dev/null +++ b/src/main/java/com/service/impl/ConfigServiceImpl.java @@ -0,0 +1,33 @@ + +package com.service.impl; + + +import java.util.Map; + +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.plugins.Page; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.dao.ConfigDao; +import com.entity.ConfigEntity; +import com.entity.UserEntity; +import com.service.ConfigService; +import com.utils.PageUtils; +import com.utils.Query; + + +/** + * 系统用户 + */ +@Service("configService") +public class ConfigServiceImpl extends ServiceImpl implements ConfigService { + @Override + public PageUtils queryPage(Map params) { + Page page = this.selectPage( + new Query(params).getPage(), + new EntityWrapper() + ); + return new PageUtils(page); + } +} diff --git a/src/main/java/com/service/impl/TokenServiceImpl.java b/src/main/java/com/service/impl/TokenServiceImpl.java new file mode 100644 index 0000000..de6c052 --- /dev/null +++ b/src/main/java/com/service/impl/TokenServiceImpl.java @@ -0,0 +1,79 @@ + +package com.service.impl; + + +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.mapper.Wrapper; +import com.baomidou.mybatisplus.plugins.Page; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.dao.TokenDao; +import com.entity.TokenEntity; +import com.entity.TokenEntity; +import com.service.TokenService; +import com.utils.CommonUtil; +import com.utils.PageUtils; +import com.utils.Query; + + +/** + * token + */ +@Service("tokenService") +public class TokenServiceImpl extends ServiceImpl implements TokenService { + + @Override + public PageUtils queryPage(Map params) { + Page page = this.selectPage( + new Query(params).getPage(), + new EntityWrapper() + ); + return new PageUtils(page); + } + + @Override + public List selectListView(Wrapper wrapper) { + return baseMapper.selectListView(wrapper); + } + + @Override + public PageUtils queryPage(Map params, + Wrapper wrapper) { + Page page =new Query(params).getPage(); + page.setRecords(baseMapper.selectListView(page,wrapper)); + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + @Override + public String generateToken(Long userid,String username, String tableName, String role) { + TokenEntity tokenEntity = this.selectOne(new EntityWrapper().eq("userid", userid).eq("role", role)); + String token = CommonUtil.getRandomString(32); + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + cal.add(Calendar.HOUR_OF_DAY, 1); + if(tokenEntity!=null) { + tokenEntity.setToken(token); + tokenEntity.setExpiratedtime(cal.getTime()); + this.updateById(tokenEntity); + } else { + this.insert(new TokenEntity(userid,username, tableName, role, token, cal.getTime())); + } + return token; + } + + @Override + public TokenEntity getTokenEntity(String token) { + TokenEntity tokenEntity = this.selectOne(new EntityWrapper().eq("token", token)); + if(tokenEntity == null || tokenEntity.getExpiratedtime().getTime() implements UserService { + + @Override + public PageUtils queryPage(Map params) { + Page page = this.selectPage( + new Query(params).getPage(), + new EntityWrapper() + ); + return new PageUtils(page); + } + + @Override + public List selectListView(Wrapper wrapper) { + return baseMapper.selectListView(wrapper); + } + + @Override + public PageUtils queryPage(Map params, + Wrapper wrapper) { + Page page =new Query(params).getPage(); + page.setRecords(baseMapper.selectListView(page,wrapper)); + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } +} diff --git a/src/main/java/com/service/impl/YonghuServiceImpl.java b/src/main/java/com/service/impl/YonghuServiceImpl.java new file mode 100644 index 0000000..3213fef --- /dev/null +++ b/src/main/java/com/service/impl/YonghuServiceImpl.java @@ -0,0 +1,62 @@ +package com.service.impl; + +import org.springframework.stereotype.Service; +import java.util.Map; +import java.util.List; + +import com.baomidou.mybatisplus.mapper.Wrapper; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.plugins.Page; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.utils.PageUtils; +import com.utils.Query; + + +import com.dao.YonghuDao; +import com.entity.YonghuEntity; +import com.service.YonghuService; +import com.entity.vo.YonghuVO; +import com.entity.view.YonghuView; + +@Service("yonghuService") +public class YonghuServiceImpl extends ServiceImpl implements YonghuService { + + + @Override + public PageUtils queryPage(Map params) { + Page page = this.selectPage( + new Query(params).getPage(), + new EntityWrapper() + ); + return new PageUtils(page); + } + + @Override + public PageUtils queryPage(Map params, Wrapper wrapper) { + Page page =new Query(params).getPage(); + page.setRecords(baseMapper.selectListView(page,wrapper)); + PageUtils pageUtil = new PageUtils(page); + return pageUtil; + } + + @Override + public List selectListVO(Wrapper wrapper) { + return baseMapper.selectListVO(wrapper); + } + + @Override + public YonghuVO selectVO(Wrapper wrapper) { + return baseMapper.selectVO(wrapper); + } + + @Override + public List selectListView(Wrapper wrapper) { + return baseMapper.selectListView(wrapper); + } + + @Override + public YonghuView selectView(Wrapper wrapper) { + return baseMapper.selectView(wrapper); + } + +} diff --git a/src/main/resources/mapper/CommonDao.xml b/src/main/resources/mapper/CommonDao.xml new file mode 100644 index 0000000..6fa996a --- /dev/null +++ b/src/main/resources/mapper/CommonDao.xml @@ -0,0 +1,57 @@ + + + + + + + + + + UPDATE ${table} set sfsh=#{sfsh} where id=#{id} + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/ConfigDao.xml b/src/main/resources/mapper/ConfigDao.xml new file mode 100644 index 0000000..21e8863 --- /dev/null +++ b/src/main/resources/mapper/ConfigDao.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TokenDao.xml b/src/main/resources/mapper/TokenDao.xml new file mode 100644 index 0000000..7dc0e2e --- /dev/null +++ b/src/main/resources/mapper/TokenDao.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/UserDao.xml b/src/main/resources/mapper/UserDao.xml new file mode 100644 index 0000000..98a7a8c --- /dev/null +++ b/src/main/resources/mapper/UserDao.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/YonghuDao.xml b/src/main/resources/mapper/YonghuDao.xml new file mode 100644 index 0000000..c579b48 --- /dev/null +++ b/src/main/resources/mapper/YonghuDao.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file