¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.smartearth.poiexcel.controller; |
| | | |
| | | import com.smartearth.poiexcel.entity.HttpStatus; |
| | | import com.smartearth.poiexcel.entity.ResponseMsg; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | |
| | | /** |
| | | * Controlleråºç±» |
| | | * @author WWW |
| | | */ |
| | | public class BaseController { |
| | | public Log log = LogFactory.getLog(getClass()); |
| | | |
| | | public <T> ResponseMsg<T> success(T result) { |
| | | return new ResponseMsg<T>(HttpStatus.OK, result); |
| | | } |
| | | |
| | | public <T> ResponseMsg<T> success(String msg, T result) { |
| | | return new ResponseMsg<T>(HttpStatus.OK, msg, result); |
| | | } |
| | | |
| | | public <T> ResponseMsg<T> success(long count, T result) { |
| | | return new ResponseMsg<T>(HttpStatus.OK, count, result); |
| | | } |
| | | |
| | | public <T> ResponseMsg<T> success(String msg, long count, T result) { |
| | | return new ResponseMsg<T>(HttpStatus.OK, msg, count, result); |
| | | } |
| | | |
| | | public <T> ResponseMsg<T> fail(T result) { |
| | | return new ResponseMsg<T>(HttpStatus.ERROR, result); |
| | | } |
| | | |
| | | public <T> ResponseMsg<T> fail(String msg, T result) { |
| | | return new ResponseMsg<T>(HttpStatus.ERROR, msg, result); |
| | | } |
| | | |
| | | public <T> ResponseMsg<T> fail(Exception ex, T result) { |
| | | log.error(ex.getMessage(), ex); |
| | | |
| | | return new ResponseMsg<T>(HttpStatus.ERROR, ex.getMessage(), result); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.smartearth.poiexcel.controller; |
| | | |
| | | import com.smartearth.poiexcel.entity.ResponseMsg; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * ä¼ä¸æ§å¶å¨ |
| | | * @author WWW |
| | | * @date 2023-10-05 |
| | | */ |
| | | @Api(tags = "ä¼ä¸æ§å¶å¨") |
| | | @RestController |
| | | @RequestMapping("/ent") |
| | | public class EntController extends BaseController { |
| | | @ApiOperation(value = "æ¥è¯¢è®°å½æ°") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "åç§°", dataType = "String", paramType = "query", required = false, example = "") |
| | | }) |
| | | @GetMapping({"/selectCount"}) |
| | | public ResponseMsg<Integer> selectCount(String name) { |
| | | try { |
| | | |
| | | |
| | | return success(0); |
| | | } catch (Exception ex) { |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.smartearth.poiexcel.entity; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * ä¼ä¸å®ä½ç±» |
| | | * @author WWW |
| | | * @date 2023-10-05 |
| | | */ |
| | | public class EntEntity implements Serializable { |
| | | private static final long serialVersionUID = -8624235184539814990L; |
| | | |
| | | public EntEntity() { |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.smartearth.poiexcel.entity; |
| | | |
| | | /** |
| | | * Httpç¶æç ç±» |
| | | * @author WWW |
| | | * @date 2023-10-05 |
| | | */ |
| | | public enum HttpStatus { |
| | | /** |
| | | * è¯·æ±æå |
| | | */ |
| | | OK(200, "è¯·æ±æå"), |
| | | |
| | | /** |
| | | * è¯·æ±æ æ |
| | | */ |
| | | BAD_REQUEST(400, "è¯·æ±æ æ"), |
| | | |
| | | /** |
| | | * æªç»ææè®¿é® |
| | | */ |
| | | UNAUTHORIZED(401, "æªç»ææè®¿é®"), |
| | | |
| | | /** |
| | | * æå¡è¯·æ±æªæ¾å° |
| | | */ |
| | | NOT_FOUND(404, "æå¡è¯·æ±æªæ¾å°"), |
| | | |
| | | /** |
| | | * ç³»ç»é误 |
| | | */ |
| | | ERROR(500, "ç³»ç»é误"), |
| | | |
| | | /** |
| | | * åå¨éå¤çæ°æ® |
| | | */ |
| | | UNIQUE_ERROR(500100, "åå¨éå¤çæ°æ®"), |
| | | |
| | | /** |
| | | * åæ°æ ¡éªé误 |
| | | */ |
| | | VALIDATE_ERROR(500101, "åæ°æ ¡éªé误"), |
| | | |
| | | /** |
| | | * tokené误 |
| | | */ |
| | | TOKEN_ERROR(500102, "tokené误"), |
| | | |
| | | /** |
| | | * ç¨æ·æªç»é |
| | | */ |
| | | NO_LOGIN_ERROR(500104, "ç¨æ·æªç»é"), |
| | | |
| | | /** |
| | | * ç»é失败 |
| | | */ |
| | | LOGIN_ERROR(500105, "ç»é失败"), |
| | | |
| | | /** |
| | | * æ æéè®¿é® |
| | | */ |
| | | NO_AUTH_ERROR(500106, "æ æé访é®"), |
| | | |
| | | /** |
| | | * ç¨æ·åé误 |
| | | */ |
| | | LOGIN_USER_ERROR(500107, "ç¨æ·åé误"), |
| | | |
| | | /** |
| | | * å¯ç é误 |
| | | */ |
| | | LOGIN_PWD_ERROR(500108, "å¯ç é误"), |
| | | |
| | | /** |
| | | * ç¨æ·è¢«éå® |
| | | */ |
| | | USER_LOCK_ERROR(500109, "ç¨æ·è¢«éå®"), |
| | | |
| | | /** |
| | | * å¯ç ä¸åè§è |
| | | */ |
| | | PWD_NONSTANDARD(500111, "å¯ç ä¸åè§è"), |
| | | |
| | | /** |
| | | * å¯ç è¿æ |
| | | */ |
| | | LOGIN_PWD_EXPIRE(500116, "å¯ç è¿æ"); |
| | | |
| | | private HttpStatus(int value, String msg) { |
| | | this.value = value; |
| | | this.msg = msg; |
| | | } |
| | | |
| | | private int value; |
| | | |
| | | private String msg; |
| | | |
| | | public int getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.smartearth.poiexcel.entity; |
| | | |
| | | /** |
| | | * ååºæ¶æ¯ç±» |
| | | * @author www |
| | | * @param <T> æ³å |
| | | */ |
| | | public class ResponseMsg<T> { |
| | | public ResponseMsg() { |
| | | this.time = System.currentTimeMillis(); |
| | | } |
| | | |
| | | public ResponseMsg(HttpStatus code, T result) { |
| | | this.code = code.getValue(); |
| | | this.msg = this.code == 200 ? "æå" : "失败"; |
| | | this.result = result; |
| | | this.time = System.currentTimeMillis(); |
| | | } |
| | | |
| | | public ResponseMsg(HttpStatus code, String msg, T result) { |
| | | this.code = code.getValue(); |
| | | this.msg = msg; |
| | | this.result = result; |
| | | this.time = System.currentTimeMillis(); |
| | | } |
| | | |
| | | public ResponseMsg(int code, String msg, T result, long time) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | this.result = result; |
| | | this.time = time; |
| | | } |
| | | |
| | | public ResponseMsg(HttpStatus code, long count, T result) { |
| | | this.code = code.getValue(); |
| | | this.msg = this.code == 200 ? "æå" : "失败"; |
| | | this.count = count; |
| | | this.result = result; |
| | | this.time = System.currentTimeMillis(); |
| | | } |
| | | |
| | | public ResponseMsg(HttpStatus code, String msg, long count, T result) { |
| | | this.code = code.getValue(); |
| | | this.msg = msg; |
| | | this.count = count; |
| | | this.result = result; |
| | | this.time = System.currentTimeMillis(); |
| | | } |
| | | |
| | | public ResponseMsg(int code, String msg, long count, T result, long time) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | this.count = count; |
| | | this.result = result; |
| | | this.time = time; |
| | | } |
| | | |
| | | private int code; |
| | | |
| | | private String msg; |
| | | |
| | | private long count; |
| | | |
| | | private T result; |
| | | |
| | | private long time; |
| | | |
| | | public int getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(int code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | |
| | | public void setMsg(String msg) { |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public long getCount() { |
| | | return count; |
| | | } |
| | | |
| | | public void setCount(long count) { |
| | | this.count = count; |
| | | } |
| | | |
| | | public T getResult() { |
| | | return result; |
| | | } |
| | | |
| | | public void setResult(T result) { |
| | | this.result = result; |
| | | } |
| | | |
| | | public long getTime() { |
| | | return time; |
| | | } |
| | | |
| | | public void setTime(long time) { |
| | | this.time = time; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.smartearth.poiexcel.mapper; |
| | | |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | /** |
| | | * ä¼ä¸æ¥å£æ å°ç±» |
| | | * @author WWW |
| | | * @date 2023-10-05 |
| | | */ |
| | | @Mapper |
| | | @Repository |
| | | public interface EntMapper { |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.smartearth.poiexcel.service; |
| | | |
| | | import com.smartearth.poiexcel.mapper.EntMapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * ä¼ä¸æå¡ç±» |
| | | * @author WWW |
| | | * @date 2023-10-05 |
| | | */ |
| | | @Service |
| | | public class EntService implements EntMapper { |
| | | @Resource |
| | | EntMapper entMapper; |
| | | |
| | | // |
| | | } |
| | |
| | | spring.datasource.username=root |
| | | spring.datasource.password=mysql |
| | | |
| | | qylweb.url=https://qylweb.bda.gov.cn/yqfwg |