Commit a5a4a078 by 吴迪

Merge remote-tracking branch 'origin/master'

parents 30e09776 17d85dd0
......@@ -252,6 +252,19 @@
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
<build>
......
package io.office.modules.manage.controller;
import java.util.Arrays;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.office.modules.manage.entity.KnowledgeinfoEntity;
import io.office.modules.manage.service.KnowledgeinfoService;
import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
/**
* 小贴士
*
* @author wudi
* @email
* @date 2021-12-08 08:59:11
*/
@RestController
@RequestMapping("/knowledgeinfo")
public class KnowledgeinfoController {
@Autowired
private KnowledgeinfoService knowledgeinfoService;
/**
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("manage:knowledgeinfo:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = knowledgeinfoService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/info/{knowledgeinfoid}")
// @RequiresPermissions("manage:knowledgeinfo:info")
public R info(@PathVariable("knowledgeinfoid") Integer knowledgeinfoid){
KnowledgeinfoEntity knowledgeinfo = knowledgeinfoService.getById(knowledgeinfoid);
return R.ok().put("knowledgeinfo", knowledgeinfo);
}
/**
* 保存
*/
@RequestMapping("/save")
// @RequiresPermissions("manage:knowledgeinfo:save")
public R save(@RequestBody KnowledgeinfoEntity knowledgeinfo){
knowledgeinfoService.save(knowledgeinfo);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("manage:knowledgeinfo:update")
public R update(@RequestBody KnowledgeinfoEntity knowledgeinfo){
knowledgeinfoService.updateById(knowledgeinfo);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("manage:knowledgeinfo:delete")
public R delete(@RequestBody Integer[] knowledgeinfoids){
knowledgeinfoService.removeByIds(Arrays.asList(knowledgeinfoids));
return R.ok();
}
}
package io.office.modules.manage.controller;
import java.util.Arrays;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.office.modules.manage.entity.LogMessageEntity;
import io.office.modules.manage.service.LogMessageService;
import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
/**
* ${comments}
*
* @author tgl
* @email
* @date 2021-12-08 11:04:42
*/
@RestController
@RequestMapping("/logmessage")
public class LogMessageController {
@Autowired
private LogMessageService logMessageService;
/**
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("manage:logmessage:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = logMessageService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
// @RequiresPermissions("manage:logmessage:info")
public R info(@PathVariable("id") Integer id){
LogMessageEntity logMessage = logMessageService.getById(id);
return R.ok().put("logMessage", logMessage);
}
/**
* 保存
*/
@RequestMapping("/save")
// @RequiresPermissions("manage:logmessage:save")
public R save(@RequestBody LogMessageEntity logMessage){
logMessageService.save(logMessage);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("manage:logmessage:update")
public R update(@RequestBody LogMessageEntity logMessage){
logMessageService.updateById(logMessage);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("manage:logmessage:delete")
public R delete(@RequestBody Integer[] ids){
logMessageService.removeByIds(Arrays.asList(ids));
return R.ok();
}
}
......@@ -339,5 +339,20 @@ public class NewsController extends AbstractController {
PageUtils pageUtils = new PageUtils(page);
return R.ok().put("data", pageUtils);
}
/**专业术语*/
@Login
@PostMapping("/api/glossaryList")
public R glossaryList(@RequestBody NewsParams newsParams) {
List<GlossaryEntity> list = this.newsService.glossaryList(newsParams);
return R.ok().put("data", list);
}
/**小贴士*/
@Login
@PostMapping("/api/tips")
public R tips(NewsParams newsParams) {
List<KnowledgeinfoEntity> list = this.newsService.selectTips(newsParams);
return R.ok().put("data", list);
}
}
package io.office.modules.manage.dao;
import io.office.modules.manage.entity.KnowledgeinfoEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 08:59:11
*/
@Mapper
public interface KnowledgeinfoDao extends BaseMapper<KnowledgeinfoEntity> {
}
package io.office.modules.manage.dao;
import io.office.modules.manage.entity.LogMessageEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 11:04:42
*/
@Mapper
public interface LogMessageDao extends BaseMapper<LogMessageEntity> {
}
......@@ -59,4 +59,9 @@ public interface NewsDao extends BaseMapper<NewsEntity> {
List<PolicyEntity> ycxgbzList();
List<PolicyEntity> zcfgList(NewsParams newsParams, Page page);
List<GlossaryEntity> glossaryList(@Param("newsParams") NewsParams newsParams);
List<KnowledgeinfoEntity> selectTips(NewsParams newsParams);
}
......@@ -3,6 +3,8 @@ package io.office.modules.manage.dao;
import io.office.modules.manage.entity.TimescodeRegiEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* ${comments}
......@@ -14,4 +16,6 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface TimescodeRegiDao extends BaseMapper<TimescodeRegiEntity> {
@Select("select * from timescode_regi where phone=#{phone} ")
TimescodeRegiEntity findByPhone(@Param("phone") String phone);
}
......@@ -3,6 +3,8 @@ package io.office.modules.manage.dao;
import io.office.modules.manage.entity.TimescodeRegiIpEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* ${comments}
......@@ -14,4 +16,6 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface TimescodeRegiIpDao extends BaseMapper<TimescodeRegiIpEntity> {
@Select("select * form timescode_regi_ip where ip = #{ip} ")
public TimescodeRegiIpEntity findByIp(@Param("ip") String ip);
}
package io.office.modules.manage.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 08:59:11
*/
@Data
@TableName("knowledgeInfo")
public class KnowledgeinfoEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* $column.comments
*/
@TableId
private Integer knowledgeinfoid;
/**
* $column.comments
*/
private Integer knowledgecategoryid;
/**
* $column.comments
*/
private Integer levels;
/**
* $column.comments
*/
private String title;
/**
* $column.comments
*/
private String editor;
/**
* $column.comments
*/
private Date inputdate;
/**
* $column.comments
*/
private String content;
/**
* $column.comments
*/
private String directpath;
/**
* $column.comments
*/
private Integer hits;
/**
* 0等待审核、1成功、2失败
*/
private Integer status;
/**
* $column.comments
*/
private String auditor;
}
package io.office.modules.manage.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 11:04:42
*/
@Data
@TableName("log_message")
public class LogMessageEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId
private Integer id;
/**
* 用户名
*/
private String username;
/**
* 手机号
*/
private String phone;
/**
*时间
*/
private Date time;
/**
* 短信内容
*/
private String pass;
/**
* ip
*/
private String ip;
/**
* 服务器IP
*/
private String url;
/**
* 分类
*/
private String type;
/**
* 发送状态
*/
private String state;
public LogMessageEntity(String username, String phone, Date time, String pass, String ip, String url, String type, String state) {
this.username = username;
this.phone = phone;
this.time = time;
this.pass = pass;
this.ip = ip;
this.url = url;
this.type = type;
this.state = state;
}
}
package io.office.modules.manage.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import org.springframework.data.annotation.Id;
/**
* 验证码实体
......@@ -22,7 +24,7 @@ public class TimescodeRegiEntity implements Serializable {
/**
* 手机号
*/
@TableId(type = IdType.INPUT)
private String phone;
/**
* 时间
......
package io.office.modules.manage.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
......@@ -22,7 +23,7 @@ public class TimescodeRegiIpEntity implements Serializable {
/**
* $column.comments
*/
@TableId
@TableId(type = IdType.INPUT)
private String ip;
/**
* $column.comments
......
......@@ -30,4 +30,6 @@ public class NewsParams extends PageParams {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTimeEnd;
private Integer classId;
private String type;
}
package io.office.modules.manage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import io.office.common.utils.PageUtils;
import io.office.modules.manage.entity.KnowledgeinfoEntity;
import java.util.Map;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 08:59:11
*/
public interface KnowledgeinfoService extends IService<KnowledgeinfoEntity> {
PageUtils queryPage(Map<String, Object> params);
}
package io.office.modules.manage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import io.office.common.utils.PageUtils;
import io.office.modules.manage.entity.LogMessageEntity;
import java.util.Map;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 11:04:42
*/
public interface LogMessageService extends IService<LogMessageEntity> {
PageUtils queryPage(Map<String, Object> params);
}
......@@ -60,5 +60,9 @@ public interface NewsService extends IService<NewsEntity> {
List<PolicyEntity> ycxgbzList();
Page<PolicyEntity> zcfgList(NewsParams newsParams, Page page);
List<GlossaryEntity> glossaryList(NewsParams newsParams);
List<KnowledgeinfoEntity> selectTips(NewsParams newsParams);
}
package io.office.modules.manage.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.office.common.utils.PageUtils;
import io.office.common.utils.Query;
import io.office.modules.manage.dao.KnowledgeinfoDao;
import io.office.modules.manage.entity.KnowledgeinfoEntity;
import io.office.modules.manage.service.KnowledgeinfoService;
@Service("knowledgeinfoService")
public class KnowledgeinfoServiceImpl extends ServiceImpl<KnowledgeinfoDao, KnowledgeinfoEntity> implements KnowledgeinfoService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<KnowledgeinfoEntity> page = this.page(
new Query<KnowledgeinfoEntity>().getPage(params),
new QueryWrapper<KnowledgeinfoEntity>()
);
return new PageUtils(page);
}
}
\ No newline at end of file
package io.office.modules.manage.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.office.common.utils.PageUtils;
import io.office.common.utils.Query;
import io.office.modules.manage.dao.LogMessageDao;
import io.office.modules.manage.entity.LogMessageEntity;
import io.office.modules.manage.service.LogMessageService;
@Service("logMessageService")
public class LogMessageServiceImpl extends ServiceImpl<LogMessageDao, LogMessageEntity> implements LogMessageService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<LogMessageEntity> page = this.page(
new Query<LogMessageEntity>().getPage(params),
new QueryWrapper<LogMessageEntity>()
);
return new PageUtils(page);
}
}
\ No newline at end of file
......@@ -213,5 +213,17 @@ public class NewsServiceImpl extends ServiceImpl<NewsDao, NewsEntity> implements
return page;
}
@Override
public List<GlossaryEntity> glossaryList(NewsParams newsParams) {
List<GlossaryEntity> list = this.newsDao.glossaryList(newsParams);
return list;
}
@Override
public List<KnowledgeinfoEntity> selectTips(NewsParams newsParams) {
List<KnowledgeinfoEntity> list = this.newsDao.selectTips(newsParams);
return list;
}
}
\ No newline at end of file
package io.office.modules.manage.service.impl;
import cn.hutool.log.Log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.office.common.exception.RRException;
import io.office.common.utils.IPUtils;
import io.office.modules.manage.dao.LogMessageDao;
import io.office.modules.manage.dao.TimescodeRegiIpDao;
import io.office.modules.manage.entity.LogMessageEntity;
import io.office.modules.manage.entity.TimescodeRegiIpEntity;
import io.office.modules.manage.service.LogMessageService;
import io.office.modules.manage.utils.DateUtils;
import org.joda.time.DateTime;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Node;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Date;
import java.util.Map;
import java.util.regex.Pattern;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
......@@ -26,9 +31,7 @@ import io.office.common.utils.Query;
import io.office.modules.manage.dao.TimescodeRegiDao;
import io.office.modules.manage.entity.TimescodeRegiEntity;
import io.office.modules.manage.service.TimescodeRegiService;
import org.springframework.util.StringUtils;
import javax.net.ssl.HttpsURLConnection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -41,6 +44,10 @@ public class TimescodeRegiServiceImpl extends ServiceImpl<TimescodeRegiDao, Time
@Autowired
private TimescodeRegiIpDao timescodeRegiIpDao;
@Autowired
private LogMessageDao logMessageDao;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<TimescodeRegiEntity> page = this.page(
......@@ -51,26 +58,46 @@ public class TimescodeRegiServiceImpl extends ServiceImpl<TimescodeRegiDao, Time
return new PageUtils(page);
}
public static void main(String[] args) {
System.out.println((int)((Math.random()*9+1)*100000)+"");
/**
* 验证手机号 由于号码段不断的更新,只需要判断手机号有11位,并且全是数字以及1开头等
* @param phoneNumber 手机号码
* @return
*/
private static boolean matchPhoneNumber(String phoneNumber) {
String regex = "1[358][0-9]{9}";
if(phoneNumber==null||phoneNumber.length()<=0){
return false;
}
return Pattern.matches(regex, phoneNumber);
}
@Override
public String getVerificationCode(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) {
//判断手机号码格式
//判断手机号码是否在黑名单内
//TODO tgl 验证码随机6位数字(验证码)
//验证码随机6位数字(验证码)
String pass=(int)((Math.random()*9+1)*100000)+"";
//获取IP(可能不是真实IP)
String ip = request.getRemoteAddr();
String ip = IPUtils.getIpAddr(request);
//手机号
String phone = String.valueOf(params.get("phone")==null?"":params.get("phone"));
String userName = String.valueOf(params.get("userName")==null?"":params.get("userName"));
//判断手机号码格式
if (!matchPhoneNumber(phone)){
throw new RRException("手机格式不正确,请重新填写");
}
//TODO tgl 判断手机号码是否在黑名单内
//发送状态
String state = "";
// 以下添加同一个手机号短信发送次数验证
int flag = 1;
TimescodeRegiEntity timescodeRegiEntity = timescodeRegiDao.selectById(phone);
if (timescodeRegiEntity!=null){ // 该手机号码是否发送过短信
Integer times = timescodeRegiEntity.getTimes();
Integer times_validate = timescodeRegiEntity.getTimesValidate();
String date = String.valueOf(params.get("date"));
String date = timescodeRegiEntity.getDate();
String date_1 = DateUtils.getDay();
if (date_1.equals(date)){
times = times + 1;
......@@ -95,12 +122,7 @@ public class TimescodeRegiServiceImpl extends ServiceImpl<TimescodeRegiDao, Time
int times = 1;
int times_validate = 0;
//新增数据
TimescodeRegiEntity timescodeRegiEntity1 = new TimescodeRegiEntity();
timescodeRegiEntity1.setPhone("phone");
timescodeRegiEntity1.setDate("date");
timescodeRegiEntity1.setTimes(times);
timescodeRegiEntity1.setTimesValidate(times_validate);
timescodeRegiDao.insert(timescodeRegiEntity1);
timescodeRegiDao.insert(new TimescodeRegiEntity(phone,date,times,times_validate));
flag = 1;
}
......@@ -126,6 +148,7 @@ public class TimescodeRegiServiceImpl extends ServiceImpl<TimescodeRegiDao, Time
}else {
times_ip = 1;
date = date_1;
timescodeRegiIpDao.updateById(new TimescodeRegiIpEntity(ip,date,times_ip));
flag_ip = 1;
}
}else {
......@@ -147,29 +170,40 @@ public class TimescodeRegiServiceImpl extends ServiceImpl<TimescodeRegiDao, Time
String userid = "9220"; // 此处按接口文档填写
String content = "您在中国物品编码中心网站注册的手机验证码为:" + pass + ",五分钟内有效,请正确输入!同一手机号每日最多操作三次!同一个ip每日最多操作十次!【中国物品编码中心】";
try{
Map<String, String> params_aspx = new HashMap<>();
params.put("action", "send");
params.put("userid", userid);
params.put("account",account);
params.put("password",password);
params.put("mobile",phone);
params.put("content",content);
params.put("sendTime",DateUtils.getDay());
params.put("mobilenumber","2");
params.put("countnumber","2");
params.put("telephonenumber","0");
String post = sendPost("http://39.106.204.178:8888/sms.aspx", map2Url(params_aspx), "application/x-www-form-urlencoded;charset=UTF-8", "POST");
JSONObject jsonObject = JSON.parseObject(post);
String returnstatus = jsonObject.getString("returnstatus");
NameValuePair[] data = {
new NameValuePair("action", "send"),
new NameValuePair("userid", userid),
new NameValuePair("account", account),
new NameValuePair("password", password),
new NameValuePair("mobile", phone),
new NameValuePair("content", content),
new NameValuePair("sendTime", DateUtils.getDay()),
new NameValuePair("mobilenumber", "2"),
new NameValuePair("countnumber", "2"),
new NameValuePair("telephonenumber", "0"),
};
String post = sendPost("http://39.106.204.178:8888/sms.aspx", data);
Document document = DocumentHelper.parseText(post);
// 获取returnstatus节点对象
String returnstatus = document.selectSingleNode("//returnstatus").getText();
if (returnstatus.equals("Success")){
//保存验证码信息log_message表
state="发送成功";
return "Success";
}else if (returnstatus.equals("Faild")){
throw new RRException("验证码发送失败:"+ jsonObject.getString("message"));
state="发送失败";
throw new RRException("验证码发送失败:"+ document.selectSingleNode("//message").getText());
}else {
state="发送失败";
throw new RRException("验证码发送失败,请稍后再试!");
}
}catch (Exception e){
e.printStackTrace();
throw new RRException("网络错误,无法连接到服务器!");
}finally {
logMessageDao.insert(new LogMessageEntity(userName,phone,new Date(),pass,ip,
request.getRequestURL().toString(),"注册新用户",state));
}
}
......@@ -180,101 +214,19 @@ public class TimescodeRegiServiceImpl extends ServiceImpl<TimescodeRegiDao, Time
* @param urls
* @return
*/
public static String sendPost(String urls, String param, String contentType, String method) {
StringBuffer sb=new StringBuffer();
DataOutputStream out = null;
BufferedReader responseReader = null;
InputStream in1 = null;
public static String sendPost(String urls, NameValuePair[] data ) {
try {
// 创建url资源
URL url = new URL(urls);
// 建立http连接
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
// 设置不用缓存
conn.setUseCaches(false);
// 设置允许输出
conn.setDoOutput(true);
// 设置允许输入
conn.setDoInput(true);
// 设置传递方式
conn.setRequestMethod(method);
System.out.println(conn.getRequestMethod());
// 设置维持长连接
conn.setRequestProperty("Connection", "Keep-Alive");
// 设置文件字符集:
conn.setRequestProperty("Charset", "UTF-8");
// 转换为字节数组
// byte[] data = (param).getBytes();
// // 设置文件长度
// conn.setRequestProperty("Content-Length", String.valueOf(data.length));
// 设置文件类型:
conn.setRequestProperty("Content-Type", contentType);
// 开始连接请求
conn.connect();
out = new DataOutputStream(conn.getOutputStream());
// 写入请求的字符串
out.writeBytes(param);
out.flush();
System.out.println(conn.getResponseCode());
// 请求返回的状态
if (HttpURLConnection.HTTP_OK == conn.getResponseCode()) {
System.out.println("连接成功");
// 请求返回的数据
in1 = conn.getInputStream();
String readLine;
responseReader = new BufferedReader(new InputStreamReader(in1,"UTF-8"));
while((readLine=responseReader.readLine()) != null){
sb.append(readLine).append("\n");
}
} else {
System.out.println("error++");
}
PostMethod postMethod = null;
postMethod = new PostMethod(urls) ;
postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8") ;
//参数设置,需要注意的就是里边不能传NULL,要传空字符串
postMethod.setRequestBody(data);
org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
int response = httpClient.executeMethod(postMethod); // 执行POST方法
String result = postMethod.getResponseBodyAsString() ;
return result;
} catch (Exception e) {
} finally {
try {
if (null != responseReader)
responseReader.close();
if (null != in1)
in1.close();
} catch(Exception e) {}
try {
out.close();
} catch(Exception e) {}
throw new RuntimeException(e.getMessage());
}
return sb.toString();
}
/**
* map转url参数
*/
public static String map2Url(Map<String, String> paramToMap) {
if (null == paramToMap || paramToMap.isEmpty()) {
return null;
}
StringBuffer url = new StringBuffer();
boolean isfist = true;
for (Map.Entry<String, String> entry : paramToMap.entrySet()) {
if (isfist) {
isfist = false;
} else {
url.append("&");
}
url.append(entry.getKey()).append("=");
String value = entry.getValue();
if (!StringUtils.isEmpty(value)) {
try {
url.append(URLEncoder.encode(value, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
return url.toString();
}
}
\ No newline at end of file
<?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="io.office.modules.manage.dao.KnowledgeinfoDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="io.office.modules.manage.entity.KnowledgeinfoEntity" id="knowledgeinfoMap">
<result property="knowledgeinfoid" column="knowledgeInfoID"/>
<result property="knowledgecategoryid" column="knowledgeCategoryID"/>
<result property="levels" column="Levels"/>
<result property="title" column="Title"/>
<result property="editor" column="Editor"/>
<result property="inputdate" column="inputDate"/>
<result property="content" column="Content"/>
<result property="directpath" column="directpath"/>
<result property="hits" column="hits"/>
<result property="status" column="status"/>
<result property="auditor" column="auditor"/>
</resultMap>
</mapper>
\ No newline at end of file
......@@ -394,4 +394,34 @@
<select id="zcfgList" resultType="io.office.modules.manage.entity.PolicyEntity">
select * from Policy where class='法律法规' and levels>0 and status > 0 order by levels desc,releasedate desc
</select>
<select id="glossaryList" resultType="io.office.modules.manage.entity.GlossaryEntity" parameterType="io.office.modules.manage.entity.dto.NewsParams">
select * from Glossary t where 1=1
<if test="newsParams.type == 1">
and t.title_CN like concat(concat('%',#{newsParams.title}),'%')
</if>
<if test="newsParams.type == 2">
and t.title_EN like concat(concat('%',#{newsParams.title}),'%')
</if>
<if test="newsParams.type == 3">
and t.content like concat(concat('%',#{newsParams.title}),'%')
</if>
</select>
<select id="selectTips" resultType="io.office.modules.manage.entity.KnowledgeinfoEntity">
SELECT
*
FROM
knowledgeInfo
WHERE
(
knowledgecategoryid = 126
OR knowledgecategoryid = 127
)
AND status = 1
AND levels > 0
ORDER BY
levels DESC,
knowledgeInfoid DESC
</select>
</mapper>
\ No newline at end of file
<?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="io.office.modules.manage.dao.TimescodeRegiIpDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="io.office.modules.manage.entity.TimescodeRegiIpEntity" id="timescodeRegiIpMap">
<result property="ip" column="ip"/>
<result property="date" column="date"/>
<result property="timesIp" column="times_ip"/>
</resultMap>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment