已修改25个文件
已重命名3个文件
已添加23个文件
| | |
| | | package com.yuanchu.limslaboratory.config; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.DbType; |
| | | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | public OptimisticLockerInterceptor optimisticLockerInterceptor() { |
| | | return new OptimisticLockerInterceptor(); |
| | | } |
| | | |
| | | /** |
| | | * éè¦é
ç½®æ¦æªå¨ï¼ä¸ç¶å¨AddDeviceä¸çtotalæ æ³è·åå° |
| | | * @return |
| | | */ |
| | | @Bean |
| | | public MybatisPlusInterceptor mybatisPlusInterceptor(){ |
| | | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
| | | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); |
| | | return interceptor; |
| | | } |
| | | } |
| | |
| | | // ç¨ApiInfoBuilderè¿è¡å®å¶ |
| | | return new ApiInfoBuilder() |
| | | // 设置æ é¢ |
| | | .title("æ±èéµ·éç½ç»ç§ææéå
¬å¸ç®¡çç³»ç»") |
| | | .title("LIMS管çç³»ç»") |
| | | // æè¿° |
| | | .description("æ±èéµ·éç½ç»ç§ææéå
¬å¸ç®¡çç³»ç»") |
| | | .description("LIMS管çç³»ç»") |
| | | // ä½è
ä¿¡æ¯ |
| | | .contact(new Contact("Crunchy", null, null)) |
| | | // çæ¬ |
| | |
| | | /** è¿è¡æ¶å¼å¸¸ */ |
| | | @ExceptionHandler(RuntimeException.class) |
| | | public Result<?> runtimeExceptionHandler(RuntimeException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("è¿è¡æ¶å¼å¸¸"); |
| | | } |
| | | |
| | | /** ç±»å转æ¢å¼å¸¸ */ |
| | | @ExceptionHandler(ClassCastException.class) |
| | | public Result<?> classCastExceptionHandler(ClassCastException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("ç±»å转æ¢å¼å¸¸"); |
| | | } |
| | | /** æä»¶æªæ¾å°å¼å¸¸ */ |
| | | @ExceptionHandler(FileNotFoundException.class) |
| | | public Result<?> FileNotFoundException(FileNotFoundException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("æä»¶æªæ¾å°å¼å¸¸"); |
| | | } |
| | | /** æ°åæ ¼å¼å¼å¸¸ */ |
| | | @ExceptionHandler(NumberFormatException.class) |
| | | public Result<?> NumberFormatException(NumberFormatException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("æ°åæ ¼å¼å¼å¸¸"); |
| | | } |
| | | /** å®å
¨å¼å¸¸ */ |
| | | @ExceptionHandler(SecurityException.class) |
| | | public Result<?> SecurityException(SecurityException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("å®å
¨å¼å¸¸"); |
| | | } |
| | | |
| | | /** ç±»åä¸åå¨å¼å¸¸ */ |
| | | @ExceptionHandler(TypeNotPresentException.class) |
| | | public Result<?> TypeNotPresentException(TypeNotPresentException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("ç±»åä¸åå¨å¼å¸¸"); |
| | | } |
| | | |
| | | /** IOå¼å¸¸ */ |
| | | @ExceptionHandler(IOException.class) |
| | | public Result<?> iOExceptionHandler(IOException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("IOå¼å¸¸"); |
| | | } |
| | | |
| | | /** æªç¥æ¹æ³å¼å¸¸ */ |
| | | @ExceptionHandler(NoSuchMethodException.class) |
| | | public Result<?> noSuchMethodExceptionHandler(NoSuchMethodException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("æªç¥æ¹æ³å¼å¸¸"); |
| | | } |
| | | |
| | | /** æ°ç»è¶çå¼å¸¸ */ |
| | | @ExceptionHandler(IndexOutOfBoundsException.class) |
| | | public Result<?> indexOutOfBoundsExceptionHandler(IndexOutOfBoundsException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("æ°ç»è¶çå¼å¸¸"); |
| | | } |
| | | /** sqlè¯æ³é误å¼å¸¸ */ |
| | | @ExceptionHandler(BadSqlGrammarException.class) |
| | | public Result<?> BadSqlGrammarException(BadSqlGrammarException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("sqlè¯æ³é误å¼å¸¸"); |
| | | } |
| | | |
| | | /** æ æ³æ³¨å
¥beanå¼å¸¸ */ |
| | | @ExceptionHandler(NoSuchBeanDefinitionException.class) |
| | | public Result<?> NoSuchBeanDefinitionException(NoSuchBeanDefinitionException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("æ æ³æ³¨å
¥bean"); |
| | | } |
| | | |
| | | /** Httpæ¶æ¯ä¸å¯è¯»å¼å¸¸ */ |
| | | @ExceptionHandler({HttpMessageNotReadableException.class}) |
| | | public Result<?> requestNotReadable(HttpMessageNotReadableException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("Httpæ¶æ¯ä¸å¯è¯»"); |
| | | } |
| | | |
| | | /** 400é误 */ |
| | | @ExceptionHandler({TypeMismatchException.class}) |
| | | public Result<?> requestTypeMismatch(TypeMismatchException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("æå¡å¨å¼å¸¸"); |
| | | } |
| | | |
| | | /** 500é误 */ |
| | | @ExceptionHandler({ConversionNotSupportedException.class, HttpMessageNotWritableException.class}) |
| | | public Result<?> server500(RuntimeException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("æå¡å¨å¼å¸¸"); |
| | | } |
| | | |
| | | /** æ æº¢åº */ |
| | | @ExceptionHandler({StackOverflowError.class}) |
| | | public Result<?> requestStackOverflow(StackOverflowError e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("æ æº¢åºå¼å¸¸"); |
| | | } |
| | | |
| | | /** 餿°ä¸è½ä¸º0 */ |
| | | @ExceptionHandler({ArithmeticException.class}) |
| | | public Result<?> arithmeticException(ArithmeticException e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("餿°ä¸è½ä¸º0å¼å¸¸"); |
| | | } |
| | | |
| | | /** å
¶ä»é误 */ |
| | | @ExceptionHandler({Exception.class}) |
| | | public Result<?> exception(Exception e) { |
| | | log.error(e.getMessage(), e.getCause()); |
| | | e.printStackTrace(); |
| | | return Result.fail("ç½ç»è¿æ¥å¤±è´¥ï¼è¯·éåºååè¯"); |
| | | } |
| | | } |
| | |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | @Component |
| | | public class MyMetaObjectHandler implements MetaObjectHandler { |
| | | @Override |
| | | public void insertFill(MetaObject metaObject) { |
| | | this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now()); // èµ·å§çæ¬ 3.3.0(æ¨è使ç¨) |
| | | this.strictInsertFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); // èµ·å§çæ¬ 3.3.0(æ¨è使ç¨) |
| | | this.strictInsertFill(metaObject, "createTime", Date.class, new Date()); // èµ·å§çæ¬ 3.3.0(æ¨è使ç¨) |
| | | this.strictInsertFill(metaObject, "updateTime", Date.class, new Date()); // èµ·å§çæ¬ 3.3.0(æ¨è使ç¨) |
| | | } |
| | | |
| | | @Override |
| | | public void updateFill(MetaObject metaObject) { |
| | | // updateçæ¶å使ç¨ï¼æ´æ°çæ¶å强å¶è¿è¡å¡«å
|
| | | this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); // èµ·å§çæ¬ 3.3.0(æ¨è) |
| | | this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date()); // èµ·å§çæ¬ 3.3.0(æ¨è) |
| | | } |
| | | } |
ÎļþÃû´Ó framework/src/main/java/com/yuanchu/limslaboratory/utils/FileSaveUtils.java ÐÞ¸Ä |
| | |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class FileSaveUtils { |
| | | public class FileSaveUtil { |
| | | |
| | | // åymlä¸çè·¯å¾ + / |
| | | // @Value("${file.path}") |
| | |
| | | */ |
| | | public String StoreFile(byte[] content, String originalFilename) { |
| | | // çæéæºåç§°ï¼æ¶é´_éæº6使°å |
| | | String FileName = System.currentTimeMillis() + "_" + MyUtils.getNumber(6); |
| | | String FileName = System.currentTimeMillis() + "_" + MyUtil.getNumber(6); |
| | | String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); |
| | | // åç§°æ¼æ¥ |
| | | String fileName = FileName + suffix; |
| | |
| | | ByteArrayInputStream is = new ByteArrayInputStream(content)) { |
| | | IOUtils.copy(is, os); |
| | | } catch (IOException e) { |
| | | MyUtils.PrintLog("å卿件å¼å¸¸ï¼" + e); |
| | | MyUtil.PrintLog("å卿件å¼å¸¸ï¼" + e); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å符串转对象 |
| | | * @param str |
| | | * @param valueType |
| | | * @return |
| | | * @param <T> |
| | | * @throws Exception |
| | | */ |
| | | public static <T> T unmarshal(String str, Class<T> valueType) throws Exception { |
| | | try { |
| | | return OBJECT_MAPPER.readValue(str, valueType); |
ÎļþÃû´Ó framework/src/main/java/com/yuanchu/limslaboratory/utils/MyUtils.java ÐÞ¸Ä |
| | |
| | | import java.util.Random; |
| | | |
| | | @Component |
| | | public class MyUtils<T> { |
| | | public class MyUtil<T> { |
| | | |
| | | /** |
| | | * èªå®ä¹è°è¯å·¥å
·ç±» |
ÎļþÃû´Ó framework/src/main/java/com/yuanchu/limslaboratory/utils/SpringUtils.java ÐÞ¸Ä |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | public class SpringUtils implements ApplicationContextAware { |
| | | public class SpringUtil implements ApplicationContextAware { |
| | | private static ApplicationContext context; |
| | | |
| | | @Override |
| | |
| | | <module>user-server</module> |
| | | <module>sys</module> |
| | | <module>framework</module> |
| | | <module>standard-library</module> |
| | | </modules> |
| | | |
| | | <properties> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <parent> |
| | | <artifactId>lims-laboratory</artifactId> |
| | | <groupId>com.yuanchu</groupId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | </parent> |
| | | <groupId>com.yunchu.limslaboratory</groupId> |
| | | <artifactId>standard-library</artifactId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | <name>standard-library</name> |
| | | <description>standard-library</description> |
| | | |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.yunchu.limslaboratory</groupId> |
| | | <artifactId>framework</artifactId> |
| | | <version>${project.parent.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.yunchu.limslaboratory</groupId> |
| | | <artifactId>user-server</artifactId> |
| | | <version>${project.parent.version}</version> |
| | | </dependency> |
| | | |
| | | <!--mybatis-plus--> |
| | | <dependency> |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>mybatis-plus-boot-starter</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.SerialNumber; |
| | | import com.yuanchu.limslaboratory.service.SerialNumberService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | @Api(tags = "æ ååº-->åå·æä½") |
| | | @RestController |
| | | @RequestMapping("/serial-number") |
| | | public class SerialNumberController { |
| | | |
| | | @Autowired |
| | | private SerialNumberService serialNumberService; |
| | | |
| | | @ApiOperation("æ ååº-->æ·»å åå·") |
| | | @PostMapping("/add") |
| | | public Result<?> addSerialNumberInformation(@RequestHeader("X-Token") String token,@RequestBody SerialNumber serialNumber) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | serialNumber.setUserId((Integer) unmarshal.get("id")); |
| | | Integer isStandardsSuccess = serialNumberService.addSerialNumberInformation(serialNumber); |
| | | if (isStandardsSuccess == 1) { |
| | | return Result.success("æ·»å ã"+ serialNumber.getName() +"ãæåï¼"); |
| | | } |
| | | return Result.fail("æ·»å ã"+ serialNumber.getName() +"ã失败ï¼"); |
| | | } |
| | | |
| | | @ApiOperation("æ ååº-->ç¹å»ä¾§è¾¹æ æ åï¼æ¥è¯¢ææåå·") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(value = "æ åå·/æ ååç§°", name = "IdOrNameOfSerialNumber", dataTypeClass = String.class), |
| | | @ApiImplicitParam(value = "æ åå·Id", name = "standardsId", dataTypeClass = String.class, required = true) |
| | | }) |
| | | @GetMapping("/list") |
| | | public Result<?> listSerialNumberInformation(String IdOrNameOfSerialNumber, String standardsId){ |
| | | List<Map<String, Object>> selectStandards= serialNumberService.listSerialNumberInformation(IdOrNameOfSerialNumber,standardsId); |
| | | return Result.success(selectStandards); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.pojo.Specifications; |
| | | import com.yuanchu.limslaboratory.pojo.Standards; |
| | | import com.yuanchu.limslaboratory.service.SpecificationsService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.ListSpecificationsInformation; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | | * å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | @Api(tags = "æ ååº-->åå·-->产åè§æ ¼æä½") |
| | | @RestController |
| | | @RequestMapping("/specifications") |
| | | public class SpecificationsController { |
| | | |
| | | @Autowired |
| | | private SpecificationsService specificationsService; |
| | | |
| | | @ApiOperation("æ ååº-->产åè§æ ¼") |
| | | @PostMapping("/add") |
| | | public Result<?> addSpecificationsInformation(@RequestHeader("X-Token") String token,@RequestBody Specifications specifications) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | specifications.setUserId((Integer) unmarshal.get("id")); |
| | | Integer isStandardsSuccess = specificationsService.addSpecificationsInformation(specifications); |
| | | if (isStandardsSuccess == 1) { |
| | | return Result.success("æ·»å ã"+ specifications.getName() +"ãæåï¼"); |
| | | } |
| | | return Result.fail("æ·»å ã"+ specifications.getName() +"ã失败ï¼"); |
| | | } |
| | | |
| | | @ApiOperation("æ ååº-->æ ¹æ®åå·æ¥è¯¢äº§åè§æ ¼") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageNo", value = "èµ·å§é¡µ", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "æ¯ä¸é¡µæ°é", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "specificationsName", value = "åå·åç§°", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "serialNumberId", value = "åå·ID", dataTypeClass = String.class), |
| | | }) |
| | | @GetMapping("/list") |
| | | public Result<?> listSpecificationsInformation(Integer pageNo, |
| | | Integer pageSize, |
| | | String specificationsName, |
| | | String serialNumberId){ |
| | | IPage<ListSpecificationsInformation> pageList= specificationsService.listSpecificationsInformation(specificationsName,serialNumberId,new Page<Objects>(pageNo, pageSize)); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("row", pageList.getRecords()); |
| | | map.put("total", pageList.getTotal()); |
| | | return Result.success(map); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.yuanchu.limslaboratory.pojo.Standards; |
| | | import com.yuanchu.limslaboratory.service.StandardsService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | @Api(tags = "æ ååºæä½") |
| | | @RestController |
| | | @RequestMapping("/standards") |
| | | public class StandardsController { |
| | | |
| | | @Autowired |
| | | private StandardsService standardsService; |
| | | |
| | | @ApiOperation("æ ååº-->æ·»å æ å") |
| | | @PostMapping("/add") |
| | | public Result<?> addStandardsInformation(@RequestHeader("X-Token") String token, @RequestBody Standards standards) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | standards.setUserId((Integer) unmarshal.get("id")); |
| | | Integer isStandardsSuccess = standardsService.addStandardsInformation(standards); |
| | | if (isStandardsSuccess == 1) { |
| | | return Result.success("æ·»å ã"+ standards.getName() +"ãæåï¼"); |
| | | } |
| | | return Result.fail("æ·»å ã"+ standards.getName() +"ã失败ï¼"); |
| | | } |
| | | |
| | | @ApiOperation("æ ååº-->ç¹å»å
¨é¨ï¼æ¥è¯¢æææ åæ°æ®") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(value = "æ åå·/æ ååç§°", name = "IdOrNameOfStandards", dataTypeClass = String.class) |
| | | }) |
| | | @GetMapping("/list") |
| | | public Result<?> listStandardsInformation(String IdOrNameOfStandards){ |
| | | List<Map<String, Object>> list = standardsService.listStandardsInformation(IdOrNameOfStandards); |
| | | return Result.success(list); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.mapper; |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.SerialNumber; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | public interface SerialNumberMapper extends BaseMapper<SerialNumber> { |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.pojo.Specifications; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.yuanchu.limslaboratory.vo.ListSpecificationsInformation; |
| | | |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | public interface SpecificationsMapper extends BaseMapper<Specifications> { |
| | | |
| | | IPage<ListSpecificationsInformation> listSpecificationsInformation(String specificationsName, String serialNumberId, Page<Objects> page); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.mapper; |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.Standards; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | public interface StandardsMapper extends BaseMapper<Standards> { |
| | | |
| | | List<Map<String, Object>> listStandardsInformation(String idOrNameOfStandards); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.pojo; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.Version; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value="SerialNumber对象", description="åå·") |
| | | public class SerialNumber implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "åå·ç¼å·", example = "ModelNumber001", required = true) |
| | | private String id; |
| | | |
| | | @ApiModelProperty(value = "åå·åç§°",example = "å
纤2.0.1", required = true) |
| | | private String name; |
| | | |
| | | @TableLogic(value = "1", delval = "0") |
| | | @ApiModelProperty(value = "é»è¾å é¤ æ£å¸¸>=1,å é¤<=0", hidden = true) |
| | | private Integer state; |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @ApiModelProperty(value = "å建æ¶é´", hidden = true) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date createTime; |
| | | |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´", hidden = true) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date updateTime; |
| | | |
| | | @ApiModelProperty(value = "ä¹è§é", hidden = true) |
| | | @Version |
| | | private Integer version; |
| | | |
| | | @ApiModelProperty(value = "å
³èåæ®µ æ åç¼å·id", example = "230711000002", required = true) |
| | | private String standardsId; |
| | | |
| | | @ApiModelProperty(value = "å
³èåæ®µ æ·»å ç¨æ·id", hidden = true) |
| | | private Integer userId; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value="Specifications对象", description="è§æ ¼") |
| | | public class Specifications implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "è§æ ¼id", hidden = true) |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(value = "è§æ ¼id", example = "modelId", required = true) |
| | | private String number; |
| | | |
| | | @ApiModelProperty(value = "产åè§æ ¼åç§°", example = "AB", required = true) |
| | | private String name; |
| | | |
| | | @ApiModelProperty(value = "ç产æä»¤å·", example = "test", required = true) |
| | | private String instruct; |
| | | |
| | | @ApiModelProperty(value = "çµåç级", example = "test", required = true) |
| | | private String voltageLevel; |
| | | |
| | | @ApiModelProperty(value = "ä¸»çº¿å¿æªé¢", example = "test", required = true) |
| | | private String crossSection; |
| | | |
| | | @ApiModelProperty(value = "主线è¯è¯æ°", example = "test", required = true) |
| | | private String numberOfCores; |
| | | |
| | | @ApiModelProperty(value = "è§æ ¼ç¶æ 0ï¼åç¨ï¼1ï¼æ£å¸¸ï¼-1ï¼è稿", hidden = true) |
| | | private Integer spe_state; |
| | | |
| | | @ApiModelProperty(value = "é»è¾å é¤ æ£å¸¸>=1,å é¤<=0", hidden = true) |
| | | private Integer state; |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @ApiModelProperty(value = "å建æ¶é´", hidden = true) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date createTime; |
| | | |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´", hidden = true) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date updateTime; |
| | | |
| | | @ApiModelProperty(value = "ä¹è§é", hidden = true) |
| | | @Version |
| | | private Integer version; |
| | | |
| | | @ApiModelProperty(value = "å
³èåæ®µ åå·id", hidden = true) |
| | | private String vel; |
| | | |
| | | @ApiModelProperty(value = "å
³èåæ®µ åå·id", example = "230711000002", required = true) |
| | | private String serialId; |
| | | |
| | | @ApiModelProperty(value = "å
³èåæ®µ ç¨æ·id", hidden = true) |
| | | private Integer userId; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value="Standards对象", description="æ å") |
| | | public class Standards implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "æ åç¼å· yyMMdd000001(000001++)", example = "230711000001", required = true) |
| | | @TableId(value = "id", type = IdType.INPUT) |
| | | private String id; |
| | | |
| | | @ApiModelProperty(value = "æ ååç§°", example = "å
纤", required = true) |
| | | private String name; |
| | | |
| | | @ApiModelProperty(value = "è±æåç§°", example = "OpticalFibre", required = true) |
| | | private String engName; |
| | | |
| | | @ApiModelProperty(value = "0ï¼åææï¼1ï¼çµçº¿çµç¼", example = "1", required = true) |
| | | private Integer type; |
| | | |
| | | @TableLogic(value = "1", delval = "0") |
| | | @ApiModelProperty(value = "é»è¾å é¤ æ£å¸¸>=1,å é¤<=0", hidden = true) |
| | | private Integer state; |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @ApiModelProperty(value = "å建æ¶é´", hidden = true) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date createTime; |
| | | |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´", hidden = true) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date updateTime; |
| | | |
| | | @ApiModelProperty(value = "ä¹è§é", hidden = true) |
| | | @Version |
| | | private Integer version; |
| | | |
| | | @ApiModelProperty(value = "å
³èåæ®µ æ´æ°äººid", hidden = true) |
| | | private Integer userId; |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.service; |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.SerialNumber; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | public interface SerialNumberService extends IService<SerialNumber> { |
| | | |
| | | /** |
| | | * æ·»å åå·ï¼é¦å
éè¦å¤æç¨æ·ï¼æ åç¼ç æ¯å¦åå¨ |
| | | * @param serialNumber |
| | | * @return |
| | | */ |
| | | Integer addSerialNumberInformation(SerialNumber serialNumber); |
| | | |
| | | List<Map<String, Object>> listSerialNumberInformation(String idOrNameOfSerialNumber, String standardsId); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.pojo.Specifications; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.yuanchu.limslaboratory.vo.ListSpecificationsInformation; |
| | | |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | | * æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | public interface SpecificationsService extends IService<Specifications> { |
| | | |
| | | Integer addSpecificationsInformation(Specifications specifications); |
| | | |
| | | IPage<ListSpecificationsInformation> listSpecificationsInformation(String specificationsName, String serialNumberId, Page<Objects> page); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.service; |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.Standards; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | public interface StandardsService extends IService<Standards> { |
| | | |
| | | Integer addStandardsInformation(Standards standards); |
| | | |
| | | List<Map<String, Object>> listStandardsInformation(String IdOrNameOfStandards); |
| | | |
| | | /** |
| | | * æ ¹æ®Idæ¥è¯¢æ¯å¦åå¨è¯¥æ å |
| | | */ |
| | | Boolean standardsIsNull(String Id); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.yuanchu.limslaboratory.pojo.SerialNumber; |
| | | import com.yuanchu.limslaboratory.mapper.SerialNumberMapper; |
| | | import com.yuanchu.limslaboratory.pojo.Standards; |
| | | import com.yuanchu.limslaboratory.pojo.User; |
| | | import com.yuanchu.limslaboratory.service.SerialNumberService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.limslaboratory.service.StandardsService; |
| | | import com.yuanchu.limslaboratory.service.UserService; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | @Service |
| | | public class SerialNumberServiceImpl extends ServiceImpl<SerialNumberMapper, SerialNumber> implements SerialNumberService { |
| | | |
| | | @Resource |
| | | private SerialNumberMapper serialNumberMapper; |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Autowired |
| | | private StandardsService standardsService; |
| | | |
| | | @Override |
| | | public Integer addSerialNumberInformation(SerialNumber serialNumber) { |
| | | Boolean userIsNull = userService.userIsNull(serialNumber.getUserId()); |
| | | if (userIsNull){ |
| | | Boolean standardsIsNull = standardsService.standardsIsNull(serialNumber.getStandardsId()); |
| | | if (!ObjectUtils.isEmpty(standardsIsNull)){ |
| | | return serialNumberMapper.insert(serialNumber); |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> listSerialNumberInformation(String idOrNameOfSerialNumber, String standardsId) { |
| | | LambdaQueryWrapper<SerialNumber> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(SerialNumber::getStandardsId, standardsId); |
| | | wrapper.like(SerialNumber::getId, idOrNameOfSerialNumber); |
| | | wrapper.or().like(SerialNumber::getName, idOrNameOfSerialNumber); |
| | | wrapper.select(SerialNumber::getId, SerialNumber::getName); |
| | | return serialNumberMapper.selectMaps(wrapper); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.pojo.Specifications; |
| | | import com.yuanchu.limslaboratory.mapper.SpecificationsMapper; |
| | | import com.yuanchu.limslaboratory.service.SpecificationsService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.limslaboratory.service.StandardsService; |
| | | import com.yuanchu.limslaboratory.service.UserService; |
| | | import com.yuanchu.limslaboratory.vo.ListSpecificationsInformation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | | * æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | @Service |
| | | public class SpecificationsServiceImpl extends ServiceImpl<SpecificationsMapper, Specifications> implements SpecificationsService { |
| | | |
| | | @Resource |
| | | private SpecificationsMapper specificationsMapper; |
| | | |
| | | @Autowired |
| | | private StandardsService standardsService; |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Override |
| | | public Integer addSpecificationsInformation(Specifications specifications) { |
| | | Boolean userIsNull = userService.userIsNull(specifications.getUserId()); |
| | | if (userIsNull){ |
| | | Boolean standardsIsNull = standardsService.standardsIsNull(specifications.getSerialId()); |
| | | if (!ObjectUtils.isEmpty(standardsIsNull)){ |
| | | LambdaQueryWrapper<Specifications> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(Specifications::getNumber, specifications.getNumber()); |
| | | Specifications specificationsNumberIsNull = specificationsMapper.selectOne(wrapper); |
| | | if (ObjectUtils.isEmpty(specificationsNumberIsNull)){ |
| | | return specificationsMapper.insert(specifications); |
| | | } |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<ListSpecificationsInformation> listSpecificationsInformation(String specificationsName, String serialNumberId, Page<Objects> page) { |
| | | return specificationsMapper.listSpecificationsInformation(specificationsName,serialNumberId,page); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.yuanchu.limslaboratory.pojo.Standards; |
| | | import com.yuanchu.limslaboratory.mapper.StandardsMapper; |
| | | import com.yuanchu.limslaboratory.pojo.User; |
| | | import com.yuanchu.limslaboratory.service.StandardsService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.limslaboratory.service.UserService; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-11 |
| | | */ |
| | | @Service |
| | | public class StandardsServiceImpl extends ServiceImpl<StandardsMapper, Standards> implements StandardsService { |
| | | |
| | | @Resource |
| | | private StandardsMapper standardsMapper; |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Override |
| | | public Integer addStandardsInformation(Standards standards) { |
| | | Boolean userIsNull = userService.userIsNull(standards.getUserId()); |
| | | if (userIsNull){ |
| | | return standardsMapper.insert(standards); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> listStandardsInformation(String IdOrNameOfStandards) { |
| | | return standardsMapper.listStandardsInformation(IdOrNameOfStandards); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean standardsIsNull(String Id) { |
| | | LambdaQueryWrapper<Standards> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(Standards::getId, Id); |
| | | Standards standardsIsNull = standardsMapper.selectOne(wrapper); |
| | | return !ObjectUtils.isEmpty(standardsIsNull); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value="ListSpecificationsInformation对象", description="ç¨äºå页æ¾ç¤ºè§æ ¼æ°æ®") |
| | | public class ListSpecificationsInformation { |
| | | |
| | | private Integer id; |
| | | |
| | | private String name; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date updateTime; |
| | | |
| | | private String username; |
| | | |
| | | private String vel; |
| | | |
| | | private Integer spe_state; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.yuanchu.limslaboratory.mapper.SerialNumberMapper"> |
| | | |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.yuanchu.limslaboratory.mapper.SpecificationsMapper"> |
| | | |
| | | <resultMap id="listSpecificationsInformationMap" type="com.yuanchu.limslaboratory.vo.ListSpecificationsInformation"> |
| | | <result property="id" column="id"/> |
| | | <result property="name" column="name"/> |
| | | <result property="updateTime" column="update_time"/> |
| | | <result property="username" column="username"/> |
| | | <result property="vel" column="vel"/> |
| | | <result property="spe_state" column="spe_state"/> |
| | | </resultMap> |
| | | |
| | | <select id="listSpecificationsInformation" resultMap="listSpecificationsInformationMap"> |
| | | SELECT s.`id`,s.`name`,s.`update_time`,u.`name` username,s.`vel`,s.`spe_state` |
| | | FROM specifications s,`user` u |
| | | WHERE s.`user_id` = u.`id` |
| | | AND s.`serial_id` = #{serialNumberId} |
| | | <if test="specificationsName != null"> |
| | | AND s.`name` = #{specificationsName} |
| | | </if> |
| | | </select> |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.yuanchu.limslaboratory.mapper.StandardsMapper"> |
| | | |
| | | <select id="listStandardsInformation" resultType="Map"> |
| | | SELECT s.`id`, s.`name`, s.`eng_name`, DATE_FORMAT(s.`create_time`, '%Y-%m-%d %H:%i') createTime |
| | | FROM standards s |
| | | <if test="idOrNameOfStandards != null"> |
| | | WHERE s.`id` LIKE concat('%',#{idOrNameOfStandards},'%') |
| | | OR s.name LIKE concat('%',#{idOrNameOfStandards},'%') |
| | | </if> |
| | | </select> |
| | | </mapper> |
| | |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <!--ç¨æ·æå¡--> |
| | | <!--ç¨æ·æå¡æ¨¡å--> |
| | | <dependency> |
| | | <groupId>com.yunchu.limslaboratory</groupId> |
| | | <artifactId>user-server</artifactId> |
| | | <version>${project.parent.version}</version> |
| | | </dependency> |
| | | |
| | | <!--æ ååºæ¨¡å--> |
| | | <dependency> |
| | | <groupId>com.yunchu.limslaboratory</groupId> |
| | | <artifactId>standard-library</artifactId> |
| | | <version>${project.parent.version}</version> |
| | | </dependency> |
| | | |
| | | <!--åºç¡æ¡æ¶ç±»--> |
| | | <dependency> |
| | | <groupId>com.yunchu.limslaboratory</groupId> |
| | |
| | | filters: stat,wall,log4j # é
ç½®çæ§ç»è®¡æ¦æªçfiltersï¼å»æåçæ§çé¢sqlæ æ³ç»è®¡ï¼'wall'ç¨äºé²ç«å¢ |
| | | useGlobalDataSourceStat: true #åå¹¶å¤ä¸ªDruidDatasourceççæ§æ°æ® |
| | | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500; #éè¿connectProperties屿§æ¥æå¼mergesqlåè½ç½æ
¢sQLè®°å½ |
| | | |
| | | |
| | | redis: |
| | | # redisæ°æ®åºç´¢å¼(é»è®¤ä¸º0)ï¼æä»¬ä½¿ç¨ç´¢å¼ä¸º3çæ°æ®åºï¼é¿å
åå
¶ä»æ°æ®åºå²çª |
| | | database: 0 |
| | | # redisæå¡å¨å°åï¼é»è®¤ä¸ºloaclhostï¼ |
| | | host: 127.0.0.1 |
| | | # redis端å£ï¼é»è®¤ä¸º6379ï¼ |
| | | port: 6379 |
| | | # redis访é®å¯ç ï¼é»è®¤ä¸ºç©ºï¼ |
| | | # password: |
| | | # redisè¿æ¥è¶
æ¶æ¶é´ï¼å使¯«ç§ï¼ |
| | | timeout: 0 |
| | | # redisè¿æ¥æ± é
ç½® |
| | | pool: |
| | | # æå¤§å¯ç¨è¿æ¥æ°ï¼é»è®¤ä¸º8ï¼è´æ°è¡¨ç¤ºæ éï¼ |
| | | max-active: 8 |
| | | # æå¤§ç©ºé²è¿æ¥æ°ï¼é»è®¤ä¸º8ï¼è´æ°è¡¨ç¤ºæ éï¼ |
| | | max-idle: 8 |
| | | # æå°ç©ºé²è¿æ¥æ°ï¼é»è®¤ä¸º0ï¼è¯¥å¼åªæä¸ºæ£æ°ææç¨ï¼ |
| | | min-idle: 0 |
| | | # ä»è¿æ¥æ± ä¸è·åè¿æ¥æå¤§çå¾
æ¶é´ï¼é»è®¤ä¸º-1ï¼åä½ä¸ºæ¯«ç§ï¼è´æ°è¡¨ç¤ºæ éï¼ |
| | | max-wait: -1 |
| | | redis: |
| | | # redisæ°æ®åºç´¢å¼(é»è®¤ä¸º0)ï¼æä»¬ä½¿ç¨ç´¢å¼ä¸º3çæ°æ®åºï¼é¿å
åå
¶ä»æ°æ®åºå²çª |
| | | database: 0 |
| | | # redisæå¡å¨å°åï¼é»è®¤ä¸ºlocalhostï¼ |
| | | host: localhost |
| | | # redis端å£ï¼é»è®¤ä¸º6379ï¼ |
| | | port: 6380 |
| | | # redis访é®å¯ç ï¼é»è®¤ä¸ºç©ºï¼ |
| | | password: null |
| | | # redisè¿æ¥è¶
æ¶æ¶é´ï¼å使¯«ç§ï¼ |
| | | timeout: 0 |
| | | # redisè¿æ¥æ± é
ç½® |
| | | pool: |
| | | # æå¤§å¯ç¨è¿æ¥æ°ï¼é»è®¤ä¸º8ï¼è´æ°è¡¨ç¤ºæ éï¼ |
| | | max-active: 8 |
| | | # æå¤§ç©ºé²è¿æ¥æ°ï¼é»è®¤ä¸º8ï¼è´æ°è¡¨ç¤ºæ éï¼ |
| | | max-idle: 8 |
| | | # æå°ç©ºé²è¿æ¥æ°ï¼é»è®¤ä¸º0ï¼è¯¥å¼åªæä¸ºæ£æ°ææç¨ï¼ |
| | | min-idle: 0 |
| | | # ä»è¿æ¥æ± ä¸è·åè¿æ¥æå¤§çå¾
æ¶é´ï¼é»è®¤ä¸º-1ï¼åä½ä¸ºæ¯«ç§ï¼è´æ°è¡¨ç¤ºæ éï¼ |
| | | max-wait: -1 |
| | | |
| | |
| | | active: dev |
| | | |
| | | login: |
| | | userID: 9c08241a7c38cb25efafde9dd1347bab |
| | | secret: D1E3ED958C5DB5BDF1FC9F77CE54B29B016213acd698f4686cac2f399f1c8d18 |
| | | userID: c8b1aaacec366c24e5d18c7eea9e551b |
| | | secret: 701C85FCE0F7CFD714C2052D77098DC7f407b0ee79210bcef51787a0eb8ec7a5 |
| | | |
| | | mybatis-plus: |
| | | type-aliases-package: com.yuanchu.limslaboratory.pojo |
| | | mapper-locations: classpath:mapper/*.xml |
| | | mapper-locations: classpath*:/mapper/*.xml |
| | | global-config: |
| | | banner: off # å
³émybatis-pluså¯å¨å¾æ |
| | | |
| | |
| | | httpclient: |
| | | enabled: false # å
³é httpclient |
| | | okhttp: |
| | | enabled: true # å¼å¯ okhttp |
| | | enabled: true # å¼å¯ okhttp |
| | |
| | | public static String database_username = "root"; |
| | | public static String database_password= "123456"; |
| | | public static String author = "æ±èéµ·éç½ç»ç§ææéå
¬å¸"; |
| | | public static String model_name = "/user-server"; // å¦æä¸ºåå¸å¼å¡«å模ååç§°ï¼å¦æä¸æ¯åå¸å¼ä¸ºç©ºå³å¯ |
| | | public static String model_name = "/standard-library"; // å¦æä¸ºåå¸å¼å¡«å模ååç§°ï¼å¦æä¸æ¯åå¸å¼ä¸ºç©ºå³å¯ |
| | | public static String setParent = "com.yuanchu.limslaboratory"; // å
è·¯å¾ |
| | | public static Boolean Override = false; // æ¯å¦è¦ç忥çæä»¶ï¼ |
| | | |
| | |
| | | .setColumnNaming(NamingStrategy.underline_to_camel) |
| | | .setEntityLombokModel(true) |
| | | .setRestControllerStyle(true) |
| | | .setInclude(scanner("表åï¼å¤ä¸ªç©ºæ ¼åå²").split(",")) |
| | | .setInclude(scanner("表åï¼å¤ä¸ªéå·åå²").split(",")) |
| | | .setControllerMappingHyphenStyle(true) |
| | | .setTablePrefix("m_"); |
| | | mpg.setStrategy(strategy); |
| | |
| | | <packaging>jar</packaging> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-test</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.yunchu.limslaboratory</groupId> |
| | | <artifactId>framework</artifactId> |
| | | <version>${project.parent.version}</version> |
| | |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.User; |
| | | import com.yuanchu.limslaboratory.shiro.utils.JwtUtils; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | @Value("${login.secret}") |
| | | private String LoginSecret; |
| | | |
| | | // public Result<Map<String, Object>> LoginExamine(User user){ |
| | | // Map<String, Object> mapData = new HashMap<>(); |
| | | // mapData.put("LoginUserID", LoginUserID); |
| | | // mapData.put("LoginSecret", LoginSecret); |
| | | // Result<?> code = userClient.BusynessUserLogin(mapData); |
| | | // if (code.getCode() == 200){ |
| | | // Result<?> result = userClient.BusynessUserLoginToken(code.getData().toString()); |
| | | // if (result.getCode() == 200){ |
| | | // Map data = (Map) result.getData(); |
| | | // String token = data.get("token").toString(); |
| | | // data.remove("token"); |
| | | //// user.setMap(data); |
| | | // //åå
¥redis,äºä¸ªå°æ¶åå é¤ |
| | | // RedisUtil.set(token, user, 2); |
| | | // // å°ç¾åç JWT token è¿åç»å端 |
| | | // HashMap<String, Object> map = new HashMap<>(); |
| | | // String refresh = JwtUtils.sign(user.getAccount()); |
| | | // map.put("token", token); |
| | | // map.put("refresh", refresh); |
| | | // RedisUtil.set(user.getAccount(), map, 168); |
| | | // return Result.success(map); |
| | | // } else { |
| | | // return Result.fail(result.getMessage()); |
| | | // } |
| | | // } else { |
| | | // return Result.fail(code.getMessage()); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | public Result<Map<String, Object>> LoginExamine(User user){ |
| | | String token = JwtUtils.sign(user.getAccount()); |
| | | //åå
¥redis,äºä¸ªå°æ¶åå é¤ |
| | | RedisUtil.set(token, user, 2); |
| | | // å°ç¾åç JWT token è¿åç»å端 |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | String refresh = JwtUtils.sign(user.getAccount()); |
| | | map.put("token", token); |
| | | map.put("refresh", refresh); |
| | | RedisUtil.set(user.getAccount(), map, 120); |
| | | return Result.success(map); |
| | | Map<String, Object> mapData = new HashMap<>(); |
| | | mapData.put("LoginUserID", LoginUserID); |
| | | mapData.put("LoginSecret", LoginSecret); |
| | | Result<?> code = userClient.BusynessUserLogin(mapData); |
| | | if (code.getCode() == 200){ |
| | | Result<?> result = userClient.BusynessUserLoginToken(code.getData().toString()); |
| | | if (result.getCode() == 200){ |
| | | Map data = (Map) result.getData(); |
| | | String token = data.get("token").toString(); |
| | | data.remove("token"); |
| | | HashMap<String, Object> mapRedis = new HashMap<>(); |
| | | mapRedis.put("id", user.getId()); |
| | | mapRedis.put("account", user.getAccount()); |
| | | mapRedis.put("name", user.getName()); |
| | | mapRedis.put("data", data); |
| | | //åå
¥redis,äºä¸ªå°æ¶åå é¤ |
| | | RedisUtil.set(token, mapRedis, 120); |
| | | // å°ç¾åç JWT token è¿åç»å端 |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | String refresh = JwtUtils.sign(user.getAccount()); |
| | | map.put("token", token); |
| | | map.put("refresh", refresh); |
| | | RedisUtil.set(user.getAccount(), map, 168); |
| | | return Result.success(map); |
| | | } else { |
| | | return Result.fail(result.getMessage()); |
| | | } |
| | | } else { |
| | | return Result.fail(code.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | // public Result<Map<String, Object>> LoginExamine(User user){ |
| | | // String token = JwtUtils.sign(user.getAccount()); |
| | | // //åå
¥redis,äºä¸ªå°æ¶åå é¤ |
| | | // RedisUtil.set(token, user, 2); |
| | | // // å°ç¾åç JWT token è¿åç»å端 |
| | | // HashMap<String, Object> map = new HashMap<>(); |
| | | // String refresh = JwtUtils.sign(user.getAccount()); |
| | | // map.put("token", token); |
| | | // map.put("refresh", refresh); |
| | | // RedisUtil.set(user.getAccount(), map, 120); |
| | | // return Result.success(map); |
| | | // } |
| | | } |
| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.clients.UserLoginUtils; |
| | | import com.yuanchu.limslaboratory.pojo.Enterprise; |
| | | import com.yuanchu.limslaboratory.pojo.User; |
| | | import com.yuanchu.limslaboratory.service.UserService; |
| | | import com.yuanchu.limslaboratory.shiro.realm.ShiroRealm; |
| | | import com.yuanchu.limslaboratory.utils.SpringUtils; |
| | | import com.yuanchu.limslaboratory.utils.SpringUtil; |
| | | import com.yuanchu.limslaboratory.vo.NewPersonnelVo; |
| | | import com.yuanchu.limslaboratory.vo.PagePersonnelVo; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import com.yuanchu.limslaboratory.vo.UpdatePersonnelVo; |
| | | import io.swagger.annotations.*; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.apache.shiro.authc.IncorrectCredentialsException; |
| | |
| | | import org.apache.shiro.authc.UsernamePasswordToken; |
| | | import org.apache.shiro.subject.Subject; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @ApiImplicitParam(name = "password", value = "å¯ç ", dataTypeClass = String.class, required = true) |
| | | }) |
| | | @PostMapping("/login") |
| | | public Result<?> UserLogin(String account, String password){ |
| | | public Result<?> userLogin(String account, String password){ |
| | | boolean loginSuccess = false; |
| | | Subject subject = SecurityUtils.getSubject(); |
| | | if (!subject.isAuthenticated()) { |
| | |
| | | } |
| | | if (loginSuccess) { |
| | | // è·åshiroRealmä¸çæ°æ® |
| | | ShiroRealm bean = SpringUtils.getBean(ShiroRealm.class); |
| | | ShiroRealm bean = SpringUtil.getBean(ShiroRealm.class); |
| | | User user = bean.user; |
| | | user.setPassword(null); |
| | | UserLoginUtils bean1 = SpringUtils.getBean(UserLoginUtils.class); |
| | | UserLoginUtils bean1 = SpringUtil.getBean(UserLoginUtils.class); |
| | | return bean1.LoginExamine(user); |
| | | }else { |
| | | return Result.fail("ç»å½å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation("ç»å½-->è·åç¨æ·ä¿¡æ¯") |
| | | @GetMapping("/info") |
| | | public Result<?> getUserInfo(@RequestHeader("X-Token") String token){ |
| | | //æ ¹æ®tokenè·åç¨æ·ä¿¡æ¯ |
| | | Map<String,Object> data = userService.getUserInfo(token); |
| | | if (data != null){ |
| | | return Result.success(data); |
| | | } |
| | | return Result.fail(202,"ç¨æ·ç»å½ä¿¡æ¯æ æï¼è¯·éæ°ç»å½"); |
| | | } |
| | | |
| | | @PostMapping("/getUserById") |
| | |
| | | } catch (Exception e) { |
| | | return Result.fail("ç¨æ·id为空!"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @PostMapping("/add_new_personnel") |
| | | @ApiOperation("å®éªå®¤ç®¡ç-->人å管ç-->æ°å¢äººå") |
| | | public Result<?> addNewPersonnel(@RequestBody NewPersonnelVo newPersonnelVo) { |
| | | newPersonnelVo.setPassword("123456"); |
| | | Integer isAddSuccess = userService.addNewPersonnel(newPersonnelVo); |
| | | if (isAddSuccess == 1){ |
| | | return Result.success("æ·»å ã" + newPersonnelVo.getName() + "ãæåï¼é»è®¤å¯ç 为ï¼" + newPersonnelVo.getPassword()); |
| | | } |
| | | return Result.fail("æ·»å 失败ï¼"); |
| | | } |
| | | |
| | | @PutMapping("/update_new_personnel") |
| | | @ApiOperation("å®éªå®¤ç®¡ç-->人å管ç-->ç¼è¾æä½") |
| | | public Result<?> updateNewPersonnel(@RequestBody UpdatePersonnelVo updatePersonnelVo) { |
| | | Integer isUpdateSuccess = userService.updateNewPersonnel(updatePersonnelVo); |
| | | if (isUpdateSuccess == 1){ |
| | | return Result.success("æ´æ°ã" + updatePersonnelVo.getName() + "ãæå"); |
| | | } |
| | | return Result.fail("æ´æ°ã" + updatePersonnelVo.getName() + "ã失败"); |
| | | } |
| | | |
| | | @GetMapping("/list_new_personnel") |
| | | @ApiOperation("å®éªå®¤ç®¡ç-->人å管ç-->å页æ¥è¯¢") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageNo", value = "èµ·å§é¡µ", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "æ¯ä¸é¡µæ°é", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "name", value = "人ååç§°", dataTypeClass = String.class) |
| | | }) |
| | | public Result<Map<String, Object>> getNewPersonnelPage(Integer pageNo, Integer pageSize, String name) { |
| | | IPage<PagePersonnelVo> PageList = userService.getNewPersonnelPage(name, new Page<Objects>(pageNo, pageSize)); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("row", PageList.getRecords()); |
| | | map.put("total", PageList.getTotal()); |
| | | return Result.success(map); |
| | | } |
| | | } |
| | |
| | | package com.yuanchu.limslaboratory.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.pojo.User; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.yuanchu.limslaboratory.vo.PagePersonnelVo; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface UserMapper extends BaseMapper<User> { |
| | | Map<String, String> selectUserByUserId(int userId); |
| | | |
| | | IPage<PagePersonnelVo> getNewPersonnelPage(String name, Page page); |
| | | } |
| | |
| | | package com.yuanchu.limslaboratory.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone="GMT+8") |
| | | private Date updateTime; |
| | | |
| | | @Version |
| | | @ApiModelProperty(value = "é") |
| | | private Integer version; |
| | | |
| | |
| | | package com.yuanchu.limslaboratory.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | |
| | | @ApiModelProperty(value = "ç¨æ·id") |
| | | private Integer userId; |
| | | |
| | | @ApiModelProperty(value = "0:å é¤;1:æ£å¸¸") |
| | | @TableLogic(value = "1", delval = "0") |
| | | @ApiModelProperty(value = "é»è¾å é¤ æ£å¸¸>=1,å é¤<=0") |
| | | private Integer state; |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone="GMT+8") |
| | | private Date updateTime; |
| | | |
| | | @Version |
| | | private Integer version; |
| | | |
| | | |
| | |
| | | package com.yuanchu.limslaboratory.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | |
| | | @ApiModelProperty(value = "0ï¼æ æéï¼1ï¼ææé") |
| | | private Integer power; |
| | | |
| | | @TableLogic(value = "1", delval = "0") |
| | | @ApiModelProperty(value = "é»è¾å é¤ æ£å¸¸>=1,å é¤<=0") |
| | | private Integer state; |
| | | |
| | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone="GMT+8") |
| | | private Date updateTime; |
| | | |
| | | @Version |
| | | @ApiModelProperty(value = "ä¹è§é") |
| | | private Integer version; |
| | | |
| | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.sun.jmx.snmp.Timestamp; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-07 |
| | | */ |
| | | @Accessors(chain = true) |
| | | @Data |
| | | @NoArgsConstructor |
| | | @EqualsAndHashCode(callSuper = false) |
| | |
| | | @ApiModelProperty(value = "å¹´é¾") |
| | | private Integer age; |
| | | |
| | | @TableLogic(value = "1", delval = "0") |
| | | @ApiModelProperty(value = "å¨èç¶æ æ£å¸¸>=1,离è<=0") |
| | | private Integer jobState; |
| | | |
| | | @ApiModelProperty(value = "个æ§ç¾å") |
| | | private String info; |
| | | |
| | | @ApiModelProperty(value = "å¨èç¶æ æ£å¸¸>=1,离è<=0") |
| | | private Integer jobState; |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone="GMT+8") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date createTime; |
| | | |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone="GMT+8") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date updateTime; |
| | | |
| | | @Version |
| | | private Integer version; |
| | | |
| | | @ApiModelProperty(value = "å
³è è§è²id") |
| | |
| | | package com.yuanchu.limslaboratory.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.pojo.User; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.yuanchu.limslaboratory.vo.NewPersonnelVo; |
| | | import com.yuanchu.limslaboratory.vo.PagePersonnelVo; |
| | | import com.yuanchu.limslaboratory.vo.UpdatePersonnelVo; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | Map<String, String> selectUserByUserId(int userId); |
| | | |
| | | User AccordingUsernameSelectAll(String account); |
| | | |
| | | Integer addNewPersonnel(NewPersonnelVo newPersonnelVo); |
| | | |
| | | Integer updateNewPersonnel(UpdatePersonnelVo updatePersonnelVo); |
| | | |
| | | IPage<PagePersonnelVo> getNewPersonnelPage(String name, Page page); |
| | | |
| | | Map<String, Object> getUserInfo(String token); |
| | | |
| | | /** |
| | | * æ ¹æ®Idæ¥è¯¢æ¯å¦åå¨è¯¥ç¨æ· |
| | | */ |
| | | Boolean userIsNull(Integer Id); |
| | | } |
| | |
| | | package com.yuanchu.limslaboratory.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.pojo.User; |
| | | import com.yuanchu.limslaboratory.mapper.UserMapper; |
| | | import com.yuanchu.limslaboratory.service.UserService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Repository; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.NewPersonnelVo; |
| | | import com.yuanchu.limslaboratory.vo.PagePersonnelVo; |
| | | import com.yuanchu.limslaboratory.vo.UpdatePersonnelVo; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService { |
| | | |
| | | @Resource |
| | | UserMapper userMapper; |
| | | private UserMapper userMapper; |
| | | |
| | | @Override |
| | | public Map<String, Object> getUserInfo(String token) { |
| | | //æ ¹æ®tokenè·åç¨æ·ä¿¡æ¯ |
| | | Object obj = RedisUtil.get(token); |
| | | if (!ObjectUtils.isEmpty(obj)){ |
| | | Map loginUser = (Map) obj; |
| | | Map map = (Map)loginUser.get("data"); |
| | | Object residualTime = map.get("residualTime"); |
| | | int i = Integer.parseInt(residualTime.toString()); |
| | | String remind = null; |
| | | if (i <= 30) { |
| | | remind = "æ¨æä½¿ç¨çç³»ç»å³å°è¿æï¼è¯·è系管çåï¼"; |
| | | } |
| | | Map<String, Object> data = new HashMap<>(); |
| | | data.put("name",loginUser.get("name")); |
| | | data.put("remind", remind); |
| | | return data; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean userIsNull(Integer Id) { |
| | | LambdaQueryWrapper<User> userLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | userLambdaQueryWrapper.eq(User::getId, Id); |
| | | userLambdaQueryWrapper.select(User::getName); |
| | | User user = userMapper.selectOne(userLambdaQueryWrapper); |
| | | return !ObjectUtils.isEmpty(user); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, String> selectUserByUserId(int userId) { |
| | | return userMapper.selectUserByUserId(userId); |
| | | } |
| | | @Resource |
| | | private UserMapper mapper; |
| | | |
| | | @Override |
| | | public User AccordingUsernameSelectAll(String account) { |
| | | LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(User::getAccount, account); |
| | | return mapper.selectOne(wrapper); |
| | | wrapper.select(User::getPassword, User::getId, User::getName, User::getAccount); |
| | | return userMapper.selectOne(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public Integer addNewPersonnel(NewPersonnelVo newPersonnelVo) { |
| | | User user = new User() |
| | | .setName(newPersonnelVo.getName()) |
| | | .setAccount(newPersonnelVo.getAccount()) |
| | | .setAge(newPersonnelVo.getAge()) |
| | | .setPhone(newPersonnelVo.getPhone()) |
| | | .setEmail(newPersonnelVo.getEmail()) |
| | | .setRoleId(newPersonnelVo.getRole_id()) |
| | | .setPassword(newPersonnelVo.getPassword()); |
| | | return userMapper.insert(user); |
| | | } |
| | | |
| | | @Override |
| | | public Integer updateNewPersonnel(UpdatePersonnelVo updatePersonnelVo) { |
| | | User user = new User() |
| | | .setName(updatePersonnelVo.getName()) |
| | | .setAccount(updatePersonnelVo.getAccount()) |
| | | .setAge(updatePersonnelVo.getAge()) |
| | | .setPhone(updatePersonnelVo.getPhone()) |
| | | .setEmail(updatePersonnelVo.getEmail()) |
| | | .setRoleId(updatePersonnelVo.getRole_id()) |
| | | .setPassword(updatePersonnelVo.getPassword()) |
| | | .setJobState(updatePersonnelVo.getJobState()); |
| | | LambdaUpdateWrapper<User> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(User::getId, updatePersonnelVo.getId()); |
| | | return userMapper.update(user, updateWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<PagePersonnelVo> getNewPersonnelPage(String name, Page page) { |
| | | return userMapper.getNewPersonnelPage(name, page); |
| | | } |
| | | } |
| | |
| | | return securityManager; |
| | | } |
| | | |
| | | // å建èªå®ä¹Realm |
| | | // å建èªå®ä¹Realm |
| | | @Bean |
| | | public Realm shiroRealm() { |
| | | return new ShiroRealm(); |
| | | ShiroRealm realm = new ShiroRealm(); |
| | | // HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(); |
| | | //// //设置使ç¨MD5å å¯ç®æ³ |
| | | //// credentialsMatcher.setHashAlgorithmName(Md5Hash.ALGORITHM_NAME); |
| | | //// //æ£åæ¬¡æ° |
| | | //// credentialsMatcher.setHashIterations(1024); |
| | | // realm.setCredentialsMatcher(credentialsMatcher); |
| | | return realm; |
| | | } |
| | | |
| | | @Bean |
| | | public Realm JwtRealm(){ |
| | | return new JwtRealm(); |
| | | JwtRealm jwtRealm = new JwtRealm(); |
| | | // 设置å å¯ç®æ³ |
| | | CredentialsMatcher credentialsMatcher = new JwtCredentialsMatcher(); |
| | | // 设置å 坿¬¡æ° |
| | | jwtRealm.setCredentialsMatcher(credentialsMatcher); |
| | | return jwtRealm; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.User; |
| | | import com.yuanchu.limslaboratory.shiro.JwtToken; |
| | | import com.yuanchu.limslaboratory.shiro.utils.JwtCredentialsMatcher; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import org.apache.shiro.authc.*; |
| | | import org.apache.shiro.authc.credential.CredentialsMatcher; |
| | | import org.apache.shiro.authz.AuthorizationInfo; |
| | | import org.apache.shiro.authz.SimpleAuthorizationInfo; |
| | | import org.apache.shiro.realm.AuthorizingRealm; |
| | |
| | | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { |
| | | SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); |
| | | return info; |
| | | } |
| | | |
| | | @Override |
| | | public void setCredentialsMatcher(CredentialsMatcher credentialsMatcher) { |
| | | // 设置å å¯ç®æ³ |
| | | CredentialsMatcher jwtCredentialsMatcher = new JwtCredentialsMatcher(); |
| | | super.setCredentialsMatcher(jwtCredentialsMatcher); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.User; |
| | | import com.yuanchu.limslaboratory.service.UserService; |
| | | import com.yuanchu.limslaboratory.utils.MyUtils; |
| | | import com.yuanchu.limslaboratory.utils.SpringUtils; |
| | | import com.yuanchu.limslaboratory.utils.SpringUtil; |
| | | import org.apache.shiro.authc.*; |
| | | import org.apache.shiro.authc.credential.CredentialsMatcher; |
| | | import org.apache.shiro.authz.AuthorizationInfo; |
| | | import org.apache.shiro.realm.AuthorizingRealm; |
| | | import org.apache.shiro.subject.PrincipalCollection; |
| | |
| | | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) { |
| | | String principal = (String) authenticationToken.getPrincipal(); |
| | | //è·åUserService对象 |
| | | UserService userService = SpringUtils.getBean(UserService.class); |
| | | UserService userService = SpringUtil.getBean(UserService.class); |
| | | user = userService.AccordingUsernameSelectAll(principal); |
| | | MyUtils.PrintLog(user.toString()); |
| | | if (!ObjectUtils.isEmpty(user)) { |
| | | return new SimpleAuthenticationInfo(user.getAccount(), user.getPassword(), this.getName()); |
| | | } else { |
| | | throw new UnknownAccountException(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void setCredentialsMatcher(CredentialsMatcher credentialsMatcher) { |
| | | // HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher(); |
| | | // //设置使ç¨MD5å å¯ç®æ³ |
| | | // hashedCredentialsMatcher.setHashAlgorithmName(Md5Hash.ALGORITHM_NAME); |
| | | // //æ£åæ¬¡æ° |
| | | // hashedCredentialsMatcher.setHashIterations(1024); |
| | | // super.setCredentialsMatcher(hashedCredentialsMatcher); |
| | | super.setCredentialsMatcher(credentialsMatcher); |
| | | } |
| | | } |
| | |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.Map; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value="NewPersonnelVo对象", description="ç¨äºå¯¹è§è²ç®¡ççæ·»å ") |
| | | public class NewPersonnelVo { |
| | | |
| | | @ApiModelProperty(value = "å§å", example = "å°é»", required = true) |
| | | private String name; |
| | | |
| | | @ApiModelProperty(value = "è´¦å·", example = "45612345", required = true) |
| | | private String account; |
| | | |
| | | @ApiModelProperty(value = "0ï¼æ æéï¼1ï¼ææé", example = "1", required = true) |
| | | private Integer role_id; |
| | | |
| | | @ApiModelProperty(value = "å¹´é¾", example = "23") |
| | | private Integer age; |
| | | |
| | | @ApiModelProperty(value = "å¹´é¾", example = "23", hidden = true) |
| | | private String password; |
| | | |
| | | @ApiModelProperty(value = "ææºå·", example = "12345678981") |
| | | private String phone; |
| | | |
| | | @ApiModelProperty(value = "é®ç®±", example = "12345678@qq.com") |
| | | private String email; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value="UpdatePersonnelVo对象", description="ç¨äºå¯¹è§è²ç®¡ççæ´æ°") |
| | | public class PagePersonnelVo { |
| | | |
| | | @ApiModelProperty(value = "主é®ID", example = "1", required = true) |
| | | private String id; |
| | | |
| | | @ApiModelProperty(value = "å§å", example = "å°é»", required = true) |
| | | private String username; |
| | | |
| | | @ApiModelProperty(value = "è§è²æé", example = "å°é»", required = true) |
| | | private String roleName; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value = "å¹´é¾", example = "23") |
| | | private Integer age; |
| | | |
| | | @ApiModelProperty(value = "ææºå·", example = "12345678981") |
| | | private String phone; |
| | | |
| | | @ApiModelProperty(value = "é®ç®±", example = "12345678@qq.com") |
| | | private String email; |
| | | |
| | | @ApiModelProperty(value = "å¨èç¶æ æ£å¸¸>=1,离è<=0", example = "0") |
| | | private Integer jobState; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value="UpdatePersonnelVo对象", description="ç¨äºå¯¹è§è²ç®¡ççæ´æ°") |
| | | public class UpdatePersonnelVo { |
| | | |
| | | @ApiModelProperty(value = "主é®ID", example = "1", required = true) |
| | | private String id; |
| | | |
| | | @ApiModelProperty(value = "å§å", example = "å°é»", required = true) |
| | | private String name; |
| | | |
| | | @ApiModelProperty(value = "è´¦å·", example = "45612345", required = true) |
| | | private String account; |
| | | |
| | | @ApiModelProperty(value = "0ï¼æ æéï¼1ï¼ææé", example = "1", required = true) |
| | | private Integer role_id; |
| | | |
| | | @ApiModelProperty(value = "å¹´é¾", example = "23") |
| | | private Integer age; |
| | | |
| | | @ApiModelProperty(value = "ææºå·", example = "12345678981") |
| | | private String phone; |
| | | |
| | | @ApiModelProperty(value = "é®ç®±", example = "12345678@qq.com") |
| | | private String email; |
| | | |
| | | @ApiModelProperty(value = "å¨èç¶æ æ£å¸¸>=1,离è<=0", example = "0") |
| | | private Integer jobState; |
| | | |
| | | @ApiModelProperty(value = "è´¦å·å¯ç ", example = "654321") |
| | | private String password; |
| | | |
| | | |
| | | } |
| | |
| | | and el.user_id = u.id |
| | | and u.id = #{userId} |
| | | </select> |
| | | |
| | | <resultMap id="PagePersonnelVoMap" type="com.yuanchu.limslaboratory.vo.PagePersonnelVo"> |
| | | <result property="id" column="id"/> |
| | | <result property="username" column="username"/> |
| | | <result property="roleName" column="roleName"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="age" column="age"/> |
| | | <result property="phone" column="phone"/> |
| | | <result property="email" column="email"/> |
| | | <result property="jobState" column="job_state"/> |
| | | </resultMap> |
| | | <select id="getNewPersonnelPage" resultMap="PagePersonnelVoMap"> |
| | | SELECT u.`id`, u.`name` username, r.`name` roleName, u.`create_time`, IFNULL(u.`age`, '---') age, |
| | | IFNULL(u.`phone`, '---') phone, IFNULL(u.`email`, '---') email, u.`job_state` |
| | | FROM `user` u, role r |
| | | WHERE u.`role_id` = r.`id` |
| | | <if test="name != null"> |
| | | AND u.name = #{name} |
| | | </if> |
| | | </select> |
| | | </mapper> |