Commit e6aeff22 authored by 李丛阳's avatar 李丛阳

修复冗余代码

parent 701b2b03
package org.rcisoft.core.controller; package org.rcisoft.core.controller;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.rcisoft.core.result.Result; import org.rcisoft.core.result.Result;
import org.rcisoft.core.service.AuthenticationService; import org.rcisoft.core.service.AuthenticationService;
import org.rcisoft.core.util.ResultGenerator; import org.rcisoft.core.util.ResultGenerator;
...@@ -30,6 +32,9 @@ public class AuthenticationController { ...@@ -30,6 +32,9 @@ public class AuthenticationController {
* @param password * @param password
* @return * @return
*/ */
@ApiImplicitParams({@ApiImplicitParam(name = "username", value = "用户名", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "password", value = "密码", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "userType", value = "用户类型 (1 admin 2 client)", required = true, dataType = "varchar")})
@PostMapping(value = "${jwt.route.authentication.path}") @PostMapping(value = "${jwt.route.authentication.path}")
public Result login(@RequestParam("username")String username, public Result login(@RequestParam("username")String username,
@RequestParam("password")String password, @RequestParam("password")String password,
...@@ -40,17 +45,22 @@ public class AuthenticationController { ...@@ -40,17 +45,22 @@ public class AuthenticationController {
} }
/** /**
* 注册 * 注册 根据需要开放注册
* @param addedUser * @param addedUser
* @return * @return
*/ */
@PostMapping(value = "${jwt.route.authentication.register}") //@PostMapping(value = "${jwt.route.authentication.register}")
public Result register(SysUser addedUser){ public Result register(SysUser addedUser){
authenticationServiceImpl.register(addedUser); authenticationServiceImpl.register(addedUser);
return ResultGenerator.genSuccessResult(); return ResultGenerator.genSuccessResult();
} }
@GetMapping(value = "${jwt.route.authentication.refresh}") /**
* 刷新token 暂不开放
* @param request
* @return
*/
//@GetMapping(value = "${jwt.route.authentication.refresh}")
public ResponseEntity<?> refreshAndGetAuthenticationToken( public ResponseEntity<?> refreshAndGetAuthenticationToken(
HttpServletRequest request){ HttpServletRequest request){
String token = request.getHeader(tokenHeader); String token = request.getHeader(tokenHeader);
......
package org.rcisoft.core.controller;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.common.component.Global;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result;
import org.rcisoft.core.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.Date;
/**
* Created by lcy on 18/2/24.
*
* common
*/
@Controller("/common")
public class CommonController<T> extends FileController<T> {
@Autowired
private Global global;
/**
* 文件上传
* @param file
* @return
*/
@ApiOperation(value="文件上传", notes="文件上传")
@ApiImplicitParams({@ApiImplicitParam(name = "file", value = "文件", required = true, dataType = "file")})
@PostMapping(value = "/upload")
public Result commonFileUpload(@RequestParam("file") MultipartFile file){
String filePath = super.globalCommonFileUpload(file, super.SAVING_PATTERN_UUID, global.getBaseUploadLocation() +
global.getTEMP_LOCATION() + File.separator + DateUtil.getSimepleDate("yyyyMMdd", new Date()));
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
filePath);
}
}
...@@ -21,12 +21,26 @@ import java.util.UUID; ...@@ -21,12 +21,26 @@ import java.util.UUID;
public class FileController<T> extends PaginationController<T> { public class FileController<T> extends PaginationController<T> {
protected static final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); protected static final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
protected static final String SEPARATOR; protected static final String SEPARATOR;
/*date 格式*/
protected static final String SAVING_PATTERN_DATE = "DATE";
/*uuid 格式*/
protected static final String SAVING_PATTERN_UUID = "UUID";
Logger logger = Logger.getLogger(FileController.class); Logger logger = Logger.getLogger(FileController.class);
static { static {
SEPARATOR = File.separator; SEPARATOR = File.separator;
} }
/**
* gload 文件上传
* @param multipartFile
* @param savingPatternOrFullName
* @param savingAbsolutePath
* @return
*/
protected String globalCommonFileUpload(MultipartFile multipartFile, String savingPatternOrFullName, String savingAbsolutePath) { protected String globalCommonFileUpload(MultipartFile multipartFile, String savingPatternOrFullName, String savingAbsolutePath) {
String finalSavingPath; String finalSavingPath;
String returnFinalFileName; String returnFinalFileName;
...@@ -37,22 +51,21 @@ public class FileController<T> extends PaginationController<T> { ...@@ -37,22 +51,21 @@ public class FileController<T> extends PaginationController<T> {
returnFinalFileName = ""; returnFinalFileName = "";
switch(savingPatternOrFullName.hashCode()) { switch(savingPatternOrFullName.hashCode()) {
case 2090926: case 2090926:
if(savingPatternOrFullName.equals("DATE")) { if(savingPatternOrFullName.equals(this.SAVING_PATTERN_DATE)) {
returnFinalFileName = getCurrentDateTimeString() + fileExtendsName; returnFinalFileName = getCurrentDateTimeString() + fileExtendsName;
finalSavingPath = savingAbsolutePath + SEPARATOR + getCurrentDateTimeString() + fileExtendsName; finalSavingPath = savingAbsolutePath + SEPARATOR + getCurrentDateTimeString() + fileExtendsName;
break label32; break label32;
} }
break; break;
case 2616251: case 2616251:
if(savingPatternOrFullName.equals("UUID")) { if(savingPatternOrFullName.equals(this.SAVING_PATTERN_UUID)) {
returnFinalFileName = getUUIDString() + fileExtendsName; returnFinalFileName = getUUIDString() + fileExtendsName;
finalSavingPath = savingAbsolutePath + SEPARATOR + getUUIDString() + fileExtendsName; finalSavingPath = savingAbsolutePath + SEPARATOR + getUUIDString() + fileExtendsName;
break label32; break label32;
} }
} }
returnFinalFileName = savingPatternOrFullName; finalSavingPath = savingAbsolutePath + SEPARATOR + returnFinalFileName;
finalSavingPath = savingAbsolutePath + SEPARATOR + savingPatternOrFullName;
} }
File dir = new File(savingAbsolutePath); File dir = new File(savingAbsolutePath);
...@@ -71,7 +84,7 @@ public class FileController<T> extends PaginationController<T> { ...@@ -71,7 +84,7 @@ public class FileController<T> extends PaginationController<T> {
var11.printStackTrace(); var11.printStackTrace();
} }
return returnFinalFileName; return finalSavingPath;
} }
......
...@@ -13,9 +13,9 @@ import org.rcisoft.core.result.Result; ...@@ -13,9 +13,9 @@ import org.rcisoft.core.result.Result;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.common.controller.PaginationController; import org.rcisoft.core.controller.PaginationController;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
import org.rcisoft.common.model.GridModel; import org.rcisoft.core.model.GridModel;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import javax.validation.Valid; import javax.validation.Valid;
...@@ -83,7 +83,7 @@ public class ${table.entityName}Controller extends PaginationController<${table. ...@@ -83,7 +83,7 @@ public class ${table.entityName}Controller extends PaginationController<${table.
${table.entityName?uncap_first}ServiceImpl.findById(id)); ${table.entityName?uncap_first}ServiceImpl.findById(id));
} }
@ApiOperation(value="查看 ${table.tableRemark!} 集合", notes="查看 ${table.tableRemark!} 集合") @ApiOperation(value="查看 ${table.tableRemark!} 集合", notes="查看 ${table.tableRemark!} 集合")
@GetMapping(value = "/query${table.entityName}ByPagination") @GetMapping(value = "/query${table.entityName}ByPagination")
public GridModel listByPagination(${table.entityName} ${table.entityName?uncap_first}) { public GridModel listByPagination(${table.entityName} ${table.entityName?uncap_first}) {
${table.entityName?uncap_first}.setCreateBy(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID)); ${table.entityName?uncap_first}.setCreateBy(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID));
......
...@@ -38,7 +38,6 @@ public class ${table.entityName}ServiceImpl implements ${table.entityName}Servic ...@@ -38,7 +38,6 @@ public class ${table.entityName}ServiceImpl implements ${table.entityName}Servic
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
public PersistModel save(${table.entityName} ${table.entityName?uncap_first}){ public PersistModel save(${table.entityName} ${table.entityName?uncap_first}){
${table.entityName?uncap_first}.setCommonBusinessId();
//增加操作 //增加操作
UserUtil.setCurrentPersistOperation(${table.entityName?uncap_first}); UserUtil.setCurrentPersistOperation(${table.entityName?uncap_first});
int line = ${table.entityName?uncap_first}Repository.insertSelective(${table.entityName?uncap_first}); int line = ${table.entityName?uncap_first}Repository.insertSelective(${table.entityName?uncap_first});
......
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