删除demoController相关接口
This commit is contained in:
parent
8876390719
commit
9685f03db4
|
|
@ -0,0 +1,3 @@
|
|||
/weaver-hrm-salary.iml
|
||||
/out/
|
||||
/.idea/
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
package com.api.salary.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
@Path("/bs/hrmsalary/demo")
|
||||
public class DemoController extends com.engine.salary.web.DemoController{
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
package com.engine.salary.cmd.demo;
|
||||
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import com.engine.salary.entity.DemoPo;
|
||||
import com.engine.salary.mapper.DemoMapper;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.engine.salary.util.page.PageUtil;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import weaver.conn.mybatis.MyBatisFactory;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DemoPageCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||||
|
||||
public DemoPageCmd(Map<String, Object> params, User user) {
|
||||
this.user = user;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BizLogContext getLogContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> execute(CommandContext commandContext) {
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>(16);
|
||||
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
|
||||
try {
|
||||
DemoMapper mapper = sqlSession.getMapper(DemoMapper.class);
|
||||
PageUtil.start(params);
|
||||
List<DemoPo> page = mapper.page();
|
||||
PageInfo<DemoPo> pageInfo = new PageInfo<>(page,DemoPo.class);
|
||||
apidatas.put("pageInfo", pageInfo);
|
||||
} finally {
|
||||
sqlSession.close();
|
||||
}
|
||||
return apidatas;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package com.engine.salary.mapper;
|
||||
|
||||
|
||||
import com.engine.salary.entity.DemoPo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 个税扣缴义务人
|
||||
* @Author: wangxiangzhong
|
||||
* @Date: 2021/10/29 16:55
|
||||
*/
|
||||
@Mapper
|
||||
public interface DemoMapper {
|
||||
|
||||
@Select("SELECT * FROM hrsa_tax_rate_base")
|
||||
List<DemoPo> page();
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
package com.engine.salary.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface DemoService {
|
||||
|
||||
Map<String, Object> list(Map<String, Object> params);
|
||||
|
||||
Map<String, Object> getForm(Map<String, Object> params);
|
||||
|
||||
Map<String, Object> save(Map<String, Object> params);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
package com.engine.salary.service.impl;
|
||||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.cmd.TaxAgent.TaxAgentGetFromCmd;
|
||||
import com.engine.salary.cmd.TaxAgent.TaxAgentSaveCmd;
|
||||
import com.engine.salary.cmd.demo.DemoPageCmd;
|
||||
import com.engine.salary.service.DemoService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class DemoServiceImpl extends Service implements DemoService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> list(Map<String, Object> params) {
|
||||
return commandExecutor.execute(new DemoPageCmd(params,user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getForm(Map<String, Object> params) {
|
||||
return commandExecutor.execute(new TaxAgentGetFromCmd(params,user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> save(Map<String, Object> params) {
|
||||
return commandExecutor.execute(new TaxAgentSaveCmd(params,user));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
package com.engine.salary.util;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description: 分页相关的工具类
|
||||
* @author: xiajun
|
||||
* @modified By: xiajun
|
||||
* @date: Created in 11/22/21 2:03 PM
|
||||
* @version:v1.0
|
||||
*/
|
||||
public class SalaryPageUtil {
|
||||
|
||||
private SalaryPageUtil() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static <T> Page<T> buildPage(Integer pageNo, Integer pageSize) {
|
||||
pageNo = pageNo == null || pageNo <= 0 ? 1 : pageNo;
|
||||
pageSize = pageSize == null || pageSize <= 0 ? 10 : pageSize;
|
||||
return new Page(pageNo, pageSize, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param pageNo 页码(从1开始)
|
||||
* @param pageSize 每页条数
|
||||
* @param source 待分页的数据
|
||||
* @param <T> 范型制定类
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<T> subList(int pageNo, int pageSize, List<T> source) {
|
||||
if (CollectionUtils.isEmpty(source)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
int endIndex = pageNo * pageSize;
|
||||
int startIndex = (pageNo - 1) * pageSize;
|
||||
startIndex = startIndex < 0 ? 0 : startIndex;
|
||||
return source.subList(startIndex > source.size() ? source.size() : startIndex,
|
||||
endIndex > source.size() ? source.size() : endIndex);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package com.engine.salary.util.page;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Column {
|
||||
String title;
|
||||
String dataIndex;
|
||||
String key;
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
package com.engine.salary.util.page;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DataSource {
|
||||
String key;
|
||||
String title;
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
package com.engine.salary.util.page;
|
||||
|
||||
import com.engine.salary.annotation.TableTitle;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class PageInfo<T> extends com.github.pagehelper.PageInfo<T> {
|
||||
Class<T> clazz;
|
||||
List<Column> columns = new ArrayList<>();
|
||||
List<DataSource> dataSource = new ArrayList<>();
|
||||
|
||||
public PageInfo(List<T> list) {
|
||||
super(list);
|
||||
}
|
||||
|
||||
public PageInfo(List<T> list, Class<T> clazz) {
|
||||
super(list);
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
|
||||
public List<Column> getColumns() {
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for (Field f : fields) {
|
||||
boolean isanno = f.isAnnotationPresent(TableTitle.class);
|
||||
if (isanno) {
|
||||
TableTitle annotation = f.getAnnotation(TableTitle.class);
|
||||
String title = annotation.title();
|
||||
String dataIndex = annotation.dataIndex();
|
||||
String key = annotation.key();
|
||||
Column column = Column.builder().title(title).dataIndex(dataIndex).key(key).build();
|
||||
columns.add(column);
|
||||
}
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
package com.engine.salary.util.page;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class PageUtil {
|
||||
|
||||
public static void start(Map<String, Object> params) {
|
||||
int pageNum = Util.getIntValue(Util.null2String(params.get("pageNum")));
|
||||
int pageSize = Util.getIntValue(Util.null2String(params.get("pageSize")));
|
||||
pageNum = pageNum <= 0 ? 1 : pageNum;
|
||||
pageSize = pageSize <= 0 ? 10 : pageSize;
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
}
|
||||
|
||||
public static <T> Page<T> buildPage(Integer pageNo, Integer pageSize) {
|
||||
pageNo = pageNo == null || pageNo <= 0 ? 1 : pageNo;
|
||||
pageSize = pageSize == null || pageSize <= 0 ? 10 : pageSize;
|
||||
return new Page(pageNo, pageSize, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param pageNo 页码(从1开始)
|
||||
* @param pageSize 每页条数
|
||||
* @param source 待分页的数据
|
||||
* @param <T> 范型制定类
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<T> subList(int pageNo, int pageSize, List<T> source) {
|
||||
if (CollectionUtils.isEmpty(source)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
int endIndex = pageNo * pageSize;
|
||||
int startIndex = (pageNo - 1) * pageSize;
|
||||
startIndex = startIndex < 0 ? 0 : startIndex;
|
||||
return source.subList(startIndex > source.size() ? source.size() : startIndex,
|
||||
endIndex > source.size() ? source.size() : endIndex);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
package com.engine.salary.web;
|
||||
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.salary.service.DemoService;
|
||||
import com.engine.salary.service.TaxAgentService;
|
||||
import com.engine.salary.service.impl.DemoServiceImpl;
|
||||
import com.engine.salary.service.impl.TaxAgentServiceImpl;
|
||||
import com.engine.salary.util.ResponseResult;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DemoController {
|
||||
|
||||
private BaseBean logger = new BaseBean();
|
||||
|
||||
private DemoService getService(User user) {
|
||||
return (DemoService) ServiceUtil.getService(DemoServiceImpl.class, user);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/list")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String list(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ResponseResult.run(getService(user)::list, ParamUtil.request2Map(request));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/getForm")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ResponseResult.run(getService(user)::getForm, ParamUtil.request2Map(request));
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/save")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String getFrom(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ResponseResult.run(getService(user)::save, getRequestParams(request,response));
|
||||
}
|
||||
|
||||
|
||||
protected Map<String,Object> getRequestParams(HttpServletRequest request, HttpServletResponse response){
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Enumeration<String> em = request.getParameterNames();
|
||||
while(em.hasMoreElements()){
|
||||
String paramname = em.nextElement();
|
||||
params.put(paramname, request.getParameter(paramname));
|
||||
}
|
||||
params.put("param_ip", request.getRemoteAddr());//加入ip
|
||||
return params;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue