Commit 7ce47435 by xiaolang850403

把mybatis框架改成引入mybatis-plus框架

parent c73498fa
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<mybatisplus.version>3.2.0</mybatisplus.version>
</properties> </properties>
<dependencies> <dependencies>
...@@ -34,14 +35,16 @@ ...@@ -34,14 +35,16 @@
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<!--mybatisplus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatisplus.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter --> <!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>
...@@ -59,6 +62,7 @@ ...@@ -59,6 +62,7 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
...@@ -88,7 +92,16 @@ ...@@ -88,7 +92,16 @@
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
<version>3.14-beta1</version> <version>3.14-beta1</version>
</dependency> </dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.8.0</version>
</dependency>
<!-- commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
# 评标专家系统 # 评标专家系统
## 说明: ## 说明:
使用springboot + mybatis 组件组合的系统 使用springboot + mybatis-plus 组件组合的系统
## 环境: ## 环境:
java 1.8以上,mysql5.7以上 java 1.8以上,mysql5.7以上
......
package com.asset.common; package com.asset.common;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -116,4 +118,35 @@ public class Common { ...@@ -116,4 +118,35 @@ public class Common {
reString = reString.replace("%3D", "=").replace("%26", "&"); reString = reString.replace("%3D", "=").replace("%26", "&");
return reString; return reString;
} }
public static String getIpAddress(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
if ("127.0.0.1".equals(ip) || "0:0:0:0:0:0:0:1".equals(ip)) {
//根据网卡取本机配置的IP
InetAddress inet = null;
try {
inet = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
ip = inet.getHostAddress();
}
}
return ip;
}
} }
package com.asset.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
@Configuration
public class MyBatisConfig {
@Bean
public ConfigurationCustomizer configurationCustomizer() {
return new ConfigurationCustomizer() {
@Override
public void customize(org.apache.ibatis.session.Configuration configuration) {
configuration.setMapUnderscoreToCamelCase(true); //驼峰配置写法
}
};
}
}
package com.asset.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
/**
* @Author: 落亦-
* @Date: 2019/11/23 19:16
*/
@Configuration
@ConditionalOnClass(value= {PaginationInterceptor.class})
public class MybatisPlusConfig {
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
...@@ -2,10 +2,14 @@ package com.asset.controller; ...@@ -2,10 +2,14 @@ package com.asset.controller;
import com.asset.common.*; import com.asset.common.*;
import com.asset.domain.User; import com.asset.domain.User;
import com.asset.domain.system.Area;
import com.asset.domain.system.Certificate; import com.asset.domain.system.Certificate;
import com.asset.domain.system.LoginLog;
import com.asset.mapper.UserMapper; import com.asset.mapper.UserMapper;
import com.asset.service.UserService; import com.asset.service.UserService;
import com.asset.service.system.CertificateService; import com.asset.service.system.CertificateService;
import com.asset.service.system.LoginLogService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -14,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -14,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.file.spi.FileSystemProvider; import java.nio.file.spi.FileSystemProvider;
...@@ -21,7 +26,7 @@ import java.nio.file.spi.FileSystemProvider; ...@@ -21,7 +26,7 @@ import java.nio.file.spi.FileSystemProvider;
/* /*
* @author xiaol * @author xiaol
* @date 2020/03/02 * @date 2020/03/10
*/ */
@RestController @RestController
public class UserController { public class UserController {
...@@ -32,18 +37,18 @@ public class UserController { ...@@ -32,18 +37,18 @@ public class UserController {
@Autowired @Autowired
CertificateService certificateService; CertificateService certificateService;
@Autowired
LoginLogService loginLogService;
@RequestMapping("/register") @RequestMapping("/register")
public Result register(@Validated(value={Insert.class}) @RequestBody User user, BindingResult result) throws UnsupportedEncodingException { public Result register(@Validated(value={Insert.class}) @RequestBody User user, BindingResult result) throws UnsupportedEncodingException {
if (result.hasErrors()) { if (result.hasErrors()) {
return ResultUtil.Validated(result); return ResultUtil.Validated(result);
} }
user.setCreate_at(Common.getTime()); user.setCreateAt(Common.getDate());
String pass = MD5Util.getEncryption(user.getPassword()); String pass = MD5Util.getEncryption(user.getPassword());
user.setPassword(pass); user.setPassword(pass);
userService.insertUser(user); userService.save(user);
System.out.println(user);
System.out.println("*****************");
System.out.println(user.getId());
if(user.getId() != null){ if(user.getId() != null){
//组合写入凭证表的数据 //组合写入凭证表的数据
if(user.getExpert() != null){ //专家凭证 if(user.getExpert() != null){ //专家凭证
...@@ -102,7 +107,9 @@ public class UserController { ...@@ -102,7 +107,9 @@ public class UserController {
if(! Common.isPhone(mobile)){ if(! Common.isPhone(mobile)){
return ResultUtil.success(CodeEnum.FORMAT_MOBILE); return ResultUtil.success(CodeEnum.FORMAT_MOBILE);
} }
User admin1 = userService.getUserByMobile(mobile); QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("mobile",mobile);
User admin1 = userService.getOne(queryWrapper);
if(admin1 != null){ if(admin1 != null){
return ResultUtil.success(CodeEnum.ISEXITE_MOBILE); return ResultUtil.success(CodeEnum.ISEXITE_MOBILE);
} }
...@@ -119,13 +126,15 @@ public class UserController { ...@@ -119,13 +126,15 @@ public class UserController {
} }
@RequestMapping("/login") @RequestMapping("/login")
public Result login(@Validated(value={Login.class}) @RequestBody User user, BindingResult result, HttpSession session) throws UnsupportedEncodingException { public Result login(@Validated(value={Login.class}) @RequestBody User user, BindingResult result, HttpSession session, HttpServletRequest request) throws UnsupportedEncodingException {
if (result.hasErrors()) { if (result.hasErrors()) {
return ResultUtil.Validated(result); return ResultUtil.Validated(result);
} }
String mobile= user.getMobile(); String mobile= user.getMobile();
String password= user.getPassword(); String password= user.getPassword();
User admin1 = userService.getUserByMobile(mobile); QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("mobile",mobile);
User admin1 = userService.getOne(queryWrapper);
if(admin1 == null){ //判断账号是否存在 if(admin1 == null){ //判断账号是否存在
return ResultUtil.error(CodeEnum.ISEXITE_NOT_ERROR); return ResultUtil.error(CodeEnum.ISEXITE_NOT_ERROR);
}else { }else {
...@@ -136,12 +145,20 @@ public class UserController { ...@@ -136,12 +145,20 @@ public class UserController {
} }
} }
session.setAttribute("mobile",mobile); session.setAttribute("mobile",mobile);
//登录成功记录登录日志
LoginLog loginLog = new LoginLog();
loginLog.setUser_id(admin1.getId().toString());
loginLog.setIp(Common.getIpAddress(request));
loginLog.setLogin_create_at(Common.getDate());
loginLogService.insertLoginLog(loginLog);
return ResultUtil.success(CodeEnum.SUCCESS); return ResultUtil.success(CodeEnum.SUCCESS);
} }
@GetMapping("/getUserById") @GetMapping("/getUserById")
public Result getUserById(int id) { public Result getUserById(int id) {
User user = userService.getUserById(id); QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id",id);
User user = userService.getOne(queryWrapper);
if(user != null){ if(user != null){
return ResultUtil.success(CodeEnum.SUCCESS,user); return ResultUtil.success(CodeEnum.SUCCESS,user);
} }
...@@ -153,24 +170,24 @@ public class UserController { ...@@ -153,24 +170,24 @@ public class UserController {
if (result.hasErrors()) { if (result.hasErrors()) {
return ResultUtil.Validated(result); return ResultUtil.Validated(result);
} }
userService.updateUser(user); userService.updateById(user);
System.out.println(user); System.out.println(user);
System.out.println("*****************"); System.out.println("*****************");
System.out.println(user.getId()); System.out.println(user.getId());
if(user.getId() != null){ if(user.getId() != null){
//删除凭证的旧数据 //删除凭证的旧数据
certificateService.deleteCertificateByUserId(user.getId()); //certificateService.deleteCertificateByUserId(user.getId());
//组合写入凭证表的数据 //组合写入凭证表的数据
if(user.getExpert() != null){ //专家凭证 if(user.getExpert() != null){ //专家凭证
if(user.getExpert().contains(",")){ if(user.getExpert().contains(",")){
try { try {
certificateService.insertAllCycle(user.getExpert(),user.getId(),1); // certificateService.insertAllCycle(user.getExpert(),user.getId(),1);
}catch (Exception e){ }catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR); return ResultUtil.success(CodeEnum.ERROR);
} }
}else{ }else{
try { try {
certificateService.insertCycle(user.getExpert(),user.getId(),1); // certificateService.insertCycle(user.getExpert(),user.getId(),1);
}catch (Exception e){ }catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR); return ResultUtil.success(CodeEnum.ERROR);
} }
...@@ -179,13 +196,13 @@ public class UserController { ...@@ -179,13 +196,13 @@ public class UserController {
if(user.getRecom() != null){ //推荐凭证 if(user.getRecom() != null){ //推荐凭证
if(user.getRecom().contains(",")){ if(user.getRecom().contains(",")){
try { try {
certificateService.insertAllCycle(user.getRecom(),user.getId(),2); // certificateService.insertAllCycle(user.getRecom(),user.getId(),2);
}catch (Exception e){ }catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR); return ResultUtil.success(CodeEnum.ERROR);
} }
}else{ }else{
try { try {
certificateService.insertCycle(user.getExpert(),user.getId(),2); //certificateService.insertCycle(user.getExpert(),user.getId(),2);
}catch (Exception e){ }catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR); return ResultUtil.success(CodeEnum.ERROR);
} }
...@@ -194,13 +211,13 @@ public class UserController { ...@@ -194,13 +211,13 @@ public class UserController {
if(user.getOther() != null){ //其他凭证 if(user.getOther() != null){ //其他凭证
if(user.getOther().contains(",")){ if(user.getOther().contains(",")){
try { try {
certificateService.insertAllCycle(user.getOther(),user.getId(),0); //certificateService.insertAllCycle(user.getOther(),user.getId(),0);
}catch (Exception e){ }catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR); return ResultUtil.success(CodeEnum.ERROR);
} }
}else{ }else{
try { try {
certificateService.insertCycle(user.getExpert(),user.getId(),0); //certificateService.insertCycle(user.getExpert(),user.getId(),0);
}catch (Exception e){ }catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR); return ResultUtil.success(CodeEnum.ERROR);
} }
......
package com.asset.controller.admin;
import com.asset.common.*;
import com.asset.domain.User;
import com.asset.domain.system.LoginLog;
import com.asset.service.UserService;
import com.asset.service.system.CertificateService;
import com.asset.service.system.LoginLogService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
* @author xiaol
* @date 2020/03/05
*/
@RestController
@RequestMapping(value = "/admin")
public class AdminController {
@Autowired
UserService userService;
@RequestMapping(value = "/getUserList")
public Result getUserList(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int per, @RequestParam(value="state",required=false)String state, @RequestParam(value="id",required=false)String id, @RequestParam(value="name",required=false)String name, @RequestParam(value="mobile",required=false)String mobile, @RequestParam(value="email",required=false)String email, @RequestParam(value="employer",required=false)String employer) {
/*PageHelper.startPage(page, per);
Map param = new HashMap();
param.put("state",state);
param.put("id",id);
param.put("name",name);
param.put("mobile",mobile);
param.put("email",email);
param.put("employer",employer);
List<User> lists = userService.getUserList(param);
Map map = Pagination.Pagination(lists);
return ResultUtil.success(CodeEnum.SUCCESS,map);*/
return ResultUtil.success(CodeEnum.SUCCESS);
}
}
package com.asset.controller.system; package com.asset.controller.admin;
import com.asset.common.CodeEnum; import com.asset.common.CodeEnum;
import com.asset.common.Result; import com.asset.common.Result;
import com.asset.common.ResultUtil; import com.asset.common.ResultUtil;
import com.asset.domain.system.Discipline; import com.asset.domain.system.FailLog;
import com.asset.service.system.DisciplineService; import com.asset.domain.system.FailReason;
import com.asset.service.system.FailLogService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -14,19 +16,21 @@ import java.util.List; ...@@ -14,19 +16,21 @@ import java.util.List;
/* /*
* @author xiaol * @author xiaol
* @date 2020/03/03 * @date 2020/03/06
*/ */
@RestController @RestController
@RequestMapping(value = "/discipline") @RequestMapping(value = "/faillog")
public class DisciplineController { public class FailLogController {
@Autowired @Autowired
DisciplineService disciplineService; FailLogService failLogService;
@GetMapping("/getDisciplineList") @GetMapping("/getFailLogByUid")
public Result getDisciplineList() { public Result getFailLogByUid(int user_id) {
List<Discipline> list = disciplineService.disciplineList(); QueryWrapper<FailLog> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("userid",user_id);
List<FailLog> list = failLogService.list(queryWrapper);
return ResultUtil.success(CodeEnum.SUCCESS,list); return ResultUtil.success(CodeEnum.SUCCESS,list);
} }
} }
package com.asset.controller.admin;
import com.asset.common.CodeEnum;
import com.asset.common.Result;
import com.asset.common.ResultUtil;
import com.asset.domain.system.FailReason;
import com.asset.service.system.FailReasonService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/*
* @author xiaol
* @date 2020/03/06
*/
@RestController
@RequestMapping(value = "/failreason")
public class FailReasonController {
@Autowired
FailReasonService failReasonService;
/**
* 查询所有部门数据
* @param
* @return
*/
@RequestMapping("getFailReason")
public Result getFailReason(){
//进行查询
QueryWrapper<FailReason> queryWrapper = new QueryWrapper<>();
List<FailReason> list = failReasonService.list();
return ResultUtil.success(CodeEnum.SUCCESS,list);
}
}
...@@ -7,12 +7,18 @@ import com.asset.common.ResultUtil; ...@@ -7,12 +7,18 @@ import com.asset.common.ResultUtil;
import com.asset.domain.User; import com.asset.domain.User;
import com.asset.domain.system.Area; import com.asset.domain.system.Area;
import com.asset.service.system.AreaService; import com.asset.service.system.AreaService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
/*
* @author xiaol
* @date 2020/03/10
*/
@RestController @RestController
@RequestMapping(value = "/area") @RequestMapping(value = "/area")
public class AreaController { public class AreaController {
...@@ -21,7 +27,9 @@ public class AreaController { ...@@ -21,7 +27,9 @@ public class AreaController {
@GetMapping("/getAreaList") @GetMapping("/getAreaList")
public Result getAreaList(int pid) { public Result getAreaList(int pid) {
List<Area> list = areaService.getAreaByPid(pid); QueryWrapper<Area> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("pid",pid);
List<Area> list = areaService.list(queryWrapper);
return ResultUtil.success(CodeEnum.SUCCESS,list); return ResultUtil.success(CodeEnum.SUCCESS,list);
} }
} }
...@@ -4,9 +4,7 @@ import com.asset.common.CodeEnum; ...@@ -4,9 +4,7 @@ import com.asset.common.CodeEnum;
import com.asset.common.Result; import com.asset.common.Result;
import com.asset.common.ResultUtil; import com.asset.common.ResultUtil;
import com.asset.domain.system.Job; import com.asset.domain.system.Job;
import com.asset.domain.system.School;
import com.asset.service.system.JobService; import com.asset.service.system.JobService;
import com.asset.service.system.SchoolService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -14,6 +12,11 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -14,6 +12,11 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
/*
* @author xiaol
* @date 2020/03/10
*/
@RestController @RestController
@RequestMapping(value = "/job") @RequestMapping(value = "/job")
public class JobController { public class JobController {
...@@ -23,7 +26,7 @@ public class JobController { ...@@ -23,7 +26,7 @@ public class JobController {
@GetMapping("/getJobList") @GetMapping("/getJobList")
public Result getJobList() { public Result getJobList() {
List<Job> list = jobService.jobList(); List<Job> list = jobService.list();
return ResultUtil.success(CodeEnum.SUCCESS,list); return ResultUtil.success(CodeEnum.SUCCESS,list);
} }
} }
package com.asset.controller.system;
import com.asset.common.CodeEnum;
import com.asset.common.Result;
import com.asset.common.ResultUtil;
import com.asset.domain.system.School;
import com.asset.service.system.SchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping(value = "/school")
public class SchoolController {
@Autowired
SchoolService schoolService;
@GetMapping("/getSchoolList")
public Result getSchoolList() {
List<School> list = schoolService.schoolList();
return ResultUtil.success(CodeEnum.SUCCESS,list);
}
}
package com.asset.controller.system;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.asset.common.CodeEnum;
import com.asset.common.Result;
import com.asset.common.ResultUtil;
import org.apache.catalina.connector.Response;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@RestController
@RequestMapping("/upload")
public class UploadController {
//http://develop.hz.oss-cdns.develop.ecrrc.cn/app/idcard/13548/RfzXEZJpwcmdA5t.jpeg
// 访问的域名
private final String host = "oss-cn-hangzhou.aliyuncs.com";
// 存储空间
private final String bucketName = "ecrrc-develop-local";
/*============================== 阿里云上传 =============================*/
/**
* 阿里云存儲上传
* @param file
* @return
*/
@PostMapping("/oss")
public Result ossUpload(@RequestParam("file") MultipartFile file, String folder){
// 创建OSSClient实例。
OSS ossClient = createOssClient();
// 上传文件流。
// 保存路径,注意:这里不要以 / 或 \ 开头
String Path = folder + "/" + new SimpleDateFormat("yyyy/MM").format(new Date()).toString();
String originalFilename = file.getOriginalFilename();
String fileName = Path + "/" + UUID.randomUUID().toString().replace("-","") + originalFilename.substring(originalFilename.lastIndexOf("."));
try {
ossClient.putObject(bucketName, fileName, file.getInputStream());
} catch (IOException e) {
// e.printStackTrace();
//return Response.error("上传失败:"+e.getMessage());
return ResultUtil.success(CodeEnum.ERROR);
}
// 关闭OSSClient。
ossClient.shutdown();
Map map = new HashMap();
map.put("url","https://" + bucketName + "." + host + "/" +fileName);
//return Response.success("上传成功",map);
return ResultUtil.success(CodeEnum.SUCCESS,map);
}
/**
* 删除阿里云图片(单个文件)
* @param filePath 路径从根目录开始 :"qingcheng/brand/2019/12/c7f2d8fbda5a45d8a6a48e74df0797c7.png
* @return
*/
@GetMapping("/delete")
public Result delete(String filePath){
// 创建OSSClient实例。
OSS ossClient = createOssClient();
// 保存路径,注意:这里不要以 / 或 \ 开头
// 路径从根目录开始 :"qingcheng/brand/2019/12/c7f2d8fbda5a45d8a6a48e74df0797c7.png
// 删除文件。如需删除文件夹,请将ObjectName设置为对应的文件夹名称。如果文件夹非空,则需要将文件夹下的所有object删除后才能删除该文件夹。
ossClient.deleteObject(bucketName, filePath);
// 关闭OSSClient。
ossClient.shutdown();
//return Response.success("删除成功");
return ResultUtil.success(CodeEnum.SUCCESS);
}
/**
* 获取 ossClient
* @return
*/
private OSS createOssClient(){
// Endpoint以杭州为例,其它Region请按实际情况填写。
String endpoint = "http://" + host;
// 云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用RAM子账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建。
String accessKeyId = "LTAIEoqNt1a3BdX2";
String accessKeySecret = "odmtOmumDOoj7qE1f1Ry135mfMbMXz";
// 创建OSSClient实例。
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
return ossClient;
}
/*============================== 本地上传 =============================*/
/**
* 上传本地图片
* @param multipartFile
* @param request
* @return
@PostMapping("/native")
public Response nativeUpload(@RequestParam("file") MultipartFile multipartFile, HttpServletRequest request){
//String path = request.getSession().getServletContext().getRealPath("/img");
String path = "D:\\web\\xampp\\htdocs\\images";
String originalFilename = multipartFile.getOriginalFilename();
String subPath = "/upload/" + new SimpleDateFormat("yyyy/MM").format(new Date()).toString();
String fileName = path + "/" + subPath + "/" + UUID.randomUUID().toString().replace("-","") + originalFilename.substring(originalFilename.lastIndexOf("."));
File file = new File(fileName);
if (!file.getParentFile().exists()){
file.setWritable(true);
file.getParentFile.mkdirs();
}
try {
multipartFile.transferTo(file);
} catch (IOException e) {
// e.printStackTrace();
return Response.error("上传失败:"+e.getMessage());
}
Map map = new HashMap();
map.put("url","http://images.com:8080" + subPath + "/" + file.getName());
return Response.success("上传成功",map);
}
*/
/**
* 删除本地图片
* @param filePath 文件路径
* @return
*/
/*public static boolean delete(String filePath){
File file = new File(filePath);
if (file.isFile()){
return file.delete();
}
return false;
}
*/
}
...@@ -5,21 +5,31 @@ import com.asset.common.Login; ...@@ -5,21 +5,31 @@ import com.asset.common.Login;
import com.asset.common.Special; import com.asset.common.Special;
import com.asset.common.Update; import com.asset.common.Update;
import com.asset.domain.system.Certificate; import com.asset.domain.system.Certificate;
import com.asset.domain.system.LoginLog;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import javax.persistence.Id; import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.List; import java.util.List;
/* /*
* @author xiaol * @author xiaol
* @date 2020/02/28 * @date 2020/03/10
*/ */
@Data @Data
public class User { @EqualsAndHashCode(callSuper = false)
@Id @Accessors(chain = true)
@NotEmpty(message = "{id.NotEmpty}", groups = {Update.class}) @TableName("ex_user")
@ToString
public class User implements Serializable {
private Integer id; private Integer id;
/** /**
* 姓名 * 姓名
...@@ -34,49 +44,71 @@ public class User { ...@@ -34,49 +44,71 @@ public class User {
@Size(min=6,max=20,message="{password.size}",groups = {Insert.class,Special.class,Login.class}) @Size(min=6,max=20,message="{password.size}",groups = {Insert.class,Special.class,Login.class})
private String password; private String password;
@NotEmpty(message = "{sex.NotEmpty}", groups = {Insert.class,Update.class})
private String sex; private String sex;
@NotEmpty(message = "{mobile.NotEmpty}", groups = {Login.class}) @NotEmpty(message = "{mobile.NotEmpty}", groups = {Insert.class,Update.class,Login.class})
@Pattern(regexp = "1[3|4|5|7|8][0-9]\\d{8}",message = "{mobile.Pattern}", groups = {Insert.class,Update.class})
private String mobile; private String mobile;
@NotEmpty(message = "{email.NotEmpty}", groups = {Insert.class,Update.class})
@Email(message="{email.Pattern}",groups = {Insert.class,Update.class})
private String email; private String email;
private Integer state; private Integer state;
@NotEmpty(message = "{province.NotEmpty}", groups = {Insert.class,Update.class})
private String province; private String province;
private Long create_at; private String createAt;
@NotEmpty(message = "{card_front.NotEmpty}", groups = {Insert.class,Update.class}) @NotEmpty(message = "{card_front.NotEmpty}", groups = {Insert.class,Update.class})
private String card_front; private String cardFront;
private String card_obverse; @NotEmpty(message = "{card_obverse.NotEmpty}", groups = {Insert.class,Update.class})
private String cardObverse;
private String school_id; @NotEmpty(message = "{school_id.NotEmpty}", groups = {Insert.class,Update.class})
private String schoolId;
private String discipline_id; private String disciplineId;
private String job_id; @NotEmpty(message = "{job_id.NotEmpty}", groups = {Insert.class,Update.class})
private String jobId;
private String employer; private String employer;
@NotEmpty(message = "{city.NotEmpty}", groups = {Insert.class,Update.class})
private String city; private String city;
@NotEmpty(message = "{county.NotEmpty}", groups = {Insert.class,Update.class})
private String county; private String county;
@NotEmpty(message = "{address.NotEmpty}", groups = {Insert.class,Update.class})
private String address; private String address;
private String is_expert; private String isExpert;
private String expert_type; private String expertType;
private String expert_type_value; private String expertTypeValue;
@TableField(exist = false)
private String expert; //专家凭证 private String expert; //专家凭证
@TableField(exist = false)
private String recom; //推荐凭证 private String recom; //推荐凭证
@TableField(exist = false)
private String other; //其他凭证 private String other; //其他凭证
@TableField(exist = false)
private String expertRange;
@TableField(exist = false)
private List<Certificate> certificate; private List<Certificate> certificate;
@TableField(exist = false)
private List<LoginLog> loginLog;
} }
package com.asset.domain.system; package com.asset.domain.system;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data @Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("ex_area")
@ToString
public class Area { public class Area {
private Integer id; private Integer id;
......
package com.asset.domain.system; package com.asset.domain.system;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
@Data @Data
@TableName("ex_certificate")
public class Certificate { public class Certificate {
private Integer id; private Integer id;
...@@ -13,6 +15,6 @@ public class Certificate { ...@@ -13,6 +15,6 @@ public class Certificate {
private Integer type; private Integer type;
private long create_at; private String create_at;
} }
package com.asset.domain.system;
import com.asset.common.Insert;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@Data
public class Discipline {
//ID
private Integer id;
/**
* 名称
*/
@NotEmpty(message = "名称不能为空!", groups = {Insert.class})
private String name;
}
package com.asset.domain.system;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("ex_fail_log")
@ToString
public class FailLog {
private Integer id;
private String userid;
private String name;
private String fid;
private String state;
private String createAt;
}
package com.asset.domain.system;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("ex_fail_reason")
@ToString
public class FailReason {
private Integer id;
private String name;
}
package com.asset.domain.system; package com.asset.domain.system;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
@Data @Data
@TableName("ex_job")
public class Job { public class Job {
private Integer id; private Integer id;
......
...@@ -3,9 +3,13 @@ package com.asset.domain.system; ...@@ -3,9 +3,13 @@ package com.asset.domain.system;
import lombok.Data; import lombok.Data;
@Data @Data
public class School { public class LoginLog {
private Integer id; private Integer id;
private String name; private String user_id;
private String ip;
private String login_create_at;
} }
package com.asset.mapper; package com.asset.mapper;
import com.asset.domain.User; import com.asset.domain.User;
import java.util.ArrayList; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
import java.util.Map;
public interface UserMapper { public interface UserMapper extends BaseMapper<User> {
public User getUserById(Integer id);
public User getUserByMobile(String mobile);
List<User> getUserList(Map param);
public int insertUser(User user);
public boolean deleteUserById(Integer id);
public boolean updateUser(User user);
} }
package com.asset.mapper.system; package com.asset.mapper.system;
import com.asset.domain.system.Area; import com.asset.domain.system.Area;
import com.github.pagehelper.Page; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
public interface AreaMapper extends BaseMapper<Area> {
public interface AreaMapper {
public List<Area> getAreaByPid(Integer pid);
Page<Area> areaList();
} }
package com.asset.mapper.system; package com.asset.mapper.system;
import com.asset.domain.system.Certificate; import com.asset.domain.system.Certificate;
import com.asset.domain.system.Discipline; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import java.util.List; import java.util.List;
import java.util.Map;
public interface CertificateMapper { public interface CertificateMapper extends BaseMapper<Certificate> {
public Certificate getCertificateById(Integer id); /**
* 插入(批量)
* @param entityList 实体对象列表
* @return boolean
*/
boolean insertAllCertificate(List<Certificate> entityList);
public Certificate getCertificateByUserId(Integer user_id);
Page<Certificate> getCertificateList();
public boolean insertCertificate(Certificate certificate);
public boolean deleteCertificateById(Integer id);
public boolean deleteCertificateByUserId(Integer user_id);
public boolean updateCertificate(Certificate certificate);
public boolean insertAllCertificate(List<Certificate> certificates);
} }
package com.asset.mapper.system;
import com.asset.domain.system.Discipline;
import com.github.pagehelper.Page;
public interface DisciplineMapper {
public Discipline getDisciplineByid(Integer id);
Page<Discipline> disciplineList();
}
package com.asset.mapper.system;
import com.asset.domain.system.FailLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface FailLogMapper extends BaseMapper<FailLog> {
}
package com.asset.mapper.system;
import com.asset.domain.system.FailReason;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface FailReasonMapper extends BaseMapper<FailReason> {
}
...@@ -2,12 +2,9 @@ package com.asset.mapper.system; ...@@ -2,12 +2,9 @@ package com.asset.mapper.system;
import com.asset.domain.system.Job; import com.asset.domain.system.Job;
import com.github.pagehelper.Page; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface JobMapper { public interface JobMapper extends BaseMapper<Job> {
public Job getJobByid(Integer id);
Page<Job> jobList();
} }
package com.asset.mapper.system;
import com.asset.domain.system.LoginLog;
import com.github.pagehelper.Page;
public interface LoginLogMapper {
public LoginLog getLoginLogByUid(Integer user_id);
Page<LoginLog> loginLogList();
public int insertLoginLog(LoginLog loginLog);
}
package com.asset.mapper.system;
import com.asset.domain.system.School;
import com.github.pagehelper.Page;
public interface SchoolMapper {
public School getSchoolByid(Integer id);
Page<School> schoolList();
}
package com.asset.service; package com.asset.service;
import com.asset.common.Common;
import com.asset.domain.*; import com.asset.domain.*;
import com.asset.mapper.UserMapper; import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
/* /*
* @author xiaol * @author xiaol
* @date 2019/12/28 * @date 2020/03/10
*/ */
@Service("UserService")
public class UserService implements UserMapper {
@Autowired
UserMapper userMapper;
@Override
public User getUserById(Integer id) {
return userMapper.getUserById(id);
}
@Override
public User getUserByMobile(String mobile) {
return userMapper.getUserByMobile(mobile);
}
@Override
public List<User> getUserList(Map param) {
List<User> lists = userMapper.getUserList(param);
return lists;
}
@Override
public int insertUser(User user) {
return userMapper.insertUser(user);
}
@Override public interface UserService extends IService<User> {
public boolean deleteUserById(Integer id) {
return userMapper.deleteUserById(id);
}
@Override
public boolean updateUser(User user) {
if(userMapper.updateUser(user)){
return true;
}else{
return false;
}
}
} }
package com.asset.service.impl;
import com.asset.domain.User;
import com.asset.mapper.UserMapper;
import com.asset.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/*
* @author xiaol
* @date 2020/03/10
*/
@Service
@Transactional
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
}
package com.asset.service.impl.system;
import com.asset.domain.system.Area;
import com.asset.mapper.system.AreaMapper;
import com.asset.service.system.AreaService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/*
* @author xiaol
* @date 2020/03/10
*/
@Service
@Transactional
public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements AreaService {
}
package com.asset.service.impl.system;
import com.asset.common.Common;
import com.asset.domain.system.Certificate;
import com.asset.mapper.system.CertificateMapper;
import com.asset.service.system.CertificateService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/*
* @author xiaol
* @date 2020/03/10
*/
@Service
@Transactional
public class CertificateServiceImpl extends ServiceImpl<CertificateMapper, Certificate> implements CertificateService {
@Autowired
CertificateMapper certificateMapper;
@Override
public boolean insertAllCycle(String expert, Integer user_id, Integer type) {
String[] arr = expert.split(",");
List<Certificate> list = new ArrayList<>();
for (int i=0;i<arr.length;i++){
Certificate certificate = new Certificate();
certificate.setUser_id(user_id);
certificate.setImage(arr[i]);
certificate.setType(type);
certificate.setCreate_at(Common.getDate());
list.add(certificate);
}
return certificateMapper.insertAllCertificate(list);
}
public int insertCycle(String expert, Integer user_id,Integer type){
Certificate certificate = new Certificate();
certificate.setUser_id(user_id);
certificate.setImage(expert);
certificate.setType(type);
certificate.setCreate_at(Common.getDate());
return certificateMapper.insert(certificate);
}
}
package com.asset.service.impl.system;
import com.asset.domain.system.FailLog;
import com.asset.mapper.system.FailLogMapper;
import com.asset.service.system.FailLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/*
* @author xiaol
* @date 2020/03/10
*/
@Service
@Transactional
public class FailLogServiceImpl extends ServiceImpl<FailLogMapper, FailLog> implements FailLogService {
}
package com.asset.service.impl.system;
import com.asset.domain.system.FailReason;
import com.asset.mapper.system.FailReasonMapper;
import com.asset.service.system.FailReasonService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/*
* @author xiaol
* @date 2020/03/10
*/
@Service
@Transactional
public class FailReasonServiceImpl extends ServiceImpl<FailReasonMapper, FailReason> implements FailReasonService {
}
package com.asset.service.impl.system;
import com.asset.domain.system.Job;
import com.asset.mapper.system.JobMapper;
import com.asset.service.system.JobService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/*
* @author xiaol
* @date 2020/03/10
*/
@Service
@Transactional
public class JobServiceImpl extends ServiceImpl<JobMapper, Job> implements JobService {
}
package com.asset.service.system; package com.asset.service.system;
import com.asset.domain.system.Area; import com.asset.domain.system.Area;
import com.asset.mapper.system.AreaMapper; import com.baomidou.mybatisplus.extension.service.IService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/* /*
* @author xiaol * @author xiaol
* @date 2020/03/03 * @date 2020/03/03
*/ */
@Service("AreaService") public interface AreaService extends IService<Area> {
public class AreaService implements AreaMapper {
@Autowired
AreaMapper areaMapper;
@Override
public List<Area> getAreaByPid(Integer pid) {
return areaMapper.getAreaByPid(pid);
}
@Override
public Page<Area> areaList() {
return areaMapper.areaList();
}
} }
package com.asset.service.system; package com.asset.service.system;
import com.asset.common.Common;
import com.asset.domain.system.Certificate; import com.asset.domain.system.Certificate;
import com.asset.mapper.system.CertificateMapper; import com.baomidou.mybatisplus.extension.service.IService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/* /*
* @author xiaol * @author xiaol
* @date 2020/03/02 * @date 2020/03/02
*/ */
@Service("CertificateService")
public class CertificateService implements CertificateMapper {
@Autowired
CertificateMapper certificateMapper;
@Override
public Certificate getCertificateById(Integer id) {
return certificateMapper.getCertificateById(id);
}
@Override
public Certificate getCertificateByUserId(Integer user_id) {
return certificateMapper.getCertificateByUserId(user_id);
}
@Override
public Page<Certificate> getCertificateList() {
return certificateMapper.getCertificateList();
}
@Override public interface CertificateService extends IService<Certificate> {
public boolean insertCertificate(Certificate certificate) {
return certificateMapper.insertCertificate(certificate);
}
@Override
public boolean deleteCertificateById(Integer id) {
return certificateMapper.deleteCertificateById(id);
}
@Override
public boolean deleteCertificateByUserId(Integer user_id) {
return certificateMapper.deleteCertificateByUserId(user_id);
}
@Override
public boolean updateCertificate(Certificate certificate) {
return certificateMapper.updateCertificate(certificate);
}
@Override
public boolean insertAllCertificate(List<Certificate> certificates) {
return certificateMapper.insertAllCertificate(certificates);
}
//循环批量写入数据库 //循环批量写入数据库
public boolean insertAllCycle(String expert, Integer user_id,Integer type){ public boolean insertAllCycle(String expert, Integer user_id,Integer type);
String[] arr = expert.split(",");
List<Certificate> list = new ArrayList<Certificate>(); public int insertCycle(String expert, Integer user_id,Integer type);
for (int i=0;i<arr.length;i++){
Certificate certificate = new Certificate();
certificate.setUser_id(user_id);
certificate.setImage(arr[i]);
certificate.setType(type);
certificate.setCreate_at(Common.getTime());
list.add(certificate);
}
return insertAllCertificate(list);
}
public boolean insertCycle(String expert, Integer user_id,Integer type){
Certificate certificate = new Certificate();
certificate.setUser_id(user_id);
certificate.setImage(expert);
certificate.setType(type);
certificate.setCreate_at(Common.getTime());
return insertCertificate(certificate);
}
} }
package com.asset.service.system;
import com.asset.domain.system.Discipline;
import com.asset.domain.system.School;
import com.asset.mapper.system.DisciplineMapper;
import com.asset.mapper.system.SchoolMapper;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/*
* @author xiaol
* @date 2020/03/03
*/
@Service("DisciplineService")
public class DisciplineService implements DisciplineMapper {
@Autowired
DisciplineMapper disciplineMapper;
@Override
public Discipline getDisciplineByid(Integer id) {
return disciplineMapper.getDisciplineByid(id);
}
@Override
public Page<Discipline> disciplineList() {
return disciplineMapper.disciplineList();
}
}
package com.asset.service.system; package com.asset.service.system;
import org.springframework.stereotype.Service; import com.asset.domain.system.FailLog;
import com.baomidou.mybatisplus.extension.service.IService;
/* /*
* @author xiaol * @author xiaol
* @date 2019/12/28 * @date 2020/03/04
*/ */
@Service("CompanyService")
public class CompanyService{ public interface FailLogService extends IService<FailLog> {
} }
package com.asset.service.system;
import com.asset.domain.system.FailReason;
import com.baomidou.mybatisplus.extension.service.IService;
/*
* @author xiaol
* @date 2020/03/04
*/
public interface FailReasonService extends IService<FailReason> {
}
package com.asset.service.system; package com.asset.service.system;
import com.asset.domain.system.Job; import com.asset.domain.system.Job;
import com.asset.domain.system.School; import com.baomidou.mybatisplus.extension.service.IService;
import com.asset.mapper.system.JobMapper;
import com.asset.mapper.system.SchoolMapper;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/* /*
* @author xiaol * @author xiaol
* @date 2020/03/03 * @date 2020/03/03
*/ */
@Service("JobService")
public class JobService implements JobMapper {
@Autowired public interface JobService extends IService<Job> {
JobMapper jobMapper;
@Override
public Job getJobByid(Integer id) {
return jobMapper.getJobByid(id);
}
@Override
public Page<Job> jobList() {
return jobMapper.jobList();
}
} }
package com.asset.service.system;
import com.asset.domain.system.Job;
import com.asset.domain.system.LoginLog;
import com.asset.mapper.system.JobMapper;
import com.asset.mapper.system.LoginLogMapper;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/*
* @author xiaol
* @date 2020/03/04
*/
@Service("LoginLogService")
public class LoginLogService implements LoginLogMapper {
@Autowired
LoginLogMapper loginLogMapper;
@Override
public LoginLog getLoginLogByUid(Integer user_id) {
return loginLogMapper.getLoginLogByUid(user_id);
}
@Override
public Page<LoginLog> loginLogList() {
return loginLogMapper.loginLogList();
}
@Override
public int insertLoginLog(LoginLog loginLog) {
return loginLogMapper.insertLoginLog(loginLog);
}
}
package com.asset.service.system;
import com.asset.domain.system.Area;
import com.asset.domain.system.School;
import com.asset.mapper.system.AreaMapper;
import com.asset.mapper.system.SchoolMapper;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/*
* @author xiaol
* @date 2020/03/03
*/
@Service("SchoolService")
public class SchoolService implements SchoolMapper {
@Autowired
SchoolMapper schoolMapper;
@Override
public School getSchoolByid(Integer id) {
return schoolMapper.getSchoolByid(id);
}
@Override
public Page<School> schoolList() {
return schoolMapper.schoolList();
}
}
#账号相关 #账号相关
username.NotEmpty=账号不能为空 name.NotEmpty=姓名不能为空
password.NotEmpty=密码不能为空 password.NotEmpty=密码不能为空
password.Pattern=密码必须是数字或字母 password.Pattern=密码必须是数字或字母
password.size=密码由6到20位数组或字母组成 password.size=密码由6到20位数组或字母组成
mobile.NotEmpty=手机号不能为空 mobile.NotEmpty=手机号不能为空
mobile.Pattern=手机号格式错误
id.NotEmpty=账号ID不能为空 id.NotEmpty=账号ID不能为空
province.NotEmpty=省份不能为空
city.NotEmpty=城市不能为空
county.NotEmpty=区县不能为空
address.NotEmpty=详细地址不能为空
card_front.NotEmpty=身份证图片不能为空
card_obverse.NotEmpty=身份证图片不能为空
sex.NotEmpty=性别不能为空
email.NotEmpty=邮箱不能为空
email.Pattern=邮箱格式不正确
school_id.NotEmpty=毕业院校不能为空
job_id.NotEmpty=职称不能为空
#角色 #角色
role.NotEmpty=角色名不能为空 role.NotEmpty=角色名不能为空
#菜单 #菜单
......
...@@ -15,6 +15,12 @@ spring: ...@@ -15,6 +15,12 @@ spring:
mybatis: mybatis:
config-location: classpath:mybatis/mybatis-config.xml config-location: classpath:mybatis/mybatis-config.xml
mapper-locations: classpath:mybatis/mapper/*Mapper.xml mapper-locations: classpath:mybatis/mapper/*Mapper.xml
#配置mybatisplus
mybatis-plus:
mapper-locations: classpath:mybatis/mapper/*Mapper.xml
global-config:
db-config:
id-type: auto
pagehelper: pagehelper:
helper-dialect: mysql helper-dialect: mysql
......
...@@ -3,17 +3,5 @@ ...@@ -3,17 +3,5 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.asset.mapper.system.AreaMapper"> <mapper namespace="com.asset.mapper.system.AreaMapper">
<resultMap id="BaseResultMap" type="com.asset.domain.system.Area">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="pid" jdbcType="VARCHAR" property="pid"/>
</resultMap>
<select id="getAreaByPid" parameterType="Map" resultMap="BaseResultMap">
select * from ex_area where pid = #{pid}
</select>
<select id="areaList" parameterType="Map" resultMap="BaseResultMap">
select * from ex_area
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -3,40 +3,6 @@ ...@@ -3,40 +3,6 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.asset.mapper.system.CertificateMapper"> <mapper namespace="com.asset.mapper.system.CertificateMapper">
<resultMap id="BaseResultMap" type="com.asset.domain.system.Certificate">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="user_id" jdbcType="VARCHAR" property="user_id"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="image" jdbcType="VARCHAR" property="image"/>
<result column="create_at" jdbcType="VARCHAR" property="create_at"/>
</resultMap>
<select id="getCertificateById" resultMap="BaseResultMap">
select * from ex_certificate where id=#{id}
</select>
<select id="getCertificateByUserId" resultMap="BaseResultMap">
select * from ex_certificate where user_id = #{user_id}
</select>
<select id="getCertificateList" resultMap="BaseResultMap">
select * from ex_certificate
</select>
<insert id="insertCertificate" parameterType="com.asset.domain.system.Certificate">
insert into ex_certificate(user_id,type,image,create_at) value (#{user_id},#{type},#{image},#{create_at})
</insert>
<delete id="deleteCertificateById" >
delete from ex_certificate where id=#{id}
</delete>
<delete id="deleteCertificateByUserId" >
delete from ex_certificate where user_id = #{user_id}
</delete>
<update id="updateCertificate" parameterType="com.asset.domain.system.Certificate">
update ex_certificate set name=#{name},sex=#{sex},mobile=#{mobile},email=#{email},title=#{title} where id=#{id}
</update>
<insert id="insertAllCertificate" parameterType="com.asset.domain.system.Certificate"> <insert id="insertAllCertificate" parameterType="com.asset.domain.system.Certificate">
insert into ex_certificate(user_id,type,image,create_at) value insert into ex_certificate(user_id,type,image,create_at) value
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.asset.mapper.system.DisciplineMapper">
<resultMap id="BaseResultMap" type="com.asset.domain.system.Discipline">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
</resultMap>
<select id="getDisciplineByid" resultMap="BaseResultMap">
select * from ex_discipline where id = #{id}
</select>
<select id="disciplineList" parameterType="Map" resultMap="BaseResultMap">
select * from ex_discipline
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.asset.mapper.system.FailLogMapper">
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.asset.mapper.system.FailReasonMapper">
</mapper>
\ No newline at end of file
...@@ -3,16 +3,6 @@ ...@@ -3,16 +3,6 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.asset.mapper.system.JobMapper"> <mapper namespace="com.asset.mapper.system.JobMapper">
<resultMap id="BaseResultMap" type="com.asset.domain.system.Job">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
</resultMap>
<select id="getJobByid" resultMap="BaseResultMap">
select * from ex_job where id = #{id}
</select>
<select id="jobList" parameterType="Map" resultMap="BaseResultMap">
select * from ex_job
</select>
</mapper> </mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.asset.mapper.system.LoginLogMapper">
<resultMap id="BaseResultMap" type="com.asset.domain.system.LoginLog">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="user_id" jdbcType="VARCHAR" property="user_id"/>
<result column="ip" jdbcType="VARCHAR" property="ip"/>
<result column="login_create_at" jdbcType="VARCHAR" property="login_create_at"/>
</resultMap>
<select id="getLoginLogByUid" resultMap="BaseResultMap">
select * from ex_login_log where user_id = #{user_id} order by id desc limit 1
</select>
<select id="loginLogList" parameterType="Map" resultMap="BaseResultMap">
select * from ex_login_log
</select>
<insert id="insertLoginLog" parameterType="com.asset.domain.system.LoginLog">
insert into ex_login_log(user_id,ip,login_create_at) value (#{user_id},#{ip},#{login_create_at})
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.asset.mapper.system.SchoolMapper">
<resultMap id="BaseResultMap" type="com.asset.domain.system.School">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
</resultMap>
<select id="getSchoolByid" resultMap="BaseResultMap">
select * from ex_school where id = #{id}
</select>
<select id="schoolList" parameterType="Map" resultMap="BaseResultMap">
select * from ex_school
</select>
</mapper>
\ No newline at end of file
...@@ -3,54 +3,6 @@ ...@@ -3,54 +3,6 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.asset.mapper.UserMapper"> <mapper namespace="com.asset.mapper.UserMapper">
<resultMap id="BaseResultMap" type="com.asset.domain.User">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="password" jdbcType="VARCHAR" property="password"/>
<result column="idcard" jdbcType="VARCHAR" property="idcard"/>
<result column="card_front" jdbcType="VARCHAR" property="card_front"/>
<result column="email" jdbcType="VARCHAR" property="email"/>
<result column="sex" jdbcType="INTEGER" property="sex"/>
<result column="card_obverse" jdbcType="VARCHAR" property="card_obverse"/>
<result column="mobile" jdbcType="VARCHAR" property="mobile"/>
<result column="school_id" jdbcType="VARCHAR" property="school_id"/>
<result column="discipline_id" jdbcType="VARCHAR" property="discipline_id"/>
<result column="job_id" jdbcType="VARCHAR" property="job_id"/>
<result column="employer" jdbcType="VARCHAR" property="employer"/>
<result column="state" jdbcType="VARCHAR" property="state"/>
<result column="create_at" jdbcType="VARCHAR" property="create_at"/>
<!--关联凭证关联表-->
<association property="certificate" column="id" select="com.asset.mapper.system.CertificateMapper.getCertificateByUserId" />
</resultMap>
<select id="getUserById" resultMap="BaseResultMap">
select * from ex_user where id=#{id}
</select>
<select id="getUserByMobile" resultMap="BaseResultMap">
select * from ex_user where mobile = #{mobile}
</select>
<select id="getUserList" resultMap="BaseResultMap">
select * from ex_user
</select>
<insert id="insertUser" useGeneratedKeys="true" keyProperty="id">
insert into ex_user(name,password,province,card_front,email,sex,card_obverse,mobile,school_id,discipline_id,job_id,employer,create_at,city,county,address,is_expert,expert_type,expert_type_value)
value (#{name},#{password},#{province},#{card_front},#{email},#{sex},#{card_obverse},#{mobile},#{school_id},#{discipline_id},#{job_id},#{employer},#{create_at},#{city},#{county},#{address},#{is_expert},#{expert_type},#{expert_type_value})
</insert>
<delete id="deleteUserById" >
delete from ex_user where id=#{id}
</delete>
<update id="updateUser" parameterType="com.asset.domain.User">
update ex_user set name=#{name},sex=#{sex},mobile=#{mobile},email=#{email},province=#{province},card_front=#{card_front},card_obverse=#{card_obverse},school_id=#{school_id},
discipline_id=#{discipline_id},job_id=#{job_id},employer=#{employer},city=#{city},county=#{county},address=#{address},is_expert=#{is_expert},expert_type=#{expert_type},expert_type_value=#{expert_type_value},
where id=#{id}
</update>
<update id="updatePassword" parameterType="com.asset.domain.User">
update ex_user set password=#{password} where id=#{id}
</update>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment