Commit 7ab2c292 by xiaolang850403

代码调整

parent 7ce47435
package com.asset.common;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
import java.util.UUID;
public class Oss {
private static OSSClient ossClient;
private String host = "oss-cn-hangzhou.aliyuncs.com";
// 云账号AccessKey
private String accessKeyId = "LTAIEoqNt1a3BdX2";
private String accessKeySecret = "odmtOmumDOoj7qE1f1Ry135mfMbMXz";
private static String bucketName = "ecrrc-production-member";
public Oss() {
ossClient = new OSSClient(host, accessKeyId, accessKeySecret);
}
/**
* 初始化
*/
public void init() {
ossClient = new OSSClient(host, accessKeyId, accessKeySecret);
}
/**
* 上传图片
* @param file 图片文件流
* @param folder 图片保存文件夹路径
* @return
*/
public String ossUpload(@RequestParam("file") MultipartFile file, String folder){
// 上传文件流。
// 保存路径,注意:这里不要以 / 或 \ 开头
String Path = folder;
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();
}
// 关闭OSSClient。
ossClient.shutdown();
return getUrl(fileName);
}
/**
* 获得url链接
* @param key 图片的短路径和名称:/app/expert/05a83ee3c3e14cdaad8fc51e109695cf.png
* @return
*/
public static String getUrl(String key) {
// 设置URL过期时间为10年 3600l* 1000*24*365*10
Date expiration = new Date(new Date().getTime() + 3600l* 1000*24*365*10);
// 生成URL
URL url = ossClient.generatePresignedUrl(bucketName, key, expiration);
if (url != null) {
return url.toString();
}
return null;
}
}
...@@ -18,10 +18,10 @@ public class Pagination { ...@@ -18,10 +18,10 @@ public class Pagination {
PageInfo pageOb = new PageInfo(list); PageInfo pageOb = new PageInfo(list);
//组合数组 //组合数组
Map<String, Object> map=new HashMap<String, Object>(); Map<String, Object> map=new HashMap<String, Object>();
map.put("total_page", pageOb.getPages()); map.put("totalPage", pageOb.getPages());
map.put("total", pageOb.getTotal()); map.put("total", pageOb.getTotal());
map.put("per_page", pageOb.getPageSize()); map.put("perPage", pageOb.getPageSize());
map.put("current_page", pageOb.getPageNum()); map.put("currentPage", pageOb.getPageNum());
map.put("list", list); map.put("list", list);
return map; return map;
} }
......
package com.asset.common;
/*
* @author xiaol
* @date 2019/12/25
*/
/**
* 公共的返回码
* 返回码code:
* 成功:0
* 失败:10001
*/
public enum ResultCode {
SUCCESS(0,"操作成功!"),
//---系统错误返回码-----
SERVER_ERROR(10001,"服务器错误"),
URL_ERROR(10002,"接口不存在"),
PARAMETER_ERROR(10003,"参数不正确");
//---用户操作返回码 2xxxx----
//---企业操作返回码 3xxxx----
//---权限操作返回码----
//---其他操作返回码----
//操作代码
int code;
//提示信息
String message;
ResultCode(int code, String message){
this.code = code;
this.message = message;
}
public int code() {
return code;
}
public String message() {
return message;
}
}
package com.asset.common; package com.asset.common;
import com.asset.domain.Result;
import com.asset.enums.CodeEnum;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError; import org.springframework.validation.FieldError;
......
package com.asset.controller;
import com.asset.common.*;
import com.asset.domain.Result;
import com.asset.domain.User;
import com.asset.domain.system.Certificate;
import com.asset.domain.system.LoginLog;
import com.asset.enums.CodeEnum;
import com.asset.service.UserService;
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.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
* @author xiaol
* @date 2020/03/17
*/
@RestController
public class LoginController {
@Autowired
UserService userService;
@Autowired
CertificateService certificateService;
@Autowired
LoginLogService loginLogService;
@RequestMapping("/login")
public Result login(@Validated(value={Login.class}) @RequestBody User user, BindingResult result, HttpSession session, HttpServletRequest request) throws UnsupportedEncodingException {
if (result.hasErrors()) {
return ResultUtil.Validated(result);
}
String mobile= user.getMobile();
String password= user.getPassword();
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("mobile",mobile);
User admin1 = userService.getOne(queryWrapper);
if(admin1 == null){ //判断账号是否存在
return ResultUtil.error(CodeEnum.ISEXITE_NOT_ERROR);
}else {
String pass = MD5Util.getEncryption(password);
String passwordold = admin1.getPassword();
if (!passwordold.equals(pass)){
return ResultUtil.error(CodeEnum.LOGIN_ERROR);
}
}
session.setAttribute("mobile",mobile);
//更新登录时间和ip地址
//登录成功记录登录日志
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);
}
@GetMapping("/loginInfo")
public Result loginInfo(HttpSession session) {
String mobile = (String) session.getAttribute("mobile");
if(mobile != null){
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("mobile",mobile);
User user = userService.getOne(queryWrapper);
if(user == null){ //判断账号是否存在
return ResultUtil.error(CodeEnum.ISEXITE_NOT_ERROR);
}else {
return ResultUtil.success(CodeEnum.SUCCESS,user);
}
}
return ResultUtil.error(CodeEnum.UN_LOGIN);
}
@GetMapping("/loginOut")
public Result loginOut(HttpSession session) {
session.invalidate();
return ResultUtil.success(CodeEnum.SUCCESS);
}
}
package com.asset.controller; package com.asset.controller;
import com.aliyun.oss.OSS;
import com.asset.common.*; import com.asset.common.*;
import com.asset.domain.Result;
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.domain.system.LoginLog;
import com.asset.mapper.UserMapper; import com.asset.enums.CodeEnum;
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.asset.service.system.LoginLogService;
...@@ -13,15 +14,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -13,15 +14,15 @@ 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;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.file.spi.FileSystemProvider; import java.net.URL;
import java.util.*;
/* /*
...@@ -29,6 +30,7 @@ import java.nio.file.spi.FileSystemProvider; ...@@ -29,6 +30,7 @@ import java.nio.file.spi.FileSystemProvider;
* @date 2020/03/10 * @date 2020/03/10
*/ */
@RestController @RestController
@RequestMapping(value = "/user")
public class UserController { public class UserController {
@Autowired @Autowired
...@@ -124,7 +126,7 @@ public class UserController { ...@@ -124,7 +126,7 @@ public class UserController {
return ResultUtil.success(CodeEnum.SUCCESS); return ResultUtil.success(CodeEnum.SUCCESS);
} }
/*
@RequestMapping("/login") @RequestMapping("/login")
public Result login(@Validated(value={Login.class}) @RequestBody User user, BindingResult result, HttpSession session, HttpServletRequest request) 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()) {
...@@ -145,6 +147,7 @@ public class UserController { ...@@ -145,6 +147,7 @@ public class UserController {
} }
} }
session.setAttribute("mobile",mobile); session.setAttribute("mobile",mobile);
//更新登录时间和ip地址
//登录成功记录登录日志 //登录成功记录登录日志
LoginLog loginLog = new LoginLog(); LoginLog loginLog = new LoginLog();
loginLog.setUser_id(admin1.getId().toString()); loginLog.setUser_id(admin1.getId().toString());
...@@ -154,11 +157,32 @@ public class UserController { ...@@ -154,11 +157,32 @@ public class UserController {
return ResultUtil.success(CodeEnum.SUCCESS); return ResultUtil.success(CodeEnum.SUCCESS);
} }
*/
@GetMapping("/getUserById") @GetMapping("/getUserById")
public Result getUserById(int id) { public Result getUserById(int id) {
QueryWrapper<User> queryWrapper = new QueryWrapper<>(); QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id",id); queryWrapper.eq("id",id);
User user = userService.getOne(queryWrapper); User user = userService.getOne(queryWrapper);
//组合专家凭证
QueryWrapper<Certificate> certificateWrapper = new QueryWrapper<>();
certificateWrapper.eq("user_id",user.getId());
List<Certificate> list = certificateService.list(certificateWrapper);
List listexpert = new ArrayList<>();
List listrecom = new ArrayList<>();
List listother = new ArrayList<>();
for (Certificate list1 : list) {
if(list1.getType() == 1){
listexpert.add(list1.getImage());
}else if(list1.getType() == 2){
listrecom.add(list1.getImage());
}else{
listother.add(list1.getImage());
}
}
user.setReexpert(listexpert);
user.setRerecom(listrecom);
user.setReother(listother);
if(user != null){ if(user != null){
return ResultUtil.success(CodeEnum.SUCCESS,user); return ResultUtil.success(CodeEnum.SUCCESS,user);
} }
...@@ -166,28 +190,29 @@ public class UserController { ...@@ -166,28 +190,29 @@ public class UserController {
} }
@RequestMapping("/getUpdateUser") @RequestMapping("/getUpdateUser")
public Result getUpdateUser(@Validated(value={Update.class}) @RequestBody User user, BindingResult result) { public Result getUpdateUser(@Validated(value={Update.class}) @RequestBody User user, BindingResult result) throws UnsupportedEncodingException {
if (result.hasErrors()) { if (result.hasErrors()) {
return ResultUtil.Validated(result); return ResultUtil.Validated(result);
} }
String pass = MD5Util.getEncryption(user.getPassword());
user.setPassword(pass);
userService.updateById(user); userService.updateById(user);
System.out.println(user);
System.out.println("*****************");
System.out.println(user.getId());
if(user.getId() != null){ if(user.getId() != null){
//删除凭证的旧数据 //删除凭证的旧数据
//certificateService.deleteCertificateByUserId(user.getId()); QueryWrapper<Certificate> certificateWrapper = new QueryWrapper<>();
certificateWrapper.eq("user_id",user.getId());
certificateService.remove(certificateWrapper);
//组合写入凭证表的数据 //组合写入凭证表的数据
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);
} }
...@@ -196,13 +221,13 @@ public class UserController { ...@@ -196,13 +221,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);
} }
...@@ -211,13 +236,13 @@ public class UserController { ...@@ -211,13 +236,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);
} }
...@@ -229,4 +254,13 @@ public class UserController { ...@@ -229,4 +254,13 @@ public class UserController {
} }
} }
@PostMapping("/uploaduIdCard")
public Result uploaduIdCard(@RequestParam("file") MultipartFile file){
String folder = "app/expert";
Oss oss = new Oss();
String url = oss.ossUpload(file,folder);
Map map = new HashMap();
map.put("url",url);
return ResultUtil.success(CodeEnum.SUCCESS,map);
}
} }
package com.asset.controller.admin; package com.asset.controller.admin;
import com.asset.common.*; import com.asset.common.*;
import com.asset.domain.Result;
import com.asset.domain.User; import com.asset.domain.User;
import com.asset.domain.system.LoginLog; import com.asset.domain.system.*;
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.*;
import com.asset.service.system.LoginLogService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired; 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 org.springframework.web.bind.annotation.*;
import com.asset.enums.CodeEnum;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import java.util.ArrayList;
import java.io.UnsupportedEncodingException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -22,7 +22,7 @@ import java.util.Map; ...@@ -22,7 +22,7 @@ import java.util.Map;
/* /*
* @author xiaol * @author xiaol
* @date 2020/03/05 * @date 2020/03/12
*/ */
@RestController @RestController
@RequestMapping(value = "/admin") @RequestMapping(value = "/admin")
...@@ -31,20 +31,162 @@ public class AdminController { ...@@ -31,20 +31,162 @@ public class AdminController {
@Autowired @Autowired
UserService userService; UserService userService;
@Autowired
CertificateService certificateService;
@Autowired
AreaService areaService;
@Autowired
JobService jobService;
@Autowired
FailLogService failLogService;
@Autowired
FailReasonService failReasonService;
@Autowired
//UserMapper userMapper;
public final static Map<String, String> Expertmap = new HashMap<String, String>();
static {
Expertmap.put("1", "省专家库");
Expertmap.put("2", "市专家库");
}
public final String agree = "审核通过";
public final String refuse = "审核不通过,原因:";
@RequestMapping(value = "/getUserList") @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) { public Result getUserList(@RequestParam(defaultValue = "1") int currentPage, @RequestParam(defaultValue = "10") int per, User user) {
/*PageHelper.startPage(page, per); QueryWrapper<User> queryWrapper = new QueryWrapper<>();
Map param = new HashMap(); if(user.getState() != null){
param.put("state",state); queryWrapper.eq("state",user.getState()).or().eq("name",user.getName()).or().eq("mobile",user.getMobile()).or().eq("email",user.getEmail()).or().eq("employer",user.getEmployer());
param.put("id",id); }
param.put("name",name); //List list = userService.list(queryWrapper);
param.put("mobile",mobile); PageHelper.startPage(currentPage, per);
param.put("email",email); Map map = Pagination.Pagination(userService.list(queryWrapper));
param.put("employer",employer); return ResultUtil.success(CodeEnum.SUCCESS,map);
List<User> lists = userService.getUserList(param); }
Map map = Pagination.Pagination(lists);
return ResultUtil.success(CodeEnum.SUCCESS,map);*/ @GetMapping("/getUserById")
public Result getUserById(int id) {
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id",id);
User user = userService.getOne(queryWrapper);
//组合专家凭证
QueryWrapper<Certificate> certificateWrapper = new QueryWrapper<>();
certificateWrapper.eq("user_id",user.getId());
java.util.List<Certificate> list = certificateService.list(certificateWrapper);
java.util.List listexpert = new ArrayList<>();
java.util.List listrecom = new ArrayList<>();
List listother = new ArrayList<>();
for (Certificate list1 : list) {
if(list1.getType() == 1){
listexpert.add(list1.getImage());
}else if(list1.getType() == 2){
listrecom.add(list1.getImage());
}else{
listother.add(list1.getImage());
}
}
user.setReexpert(listexpert);
user.setRerecom(listrecom);
user.setReother(listother);
user.setExpertType(Expertmap.get(user.getExpertType()));
//组合地址
Area p = areaService.getById(user.getProvince());
user.setProvince(p.getName());
Area c = areaService.getById(user.getCity());
user.setCity(c.getName());
Area co = areaService.getById(user.getCounty());
user.setCounty(co.getName());
//专家类型(省级还是市级)
if(user.getExpertTypeValue().contains(",")){
String[] arr = user.getExpertTypeValue().split(",");
String tmp = "";
for (int i=0;i<arr.length;i++){
Area pt = areaService.getById(arr[i]);
tmp += pt.getName();
}
user.setExpertTypeValue(tmp);
}else{
Area pt = areaService.getById(user.getExpertTypeValue());
user.setExpertTypeValue(pt.getName());
}
//职称
Job job = jobService.getById(user.getJobId());
user.setJobId(job.getName());
//审核历史
QueryWrapper<FailLog> queryWrapperFail = new QueryWrapper<>();
queryWrapperFail.eq("user_id",user.getId());
List<FailLog> fail = failLogService.list(queryWrapperFail);
user.setFaillog(fail);
if(user != null){
return ResultUtil.success(CodeEnum.SUCCESS,user);
}
return ResultUtil.success(CodeEnum.ERROR);
}
@RequestMapping(value = "/getUserReviewAgree")
public Result getUserReviewAgree(int id) {
User user = new User();
QueryWrapper<User> updateWrapper = new QueryWrapper<>();
updateWrapper.eq("id",id);
user.setState(1);
if(userService.update(user,updateWrapper)){
//记录审核日志
FailLog failLog = new FailLog();
failLog.setUserId(Integer.toString(id));
failLog.setState(Integer.toString(0));
failLog.setName(agree);
failLog.setCreateAt(Common.getDate());
failLogService.save(failLog);
return ResultUtil.success(CodeEnum.SUCCESS); return ResultUtil.success(CodeEnum.SUCCESS);
}else{
return ResultUtil.success(CodeEnum.ERROR);
}
}
@RequestMapping(value = "/getUserReviewRefuse")
public Result getUserReviewRefuse(@RequestBody User user) {
QueryWrapper<User> updateWrapper = new QueryWrapper<>();
updateWrapper.eq("id",user.getId());
user.setState(2);
if(userService.update(user,updateWrapper)){
//记录审核日志
FailLog failLog = new FailLog();
failLog.setUserId(user.getId().toString());
failLog.setState(Integer.toString(1));
//拼接失败的原因
String tmp = "";
String ref = "";
String fids = user.getFids();
String reasons = user.getReason();
if(fids.contains(",")){
String[] arr = fids.split(",");
for (int i=0;i<arr.length;i++){
FailReason reason = failReasonService.getById(arr[i]);
tmp += reason.getId() +":"+ reason.getName() + ",";
}
}else{
FailReason reason = failReasonService.getById(fids);
tmp = reason.getId() +":"+ reason.getName();
}
if(reasons != null && reasons.length()>0){
ref = refuse + tmp + reasons;
}else{
ref = refuse + tmp;
}
failLog.setFid(fids);
failLog.setName(ref);
failLog.setCreateAt(Common.getDate());
failLogService.save(failLog);
return ResultUtil.success(CodeEnum.SUCCESS);
}else{
return ResultUtil.success(CodeEnum.ERROR);
}
} }
} }
package com.asset.controller.admin; package com.asset.controller.admin;
import com.asset.common.CodeEnum;
import com.asset.common.Result;
import com.asset.common.ResultUtil; import com.asset.common.ResultUtil;
import com.asset.domain.Result;
import com.asset.domain.system.FailLog; import com.asset.domain.system.FailLog;
import com.asset.domain.system.FailReason; import com.asset.enums.CodeEnum;
import com.asset.service.system.FailLogService; import com.asset.service.system.FailLogService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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;
......
package com.asset.controller.admin; package com.asset.controller.admin;
import com.asset.common.CodeEnum;
import com.asset.common.Result;
import com.asset.common.ResultUtil; import com.asset.common.ResultUtil;
import com.asset.domain.Result;
import com.asset.domain.system.FailReason; import com.asset.domain.system.FailReason;
import com.asset.enums.CodeEnum;
import com.asset.service.system.FailReasonService; import com.asset.service.system.FailReasonService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
package com.asset.controller.system; package com.asset.controller.system;
import com.asset.common.CodeEnum;
import com.asset.common.Common;
import com.asset.common.Result;
import com.asset.common.ResultUtil; import com.asset.common.ResultUtil;
import com.asset.domain.User; import com.asset.domain.Result;
import com.asset.domain.system.Area; import com.asset.domain.system.Area;
import com.asset.enums.CodeEnum;
import com.asset.service.system.AreaService; import com.asset.service.system.AreaService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
package com.asset.controller.system; package com.asset.controller.system;
import com.asset.common.CodeEnum;
import com.asset.common.Result;
import com.asset.common.ResultUtil; import com.asset.common.ResultUtil;
import com.asset.domain.Result;
import com.asset.domain.system.Job; import com.asset.domain.system.Job;
import com.asset.enums.CodeEnum;
import com.asset.service.system.JobService; import com.asset.service.system.JobService;
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;
......
...@@ -2,20 +2,17 @@ package com.asset.controller.system; ...@@ -2,20 +2,17 @@ package com.asset.controller.system;
import com.aliyun.oss.OSS; import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder; import com.aliyun.oss.OSSClientBuilder;
import com.asset.common.CodeEnum;
import com.asset.common.Result;
import com.asset.common.ResultUtil; import com.asset.common.ResultUtil;
import org.apache.catalina.connector.Response; import com.asset.domain.Result;
import com.asset.enums.CodeEnum;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -30,7 +27,7 @@ public class UploadController { ...@@ -30,7 +27,7 @@ public class UploadController {
// 访问的域名 // 访问的域名
private final String host = "oss-cn-hangzhou.aliyuncs.com"; private final String host = "oss-cn-hangzhou.aliyuncs.com";
// 存储空间 // 存储空间
private final String bucketName = "ecrrc-develop-local"; private final String bucketName = "ecrrc-production-member";
/*============================== 阿里云上传 =============================*/ /*============================== 阿里云上传 =============================*/
/** /**
...@@ -44,7 +41,7 @@ public class UploadController { ...@@ -44,7 +41,7 @@ public class UploadController {
OSS ossClient = createOssClient(); OSS ossClient = createOssClient();
// 上传文件流。 // 上传文件流。
// 保存路径,注意:这里不要以 / 或 \ 开头 // 保存路径,注意:这里不要以 / 或 \ 开头
String Path = folder + "/" + new SimpleDateFormat("yyyy/MM").format(new Date()).toString(); String Path = folder;
String originalFilename = file.getOriginalFilename(); String originalFilename = file.getOriginalFilename();
String fileName = Path + "/" + UUID.randomUUID().toString().replace("-","") + originalFilename.substring(originalFilename.lastIndexOf(".")); String fileName = Path + "/" + UUID.randomUUID().toString().replace("-","") + originalFilename.substring(originalFilename.lastIndexOf("."));
try { try {
...@@ -57,7 +54,9 @@ public class UploadController { ...@@ -57,7 +54,9 @@ public class UploadController {
// 关闭OSSClient。 // 关闭OSSClient。
ossClient.shutdown(); ossClient.shutdown();
Map map = new HashMap(); Map map = new HashMap();
map.put("url","https://" + bucketName + "." + host + "/" +fileName); Date expiration = new Date(new Date().getTime() + 3600l * 1000 * 24 * 365 * 10);
URL url = ossClient.generatePresignedUrl(bucketName, fileName, expiration);
map.put("url",url);
//return Response.success("上传成功",map); //return Response.success("上传成功",map);
return ResultUtil.success(CodeEnum.SUCCESS,map); return ResultUtil.success(CodeEnum.SUCCESS,map);
} }
......
package com.asset.common; package com.asset.domain;
/* /*
* @author xiaol * @author xiaol
...@@ -11,7 +11,7 @@ package com.asset.common; ...@@ -11,7 +11,7 @@ package com.asset.common;
* 成功:0 * 成功:0
* 失败:10001 * 失败:10001
*/ */
public class Result<T> { public class Result<Object> {
/** 错误码. */ /** 错误码. */
private Integer code; private Integer code;
...@@ -20,13 +20,13 @@ public class Result<T> { ...@@ -20,13 +20,13 @@ public class Result<T> {
private String msg; private String msg;
/** 具体的内容. */ /** 具体的内容. */
private T data; private Object data;
public Result() { public Result() {
super(); super();
} }
public Result(Integer code, String msg, T data) { public Result(Integer code, String msg, Object data) {
this.code = code; this.code = code;
this.msg = msg; this.msg = msg;
this.data = data; this.data = data;
...@@ -48,11 +48,11 @@ public class Result<T> { ...@@ -48,11 +48,11 @@ public class Result<T> {
this.msg = msg; this.msg = msg;
} }
public T getData() { public Object getData() {
return data; return data;
} }
public void setData(T data) { public void setData(Object data) {
this.data = data; this.data = data;
} }
......
package com.asset.domain; package com.asset.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.asset.common.Insert; import com.asset.common.Insert;
import com.asset.common.Login; import com.asset.common.Login;
import com.asset.common.Special; import com.asset.common.Special;
...@@ -8,6 +9,7 @@ import com.asset.domain.system.Certificate; ...@@ -8,6 +9,7 @@ import com.asset.domain.system.Certificate;
import com.asset.domain.system.LoginLog; import com.asset.domain.system.LoginLog;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
...@@ -17,6 +19,7 @@ import javax.validation.constraints.NotEmpty; ...@@ -17,6 +19,7 @@ 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.io.Serializable;
import java.util.Date;
import java.util.List; import java.util.List;
/* /*
...@@ -68,10 +71,10 @@ public class User implements Serializable { ...@@ -68,10 +71,10 @@ public class User implements Serializable {
@NotEmpty(message = "{card_obverse.NotEmpty}", groups = {Insert.class,Update.class}) @NotEmpty(message = "{card_obverse.NotEmpty}", groups = {Insert.class,Update.class})
private String cardObverse; private String cardObverse;
@NotEmpty(message = "{school_id.NotEmpty}", groups = {Insert.class,Update.class}) @NotEmpty(message = "{school.NotEmpty}", groups = {Insert.class,Update.class})
private String schoolId; private String school;
private String disciplineId; private String discipline;
@NotEmpty(message = "{job_id.NotEmpty}", groups = {Insert.class,Update.class}) @NotEmpty(message = "{job_id.NotEmpty}", groups = {Insert.class,Update.class})
private String jobId; private String jobId;
...@@ -103,12 +106,31 @@ public class User implements Serializable { ...@@ -103,12 +106,31 @@ public class User implements Serializable {
private String other; //其他凭证 private String other; //其他凭证
@TableField(exist = false) @TableField(exist = false)
private List reexpert; //专家凭证
@TableField(exist = false)
private List rerecom; //推荐凭证
@TableField(exist = false)
private List reother; //其他凭证
private String expertRange; private String expertRange;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date loginTime;
//@JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8")
//private Date yy;
private String ip;
@TableField(exist = false)
private List faillog;
@TableField(exist = false) @TableField(exist = false)
private List<Certificate> certificate; private String fids;
@TableField(exist = false) @TableField(exist = false)
private List<LoginLog> loginLog; private String reason;
} }
...@@ -15,7 +15,7 @@ public class FailLog { ...@@ -15,7 +15,7 @@ public class FailLog {
private Integer id; private Integer id;
private String userid; private String userId;
private String name; private String name;
......
package com.asset.common; package com.asset.enums;
public enum CodeEnum { public enum CodeEnum {
...@@ -23,16 +23,6 @@ public enum CodeEnum { ...@@ -23,16 +23,6 @@ public enum CodeEnum {
//---资产管理操作返回码 3xxxx----
//---资产盘点操作返回码 4xxxx----
//---资产报表操作返回码 5xxxx----
private int key; private int key;
private String value; private String value;
......
package com.asset.enums;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;
@Getter
public enum ExpertTypeEnum {
PROVINCE(1,"省专家库"),
CITY(2,"市专家库");
ExpertTypeEnum(int code, String descp) {
this.code = code;
this.descp = descp;
}
@EnumValue
private final int code;
private final String descp;
}
package com.asset.common; package com.asset.enums;
public enum StatusEnum { public enum StatusEnum {
ON(0,"正常"), ON(0,"正常"),
......
package com.asset.utils; package com.asset.utils;
import com.asset.common.CodeEnum;
import com.asset.common.Result;
import com.asset.common.ResultUtil; import com.asset.common.ResultUtil;
import com.asset.domain.Result;
import com.asset.enums.CodeEnum;
import org.springframework.boot.web.server.ConfigurableWebServerFactory; import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage; import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactory; import org.springframework.boot.web.server.WebServerFactory;
......
...@@ -15,7 +15,7 @@ card_obverse.NotEmpty=身份证图片不能为空 ...@@ -15,7 +15,7 @@ card_obverse.NotEmpty=身份证图片不能为空
sex.NotEmpty=性别不能为空 sex.NotEmpty=性别不能为空
email.NotEmpty=邮箱不能为空 email.NotEmpty=邮箱不能为空
email.Pattern=邮箱格式不正确 email.Pattern=邮箱格式不正确
school_id.NotEmpty=毕业院校不能为空 school.NotEmpty=毕业院校不能为空
job_id.NotEmpty=职称不能为空 job_id.NotEmpty=职称不能为空
#角色 #角色
......
...@@ -12,9 +12,6 @@ spring: ...@@ -12,9 +12,6 @@ spring:
url: jdbc:mysql://152.136.188.17:2303/expert?useUnicode=true&characterEncoding=utf8 url: jdbc:mysql://152.136.188.17:2303/expert?useUnicode=true&characterEncoding=utf8
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
mybatis:
config-location: classpath:mybatis/mybatis-config.xml
mapper-locations: classpath:mybatis/mapper/*Mapper.xml
#配置mybatisplus #配置mybatisplus
mybatis-plus: mybatis-plus:
mapper-locations: classpath:mybatis/mapper/*Mapper.xml mapper-locations: classpath:mybatis/mapper/*Mapper.xml
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
<!-- 打印查询语句 -->
<setting name="logImpl" value="STDOUT_LOGGING" />
</settings>
</configuration>
\ 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