Commit 4e502e97 authored by hanfeng's avatar hanfeng

Merge branch 'base-modify' of http://10.5.52.3/youjj/cloud-platform into base-modify

parents 5dd88b38 8aa53338
...@@ -56,6 +56,15 @@ public class AuthController { ...@@ -56,6 +56,15 @@ public class AuthController {
return new ObjectRestResponse<String>().data(token); return new ObjectRestResponse<String>().data(token);
} }
@RequestMapping(value = "token/small", method = RequestMethod.POST)
public ObjectRestResponse<String> createAuthenticationTokenSmall(
@RequestBody JwtAuthenticationRequest authenticationRequest,
HttpServletRequest request) throws Exception {
log.info(authenticationRequest.getUsername()+" require logging...");
// keliii 分请求类型处理token
return authService.loginSmall(authenticationRequest);
}
@RequestMapping(value = "refresh", method = RequestMethod.GET) @RequestMapping(value = "refresh", method = RequestMethod.GET)
public ObjectRestResponse<String> refreshAndGetAuthenticationToken( public ObjectRestResponse<String> refreshAndGetAuthenticationToken(
HttpServletRequest request) throws Exception { HttpServletRequest request) throws Exception {
......
...@@ -20,6 +20,9 @@ public interface IUserService { ...@@ -20,6 +20,9 @@ public interface IUserService {
@RequestMapping(value = "/api/user/validate", method = RequestMethod.POST) @RequestMapping(value = "/api/user/validate", method = RequestMethod.POST)
public UserInfo validate(@RequestBody JwtAuthenticationRequest authenticationRequest); public UserInfo validate(@RequestBody JwtAuthenticationRequest authenticationRequest);
@RequestMapping(value = "/api/user/validate/small", method = RequestMethod.POST)
public UserInfo validateSmall(@RequestBody JwtAuthenticationRequest authenticationRequest);
@RequestMapping(value = "/api/app/user/validate", method = RequestMethod.POST) @RequestMapping(value = "/api/app/user/validate", method = RequestMethod.POST)
AppUserInfo AppValidate(@RequestBody JwtAuthenticationRequest authenticationRequest); AppUserInfo AppValidate(@RequestBody JwtAuthenticationRequest authenticationRequest);
......
...@@ -3,10 +3,12 @@ package com.github.wxiaoqi.security.auth.service; ...@@ -3,10 +3,12 @@ package com.github.wxiaoqi.security.auth.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest; import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
public interface AuthService { public interface AuthService {
String login(JwtAuthenticationRequest authenticationRequest) throws Exception; String login(JwtAuthenticationRequest authenticationRequest) throws Exception;
ObjectRestResponse loginSmall(JwtAuthenticationRequest authenticationRequest) throws Exception;
String refresh(String oldToken) throws Exception; String refresh(String oldToken) throws Exception;
void validate(String token) throws Exception; void validate(String token) throws Exception;
JSONObject sendsms(String username, Integer type) throws Exception; JSONObject sendsms(String username, Integer type) throws Exception;
......
...@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.auth.service.impl; ...@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.auth.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.api.vo.user.AppUserInfo; import com.github.wxiaoqi.security.api.vo.user.AppUserInfo;
import com.github.wxiaoqi.security.api.vo.user.UserInfo;
import com.github.wxiaoqi.security.auth.common.util.jwt.JWTInfo; import com.github.wxiaoqi.security.auth.common.util.jwt.JWTInfo;
import com.github.wxiaoqi.security.auth.feign.IUserService; import com.github.wxiaoqi.security.auth.feign.IUserService;
import com.github.wxiaoqi.security.auth.service.AuthService; import com.github.wxiaoqi.security.auth.service.AuthService;
...@@ -9,6 +10,7 @@ import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest; ...@@ -9,6 +10,7 @@ import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest;
import com.github.wxiaoqi.security.auth.util.user.JwtTokenUtil; import com.github.wxiaoqi.security.auth.util.user.JwtTokenUtil;
import com.github.wxiaoqi.security.common.constant.RequestTypeConstants; import com.github.wxiaoqi.security.common.constant.RequestTypeConstants;
import com.github.wxiaoqi.security.common.exception.auth.UserInvalidException; import com.github.wxiaoqi.security.common.exception.auth.UserInvalidException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -36,6 +38,20 @@ public class AppAuthServiceImpl implements AuthService { ...@@ -36,6 +38,20 @@ public class AppAuthServiceImpl implements AuthService {
throw new UserInvalidException("用户不存在或账户密码错误!"); throw new UserInvalidException("用户不存在或账户密码错误!");
} }
@Override
public ObjectRestResponse loginSmall(JwtAuthenticationRequest authenticationRequest) throws Exception {
UserInfo info = userService.validateSmall(authenticationRequest);
if (info!=null&&!StringUtils.isEmpty(info.getId())) {
info.setPassword(null);
JSONObject object=new JSONObject();
String token=jwtTokenUtil.generateToken(new JWTInfo(info.getUsername(), info.getId() + "", info.getName()));
object.put("token",token);
object.put("info",info);
return ObjectRestResponse.succ(object);
}
throw new UserInvalidException("用户不存在或账户密码错误!");
}
@Override @Override
public String refresh(String oldToken) throws Exception { public String refresh(String oldToken) throws Exception {
return jwtTokenUtil.generateToken(jwtTokenUtil.getInfoFromToken(oldToken)); return jwtTokenUtil.generateToken(jwtTokenUtil.getInfoFromToken(oldToken));
......
...@@ -9,6 +9,7 @@ import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest; ...@@ -9,6 +9,7 @@ import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest;
import com.github.wxiaoqi.security.auth.util.user.JwtTokenUtil; import com.github.wxiaoqi.security.auth.util.user.JwtTokenUtil;
import com.github.wxiaoqi.security.common.constant.RequestTypeConstants; import com.github.wxiaoqi.security.common.constant.RequestTypeConstants;
import com.github.wxiaoqi.security.common.exception.auth.UserInvalidException; import com.github.wxiaoqi.security.common.exception.auth.UserInvalidException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -36,6 +37,20 @@ public class AuthServiceImpl implements AuthService { ...@@ -36,6 +37,20 @@ public class AuthServiceImpl implements AuthService {
throw new UserInvalidException("用户不存在或账户密码错误!"); throw new UserInvalidException("用户不存在或账户密码错误!");
} }
@Override
public ObjectRestResponse loginSmall(JwtAuthenticationRequest authenticationRequest) throws Exception {
UserInfo info = userService.validateSmall(authenticationRequest);
if (info!=null&&!StringUtils.isEmpty(info.getId())) {
info.setPassword(null);
JSONObject object=new JSONObject();
String token=jwtTokenUtil.generateToken(new JWTInfo(info.getUsername(), info.getId() + "", info.getName()));
object.put("token",token);
object.put("info",info);
return ObjectRestResponse.succ(object);
}
throw new UserInvalidException("用户不存在或账户密码错误!");
}
@Override @Override
public void validate(String token) throws Exception { public void validate(String token) throws Exception {
jwtTokenUtil.getInfoFromToken(token); jwtTokenUtil.getInfoFromToken(token);
......
...@@ -40,6 +40,11 @@ public class UserRest { ...@@ -40,6 +40,11 @@ public class UserRest {
public @ResponseBody UserInfo validate(@RequestBody Map<String,String> body){ public @ResponseBody UserInfo validate(@RequestBody Map<String,String> body){
return permissionService.validate(body.get("username"),body.get("password")); return permissionService.validate(body.get("username"),body.get("password"));
} }
@RequestMapping(value = "/user/validate/small", method = RequestMethod.POST)
public @ResponseBody UserInfo validateSmall(@RequestBody Map<String,String> body){
return permissionService.validateSmall(body.get("username"),body.get("password"));
}
......
...@@ -14,6 +14,8 @@ import com.github.wxiaoqi.security.api.vo.user.UserInfo; ...@@ -14,6 +14,8 @@ import com.github.wxiaoqi.security.api.vo.user.UserInfo;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil; import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.common.constant.CommonConstants; import com.github.wxiaoqi.security.common.constant.CommonConstants;
import com.github.wxiaoqi.security.common.util.TreeUtil; import com.github.wxiaoqi.security.common.util.TreeUtil;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -38,6 +40,9 @@ public class PermissionService { ...@@ -38,6 +40,9 @@ public class PermissionService {
private ElementBiz elementBiz; private ElementBiz elementBiz;
@Autowired @Autowired
private UserAuthUtil userAuthUtil; private UserAuthUtil userAuthUtil;
@Autowired
private VehicleFeign vehicleFeign;
private BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12); private BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12);
...@@ -60,6 +65,22 @@ public class PermissionService { ...@@ -60,6 +65,22 @@ public class PermissionService {
} }
return info; return info;
} }
//小程序登录
public UserInfo validateSmall(String username,String password){
UserInfo info = new UserInfo();
User user = userBiz.getUserByUsername(username);
if (user!=null){
if (encoder.matches(password, user.getPassword())) {
BeanUtils.copyProperties(user, info);
info.setId(user.getId().toString());
List<BranchCompany> list=vehicleFeign.companyAll(2,user.getDataCompany(),null);
if (list.size()>0){
info.setDataCompanyName(list.get(0).getName());
}
}
}
return info;
}
public List<PermissionInfo> getAllPermission() { public List<PermissionInfo> getAllPermission() {
List<Menu> menus = menuBiz.selectListAll(); List<Menu> menus = menuBiz.selectListAll();
......
...@@ -18,6 +18,7 @@ public class UserInfo implements Serializable{ ...@@ -18,6 +18,7 @@ public class UserInfo implements Serializable{
private Integer dataAll; private Integer dataAll;
private String dataZone; private String dataZone;
private String dataCompany; private String dataCompany;
private String dataCompanyName;
public Date getUpdTime() { public Date getUpdTime() {
return updTime; return updTime;
...@@ -92,4 +93,13 @@ public class UserInfo implements Serializable{ ...@@ -92,4 +93,13 @@ public class UserInfo implements Serializable{
public void setDataCompany(String dataCompany) { public void setDataCompany(String dataCompany) {
this.dataCompany = dataCompany; this.dataCompany = dataCompany;
} }
public String getDataCompanyName() {
return dataCompanyName;
}
public void setDataCompanyName(String dataCompanyName) {
this.dataCompanyName = dataCompanyName;
}
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -87,7 +87,7 @@ public class VehicleDepartureLog { ...@@ -87,7 +87,7 @@ public class VehicleDepartureLog {
*/ */
Integer bookRecordId; Integer bookRecordId;
private String illegalPic; String illegalPic;
private Integer illegalAmount; Integer illegalAmount;
} }
...@@ -26,4 +26,9 @@ public class VehicleDepartureLogVo { ...@@ -26,4 +26,9 @@ public class VehicleDepartureLogVo {
String departureDay; String departureDay;
String departureName; String departureName;
String arrivalName; String arrivalName;
Integer bookRecordId;
String illegalPic;
Integer illegalAmount;
} }
package com.xxfc.platform.vehicle.biz; package com.xxfc.platform.vehicle.biz;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
...@@ -418,21 +419,12 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> { ...@@ -418,21 +419,12 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
VehicleBookRecord vehicleBookRecord = null; VehicleBookRecord vehicleBookRecord = null;
if(bookVehicleVo.getVehicleBookRecordId() == null) { if(bookVehicleVo.getVehicleBookRecordId() == null) {
vehicleBookRecord = new VehicleBookRecord(); vehicleBookRecord = new VehicleBookRecord();
vehicleBookRecord.setVehicleId(bookVehicleVo.getVehicleId()); BeanUtil.copyProperties(bookVehicleVo, vehicleBookRecord, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
vehicleBookRecord.setBookType(bookVehicleVo.getBookType()); vehicleBookRecord.setBookStartDate(startDay.toDate());
vehicleBookRecord.setBookEndDate(endDay.toDate());
vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPLY.getCode()); vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPLY.getCode());
vehicleBookRecord.setBookUser(userId); vehicleBookRecord.setBookUser(userId);
vehicleBookRecord.setBookUserName(userName); vehicleBookRecord.setBookUserName(userName);
vehicleBookRecord.setBookStartDate(startDay.toDate());
vehicleBookRecord.setBookEndDate(endDay.toDate());
vehicleBookRecord.setLiftAddr(bookVehicleVo.getLiftAddr());
vehicleBookRecord.setRemark(bookVehicleVo.getRemark());
vehicleBookRecord.setDestination(bookVehicleVo.getDestination());
vehicleBookRecord.setLiftCompany(bookVehicleVo.getLiftCompany());
vehicleBookRecord.setRetCompany(bookVehicleVo.getRetCompany());
vehicleBookRecord.setVehicleUsername(bookVehicleVo.getVehicleUsername());
vehicleBookRecord.setVehicleUserPhone(bookVehicleVo.getVehicleUserPhone());
vehicleBookRecord.setUpkeepIds(bookVehicleVo.getUpkeepIds());
vehicleBookRecordBiz.save(vehicleBookRecord); vehicleBookRecordBiz.save(vehicleBookRecord);
} else { } else {
vehicleBookRecord = vehicleBookRecordBiz.selectById(bookVehicleVo.getVehicleBookRecordId()); vehicleBookRecord = vehicleBookRecordBiz.selectById(bookVehicleVo.getVehicleBookRecordId());
...@@ -511,21 +503,12 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> { ...@@ -511,21 +503,12 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
VehicleBookRecord vehicleBookRecord = null; VehicleBookRecord vehicleBookRecord = null;
if(bookVehicleVo.getVehicleBookRecordId() == null) { if(bookVehicleVo.getVehicleBookRecordId() == null) {
vehicleBookRecord = new VehicleBookRecord(); vehicleBookRecord = new VehicleBookRecord();
vehicleBookRecord.setVehicleId(bookVehicleVo.getVehicleId()); BeanUtil.copyProperties(bookVehicleVo, vehicleBookRecord, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
vehicleBookRecord.setBookType(bookVehicleVo.getBookType()); vehicleBookRecord.setBookStartDate(startDay.toDate());
vehicleBookRecord.setBookEndDate(endDay.toDate());
vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPROVE.getCode()); vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPROVE.getCode());
vehicleBookRecord.setBookUser(userId); vehicleBookRecord.setBookUser(userId);
vehicleBookRecord.setBookUserName(userName); vehicleBookRecord.setBookUserName(userName);
vehicleBookRecord.setBookStartDate(startDay.toDate());
vehicleBookRecord.setBookEndDate(endDay.toDate());
vehicleBookRecord.setLiftAddr(bookVehicleVo.getLiftAddr());
vehicleBookRecord.setRemark(bookVehicleVo.getRemark());
vehicleBookRecord.setDestination(bookVehicleVo.getDestination());
vehicleBookRecord.setLiftCompany(bookVehicleVo.getLiftCompany());
vehicleBookRecord.setRetCompany(bookVehicleVo.getRetCompany());
vehicleBookRecord.setVehicleUsername(bookVehicleVo.getVehicleUsername());
vehicleBookRecord.setVehicleUserPhone(bookVehicleVo.getVehicleUserPhone());
vehicleBookRecord.setUpkeepIds(bookVehicleVo.getUpkeepIds());
vehicleBookRecordBiz.save(vehicleBookRecord); vehicleBookRecordBiz.save(vehicleBookRecord);
} else { } else {
vehicleBookRecord = vehicleBookRecordBiz.selectById(bookVehicleVo.getVehicleBookRecordId()); vehicleBookRecord = vehicleBookRecordBiz.selectById(bookVehicleVo.getVehicleBookRecordId());
...@@ -1291,22 +1274,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> { ...@@ -1291,22 +1274,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
if(DATA_ALL_FALSE.equals(userDTO.getDataAll())) { //不能获取全部数据 if(DATA_ALL_FALSE.equals(userDTO.getDataAll())) { //不能获取全部数据
String zoneId = null; String zoneId = null;
if(StringUtils.isNotBlank(userDTO.getDataZone())) { if(StringUtils.isNotBlank(userDTO.getDataZone())) {
if(userDTO.getDataZone().contains(",")) {
zoneId = userDTO.getDataZone(); zoneId = userDTO.getDataZone();
} else {
zoneId = userDTO.getDataZone() + ",";
}
} else { } else {
zoneId = userDTO.getZoneId() + ","; zoneId = userDTO.getZoneId() + ",";
} }
vehiclePlanDto.setZoneIds(zoneId.split(",")); vehiclePlanDto.setZoneIds(zoneId.split(","));
String companyId = null; String companyId = null;
if(StringUtils.isNotBlank(userDTO.getDataCompany())) { if(StringUtils.isNotBlank(userDTO.getDataCompany())) {
if(userDTO.getDataCompany().contains(",")) {
companyId = userDTO.getDataCompany(); companyId = userDTO.getDataCompany();
} else {
companyId = userDTO.getDataCompany() + ",";
}
} else { } else {
companyId = userDTO.getCompanyId() + ","; companyId = userDTO.getCompanyId() + ",";
} }
......
...@@ -14,6 +14,7 @@ import com.xxfc.platform.vehicle.mapper.VehicleDepartureLogMapper; ...@@ -14,6 +14,7 @@ import com.xxfc.platform.vehicle.mapper.VehicleDepartureLogMapper;
import com.xxfc.platform.vehicle.mapper.VehicleMapper; import com.xxfc.platform.vehicle.mapper.VehicleMapper;
import com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo; import com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo;
import com.xxfc.platform.vehicle.pojo.VehicleDepartureStatisticDataVo; import com.xxfc.platform.vehicle.pojo.VehicleDepartureStatisticDataVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -25,6 +26,7 @@ import java.util.Date; ...@@ -25,6 +26,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
@Service @Service
@Slf4j
public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper, VehicleDepartureLog> { public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper, VehicleDepartureLog> {
@Autowired @Autowired
...@@ -71,21 +73,30 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper, ...@@ -71,21 +73,30 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
@Transactional @Transactional
public ObjectRestResponse save(VehicleDepartureLog vehicleDepartureLog) { public ObjectRestResponse save(VehicleDepartureLog vehicleDepartureLog) {
Integer id = vehicleDepartureLog.getId(); Integer id = vehicleDepartureLog.getId();
log.info("添加出行记录参数: vehicleDepartureLog = {}", vehicleDepartureLog);
if (id == null || id == 0) { if (id == null || id == 0) {
vehicleDepartureLog.setCreateTime(new Date()); vehicleDepartureLog.setCreateTime(new Date());
vehicleDepartureLog.setState(0); vehicleDepartureLog.setState(0);
insertSelective(vehicleDepartureLog); insertSelective(vehicleDepartureLog);
return ObjectRestResponse.succ();
} else { } else {
vehicleDepartureLog.setUpdateTime(new Date()); vehicleDepartureLog.setUpdateTime(new Date());
VehicleDepartureLog oldValue = mapper.selectByPrimaryKey(vehicleDepartureLog); VehicleDepartureLog oldValue = mapper.selectByPrimaryKey(vehicleDepartureLog);
if(oldValue != null) { if(oldValue != null) {
BeanUtil.copyProperties(oldValue, vehicleDepartureLog, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true)); log.info("更新出行记录: vehicleDepartureLog = {}", oldValue);
BeanUtil.copyProperties(vehicleDepartureLog, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
oldValue.setUpdateTime(new Date()); oldValue.setUpdateTime(new Date());
updateSelectiveById(oldValue); updateSelectiveById(oldValue);
return ObjectRestResponse.succ();
} else {
vehicleDepartureLog.setCreateTime(new Date());
vehicleDepartureLog.setState(0);
insertSelective(vehicleDepartureLog);
return ObjectRestResponse.succ();
} }
} }
return ObjectRestResponse.succ();
} }
......
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 to comment