北京经济技术开发区经开区虚拟城市项目-【后端】-服务,Poi,企业,地块等定制接口
13693261870
2023-10-05 660ea8a344a91d7be146bf73541f681647760efa
添加 企业 控制器
已添加7个文件
已修改1个文件
341 ■■■■■ 文件已修改
src/main/java/com/smartearth/poiexcel/controller/BaseController.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/smartearth/poiexcel/controller/EntController.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/smartearth/poiexcel/entity/EntEntity.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/smartearth/poiexcel/entity/HttpStatus.java 105 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/smartearth/poiexcel/entity/ResponseMsg.java 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/smartearth/poiexcel/mapper/EntMapper.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/smartearth/poiexcel/service/EntService.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.properties 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/smartearth/poiexcel/controller/BaseController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,44 @@
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);
    }
}
src/main/java/com/smartearth/poiexcel/controller/EntController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,35 @@
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);
        }
    }
}
src/main/java/com/smartearth/poiexcel/entity/EntEntity.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,15 @@
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() {
    }
}
src/main/java/com/smartearth/poiexcel/entity/HttpStatus.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,105 @@
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;
    }
}
src/main/java/com/smartearth/poiexcel/entity/ResponseMsg.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,107 @@
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;
    }
}
src/main/java/com/smartearth/poiexcel/mapper/EntMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,15 @@
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 {
}
src/main/java/com/smartearth/poiexcel/service/EntService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
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;
    //
}
src/main/resources/application.properties
@@ -13,3 +13,4 @@
spring.datasource.username=root
spring.datasource.password=mysql
qylweb.url=https://qylweb.bda.gov.cn/yqfwg