更新后端,采用Springboot+mybatis
This commit is contained in:
72
src/main/java/com/jsh/erp/service/app/AppComponent.java
Normal file
72
src/main/java/com/jsh/erp/service/app/AppComponent.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package com.jsh.erp.service.app;
|
||||
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.utils.Constants;
|
||||
import com.jsh.erp.utils.QueryUtils;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service(value = "app_component")
|
||||
@AppResource
|
||||
public class AppComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private AppService appService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getAppList(map);
|
||||
}
|
||||
|
||||
private List<?> getAppList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String order = QueryUtils.order(map);
|
||||
return appService.select(name, type, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
return appService.countApp(name, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return appService.insertApp(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return appService.updateApp(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return appService.deleteApp(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return appService.batchDeleteApp(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
15
src/main/java/com/jsh/erp/service/app/AppResource.java
Normal file
15
src/main/java/com/jsh/erp/service/app/AppResource.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.app;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "app", type = 15)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface AppResource {
|
||||
}
|
||||
85
src/main/java/com/jsh/erp/service/app/AppService.java
Normal file
85
src/main/java/com/jsh/erp/service/app/AppService.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package com.jsh.erp.service.app;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.App;
|
||||
import com.jsh.erp.datasource.entities.AppExample;
|
||||
import com.jsh.erp.datasource.mappers.AppMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AppService {
|
||||
private Logger logger = LoggerFactory.getLogger(AppService.class);
|
||||
|
||||
@Resource
|
||||
private AppMapper appMapper;
|
||||
|
||||
public List<App> findDock(){
|
||||
AppExample example = new AppExample();
|
||||
example.createCriteria().andZlEqualTo("dock").andEnabledEqualTo(true);
|
||||
example.setOrderByClause("Sort");
|
||||
List<App> list = appMapper.selectByExample(example);
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<App> findDesk(){
|
||||
AppExample example = new AppExample();
|
||||
example.createCriteria().andZlEqualTo("desk").andEnabledEqualTo(true);
|
||||
example.setOrderByClause("Sort");
|
||||
List<App> list = appMapper.selectByExample(example);
|
||||
return list;
|
||||
}
|
||||
|
||||
public App getApp(long id) {
|
||||
return appMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<App> getApp() {
|
||||
AppExample example = new AppExample();
|
||||
return appMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<App> select(String name, String type, int offset, int rows) {
|
||||
return appMapper.selectByConditionApp(name, type, offset, rows);
|
||||
}
|
||||
|
||||
public int countApp(String name, String type) {
|
||||
return appMapper.countsByApp(name, type);
|
||||
}
|
||||
|
||||
public int insertApp(String beanJson, HttpServletRequest request) {
|
||||
App app = JSONObject.parseObject(beanJson, App.class);
|
||||
return appMapper.insertSelective(app);
|
||||
}
|
||||
|
||||
public int updateApp(String beanJson, Long id) {
|
||||
App app = JSONObject.parseObject(beanJson, App.class);
|
||||
app.setId(id);
|
||||
return appMapper.updateByPrimaryKeySelective(app);
|
||||
}
|
||||
|
||||
public int deleteApp(Long id) {
|
||||
return appMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteApp(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
AppExample example = new AppExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return appMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public List<App> findRoleAPP(){
|
||||
AppExample example = new AppExample();
|
||||
example.createCriteria().andEnabledEqualTo(true);
|
||||
example.setOrderByClause("Sort");
|
||||
List<App> list = appMapper.selectByExample(example);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user