Commit 4659c06d authored by wyh's avatar wyh

批量审核 批量展示

parent 9c5bc464
package cn.com.fqy.controller.mgt; package cn.com.fqy.controller.mgt;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.fqy.common.Operator; import cn.com.fqy.common.Operator;
import cn.com.fqy.common.ResultInfo; import cn.com.fqy.common.ResultInfo;
import cn.com.fqy.core.common.BaseController; import cn.com.fqy.core.common.BaseController;
import cn.com.fqy.core.common.PageFinder; import cn.com.fqy.core.common.PageFinder;
import cn.com.fqy.core.model.Query; import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.model.Store; import cn.com.fqy.core.model.Store;
import cn.com.fqy.core.model.SysUser; import cn.com.fqy.core.model.SysUser;
import cn.com.fqy.core.service.StoreService; import cn.com.fqy.core.model.Worker;
import cn.com.fqy.core.service.SysUserService; import cn.com.fqy.core.service.StoreService;
@Controller import cn.com.fqy.core.service.SysUserService;
@RequestMapping("store") @Controller
public class StoreController extends BaseController { @RequestMapping("store")
public class StoreController extends BaseController {
@Resource
private StoreService storeService; @Resource
@Resource private StoreService storeService;
private SysUserService sysUserService; @Resource
/* private SysUserService sysUserService;
* 分页展示店铺信息 /*
*/ * 分页展示店铺信息
@RequestMapping("storeList") */
@ResponseBody @RequestMapping("storeList")
public PageFinder<Store> storeList(Store store,Query query) { @ResponseBody
store.setIsDeleted(0); public PageFinder<Store> storeList(Store store,Query query) {
SysUser user = sysUserService.detail(store.getUserId()); store.setIsDeleted(0);
if (user!=null) { SysUser user = sysUserService.detail(store.getUserId());
if ("1".equals(user.getFlag())) { if (user!=null) {
store.setUserId(""); if ("1".equals(user.getFlag())) {
} store.setUserId("");
} }
Query q = new Query(query.getPageNo(),query.getPageSize(),store); }
return storeService.getStorePagedList(q); Query q = new Query(query.getPageNo(),query.getPageSize(),store);
} return storeService.getStorePagedList(q);
}
/**
* 添加或修改店铺信息 /**
* @param CarPreiod * 添加或修改店铺信息
* @return * @param CarPreiod
*/ * @return
@RequestMapping("addOrEditStore") */
@ResponseBody @RequestMapping("addOrEditStore")
public ResultInfo<Store> addOrEditStore(Store store) { @ResponseBody
ResultInfo<Store> resultInfo = new ResultInfo<>(); public ResultInfo<Store> addOrEditStore(Store store) {
//操作人 ResultInfo<Store> resultInfo = new ResultInfo<>();
Operator op = getOperator(); //操作人
if (store!=null&&store.getStoreId()!=null&&!"".equals(store.getStoreId())) { Operator op = getOperator();
resultInfo = storeService.updateStore(store, op); if (store!=null&&store.getStoreId()!=null&&!"".equals(store.getStoreId())) {
}else { resultInfo = storeService.updateStore(store, op);
}else {
resultInfo = storeService.addStore(store, op);
} resultInfo = storeService.addStore(store, op);
return resultInfo; }
} return resultInfo;
}
/**
* 店铺删除 /**
* @param workerId * 店铺删除
* @return * @param workerId
*/ * @return
@RequestMapping("delStore") */
@ResponseBody @RequestMapping("delStore")
public ResultInfo<Store> delStore(String storeId ) { @ResponseBody
ResultInfo<Store> resultInfo = new ResultInfo<>(); public ResultInfo<Store> delStore(String storeId ) {
if(storeId == null || "".equals(storeId)) { ResultInfo<Store> resultInfo = new ResultInfo<>();
resultInfo.setCode("0"); if(storeId == null || "".equals(storeId)) {
resultInfo.setMsg("店铺ID参数为空"); resultInfo.setCode("0");
return resultInfo; resultInfo.setMsg("店铺ID参数为空");
} return resultInfo;
Store store = new Store(); }
store.setIsDeleted(1); Store store = new Store();
store.setStoreId(storeId); store.setIsDeleted(1);
return storeService.updateStore(store, getOperator()); store.setStoreId(storeId);
} return storeService.updateStore(store, getOperator());
}
/**
* 获取店铺信息 /**
*/ * 获取店铺信息
@RequestMapping("getStores") */
@ResponseBody @RequestMapping("getStores")
public ResultInfo<List<Map<String,Object>>> getStores(){ @ResponseBody
ResultInfo<List<Map<String,Object>>> result = new ResultInfo<>(); public ResultInfo<List<Map<String,Object>>> getStores(){
List<Map<String,Object>> listQuery = new ArrayList<>(); ResultInfo<List<Map<String,Object>>> result = new ResultInfo<>();
Store store = new Store(); List<Map<String,Object>> listQuery = new ArrayList<>();
store.setIsDeleted(0); Store store = new Store();
store.setIsAuditing(1); store.setIsDeleted(0);
List<Store> storeList = storeService.getStoreList(new Query(store)); store.setIsAuditing(1);
if (storeList.size()>0 && storeList !=null) { List<Store> storeList = storeService.getStoreList(new Query(store));
for(Store list: storeList) { if (storeList.size()>0 && storeList !=null) {
Map<String,Object> map = new HashMap<>(); for(Store list: storeList) {
map.put("storeId", list.getStoreId()); Map<String,Object> map = new HashMap<>();
map.put("storeName",list.getStoreName()); map.put("storeId", list.getStoreId());
listQuery.add(map); map.put("storeName",list.getStoreName());
} listQuery.add(map);
if(listQuery.size()>0 && listQuery != null) { }
result.setCode("1"); if(listQuery.size()>0 && listQuery != null) {
result.setData(listQuery); result.setCode("1");
}else { result.setData(listQuery);
result.setCode("0"); }else {
result.setMsg("暂无可用店铺数据"); result.setCode("0");
} result.setMsg("暂无可用店铺数据");
}else { }
result.setCode("0"); }else {
result.setMsg("暂无店铺数据"); result.setCode("0");
} result.setMsg("暂无店铺数据");
return result; }
} return result;
} }
/**
* 批量审核
* @param workerIds
* @return
*/
@RequestMapping("batchStores")
@ResponseBody
public ResultInfo<Store> batchStores(String[] storeIds) {
return storeService.batchStoreUpdate(storeIds, getOperator());
}
/**
* 批量展示
* @param workerIds
* @return
*/
@RequestMapping("batchStoreShop")
@ResponseBody
public ResultInfo<Store> batchStoreShop(String[] storeIds) {
return storeService.batchStoreShopping(storeIds, getOperator());
}
}
...@@ -6,6 +6,7 @@ import javax.annotation.Resource; ...@@ -6,6 +6,7 @@ import javax.annotation.Resource;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.fqy.common.Operator; import cn.com.fqy.common.Operator;
......
package cn.com.fqy.core.dao; package cn.com.fqy.core.dao;
import cn.com.fqy.core.common.BaseDao; import cn.com.fqy.core.common.BaseDao;
import cn.com.fqy.core.model.Store; import cn.com.fqy.core.model.Store;
/** /**
* Store 数据库处理类 * Store 数据库处理类
*/ */
public interface StoreDao extends BaseDao<Store,String> { public interface StoreDao extends BaseDao<Store,String> {
} public int updateAdByIds(String[] ids);
public int updateShopByIds(String[] ids);
}
package cn.com.fqy.core.dao; package cn.com.fqy.core.dao;
import java.util.List; import java.util.List;
import cn.com.fqy.core.common.BaseDao; import cn.com.fqy.core.common.BaseDao;
import cn.com.fqy.core.model.Worker; import cn.com.fqy.core.model.Worker;
/** /**
* Worker 数据库处理类 * Worker 数据库处理类
*/ */
public interface WorkerDao extends BaseDao<Worker,String> { public interface WorkerDao extends BaseDao<Worker,String> {
/** /**
* 根据 一组ID 查询返回一个对象集合 * 根据 一组ID 查询返回一个对象集合
* @param ids * @param ids
* @return * @return
*/ */
public List<Worker> getWorkerByIds(String[] ids); public List<Worker> getWorkerByIds(String[] ids);
}
public int updateAdByIds(String[] ids);
public int updateShopByIds(String[] ids);
}
package cn.com.fqy.core.service; package cn.com.fqy.core.service;
import java.util.List; import java.util.List;
import cn.com.fqy.common.Operator; import cn.com.fqy.common.Operator;
import cn.com.fqy.common.ResultInfo; import cn.com.fqy.common.ResultInfo;
import cn.com.fqy.core.common.BaseService; import cn.com.fqy.core.common.BaseService;
import cn.com.fqy.core.common.PageFinder; import cn.com.fqy.core.common.PageFinder;
import cn.com.fqy.core.model.Query; import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.model.Store; import cn.com.fqy.core.model.Store;
import cn.com.fqy.core.model.Worker;
/**
* Store 服务接口类 /**
*/ * Store 服务接口类
public interface StoreService extends BaseService { */
public interface StoreService extends BaseService {
/**
* 根据查询条件,查询并返回Store的列表 /**
* @param q 查询条件 * 根据查询条件,查询并返回Store的列表
* @return * @param q 查询条件
*/ * @return
public List<Store> getStoreList(Query q); */
public List<Store> getStoreList(Query q);
/**
* 根据查询条件,分页查询并返回Store的分页结果 /**
* @param q 查询条件 * 根据查询条件,分页查询并返回Store的分页结果
* @return * @param q 查询条件
*/ * @return
public PageFinder<Store> getStorePagedList(Query q); */
public PageFinder<Store> getStorePagedList(Query q);
/**
* 根据主键,查询并返回一个Store对象 /**
* @param id 主键id * 根据主键,查询并返回一个Store对象
* @return * @param id 主键id
*/ * @return
public Store getStore(String id); */
public Store getStore(String id);
/**
* 根据主键数组,查询并返回一组Store对象 /**
* @param ids 主键数组,数组中的主键值应当无重复值,如有重复值时,则返回的列表长度可能小于传入的数组长度 * 根据主键数组,查询并返回一组Store对象
* @return * @param ids 主键数组,数组中的主键值应当无重复值,如有重复值时,则返回的列表长度可能小于传入的数组长度
*/ * @return
public List<Store> getStoreByIds(String[] ids); */
public List<Store> getStoreByIds(String[] ids);
/**
* 根据主键,删除特定的Store记录 /**
* @param id 主键id * 根据主键,删除特定的Store记录
* @param operator 操作人对象 * @param id 主键id
* @return * @param operator 操作人对象
*/ * @return
public ResultInfo<Store> delStore(String id, Operator operator); */
public ResultInfo<Store> delStore(String id, Operator operator);
/**
* 新增一条Store记录,执行成功后传入对象及返回对象的主键属性值不为null /**
* @param store 新增的Store数据(如果无特殊需求,新增对象的主键值请保留为null) * 新增一条Store记录,执行成功后传入对象及返回对象的主键属性值不为null
* @param operator 操作人对象 * @param store 新增的Store数据(如果无特殊需求,新增对象的主键值请保留为null)
* @return * @param operator 操作人对象
*/ * @return
public ResultInfo<Store> addStore(Store store, Operator operator); */
public ResultInfo<Store> addStore(Store store, Operator operator);
/**
* 根据主键,更新一条Store记录 /**
* @param store 更新的Store数据,且其主键不能为空 * 根据主键,更新一条Store记录
* @param operator 操作人对象 * @param store 更新的Store数据,且其主键不能为空
* @return * @param operator 操作人对象
*/ * @return
public ResultInfo<Store> updateStore(Store store, Operator operator); */
public ResultInfo<Store> updateStore(Store store, Operator operator);
/**
* 生成主键 /**
* @return * 生成主键
*/ * @return
public String generatePK(); */
public String generatePK();
/**
* 为Store对象设置默认值 /**
* @param obj * 为Store对象设置默认值
*/ * @param obj
public void fillDefaultValues(Store obj); */
public void fillDefaultValues(Store obj);
}
/**
* 根据 一组ID 修改一组数据
* @param workerId
* @return
*/
public ResultInfo<Store> batchStoreUpdate(String[] storeIds,Operator operator);
public ResultInfo<Store> batchStoreShopping(String[] storeIds,Operator operator);
}
...@@ -21,6 +21,7 @@ import cn.com.fqy.core.common.PageFinder; ...@@ -21,6 +21,7 @@ import cn.com.fqy.core.common.PageFinder;
import cn.com.fqy.core.dao.StoreDao; import cn.com.fqy.core.dao.StoreDao;
import cn.com.fqy.core.model.Query; import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.model.Store; import cn.com.fqy.core.model.Store;
import cn.com.fqy.core.model.Worker;
import cn.com.fqy.core.service.StoreService; import cn.com.fqy.core.service.StoreService;
/** /**
...@@ -298,4 +299,52 @@ public class StoreServiceImpl implements StoreService { ...@@ -298,4 +299,52 @@ public class StoreServiceImpl implements StoreService {
} }
} }
@Transactional
public ResultInfo<Store> batchStoreUpdate(String[] storeIds, Operator operator) {
ResultInfo<Store> resultInfo = new ResultInfo<Store>();
if (storeIds == null || storeIds.length == 0) {
log.info(Constant.ERR_MSG_INVALID_ARG + " storeIds is null or empty array.");
} else {
try {
//调用dao,根据主键数组查询
int count=storeDao.updateAdByIds(storeIds);
if (count > 0) {
resultInfo.setCode(Constant.SUCCESS);
} else {
resultInfo.setCode(Constant.FAIL);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
resultInfo.setCode(Constant.FAIL);
resultInfo.setMsg(Constant.ERR_MSG_EXCEPTION_CATCHED);
}
}
return resultInfo;
}
@Transactional
public ResultInfo<Store> batchStoreShopping(String[] storeIds, Operator operator) {
ResultInfo<Store> resultInfo = new ResultInfo<Store>();
if (storeIds == null || storeIds.length == 0) {
log.info(Constant.ERR_MSG_INVALID_ARG + " storeIds is null or empty array.");
} else {
try {
//调用dao,根据主键数组查询
int count=storeDao.updateShopByIds(storeIds);
if (count > 0) {
resultInfo.setCode(Constant.SUCCESS);
} else {
resultInfo.setCode(Constant.FAIL);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
resultInfo.setCode(Constant.FAIL);
resultInfo.setMsg(Constant.ERR_MSG_EXCEPTION_CATCHED);
}
}
return resultInfo;
}
} }
...@@ -322,26 +322,51 @@ public class WorkerServiceImpl implements WorkerService { ...@@ -322,26 +322,51 @@ public class WorkerServiceImpl implements WorkerService {
return list; return list;
} }
@Override @Transactional
public ResultInfo<Worker> batchWorkerUpdate(String[] workerIds,Operator operator) { public ResultInfo<Worker> batchWorkerUpdate(String[] workerIds,Operator operator) {
ResultInfo<Worker> resultInfo = new ResultInfo<Worker>(); ResultInfo<Worker> resultInfo = new ResultInfo<Worker>();
for (String id : workerIds) { if (workerIds == null || workerIds.length == 0) {
Worker worker =new Worker(); log.info(Constant.ERR_MSG_INVALID_ARG + " workerIds is null or empty array.");
worker.setWorkerId(id); } else {
worker.setIsAuditing(1); try {
resultInfo = updateWorker(worker,operator); //调用dao,根据主键数组查询
int count=workerDao.updateAdByIds(workerIds);
if (count > 0) {
resultInfo.setCode(Constant.SUCCESS);
} else {
resultInfo.setCode(Constant.FAIL);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
resultInfo.setCode(Constant.FAIL);
resultInfo.setMsg(Constant.ERR_MSG_EXCEPTION_CATCHED);
}
} }
return resultInfo; return resultInfo;
} }
@Override @Transactional
public ResultInfo<Worker> batchWorkerShopping(String[] workerIds, Operator operator) { public ResultInfo<Worker> batchWorkerShopping(String[] workerIds, Operator operator) {
ResultInfo<Worker> resultInfo = new ResultInfo<Worker>(); ResultInfo<Worker> resultInfo = new ResultInfo<Worker>();
for (String id : workerIds) { if (workerIds == null || workerIds.length == 0) {
Worker worker =new Worker(); log.info(Constant.ERR_MSG_INVALID_ARG + " workerIds is null or empty array.");
worker.setWorkerId(id); } else {
worker.setIsShopping(1);; try {
resultInfo = updateWorker(worker,operator); //调用dao,根据主键数组查询
int count=workerDao.updateShopByIds(workerIds);
if (count > 0) {
resultInfo.setCode(Constant.SUCCESS);
} else {
resultInfo.setCode(Constant.FAIL);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
resultInfo.setCode(Constant.FAIL);
resultInfo.setMsg(Constant.ERR_MSG_EXCEPTION_CATCHED);
}
} }
return resultInfo; return resultInfo;
} }
......
...@@ -258,6 +258,18 @@ CITY_NAME,CITY_ID,PROVINCE_ID,COUNTY_ID,BRIEF ...@@ -258,6 +258,18 @@ CITY_NAME,CITY_ID,PROVINCE_ID,COUNTY_ID,BRIEF
</where> </where>
</update> </update>
<update id="updateAdByIds">
update T_STORE set IS_AUDITING=1
<where>
STORE_ID in <foreach item="item" index="index" collection="array" open="(" separator="," close=")">#{item}</foreach>
</where>
</update>
<update id="updateShopByIds">
update T_STORE set IS_SHOPPING=1
<where>
STORE_ID in <foreach item="item" index="index" collection="array" open="(" separator="," close=")">#{item}</foreach>
</where>
</update>
<delete id="delete"> <delete id="delete">
delete from T_STORE delete from T_STORE
<where> <where>
......
...@@ -232,6 +232,18 @@ UPDATE_TIME,OPERATOR_ID,OPERATOR_TYPE,SERIAL_NUMBER,IS_DELETED,STORE_NAME,BRIEF ...@@ -232,6 +232,18 @@ UPDATE_TIME,OPERATOR_ID,OPERATOR_TYPE,SERIAL_NUMBER,IS_DELETED,STORE_NAME,BRIEF
</where> </where>
</update> </update>
<update id="updateAdByIds" >
update T_WORKER set IS_AUDITING=1
<where>
WORKER_ID in <foreach item="item" index="index" collection="array" open="(" separator="," close=")">#{item}</foreach>
</where>
</update>
<update id="updateShopByIds" >
update T_WORKER set IS_SHOPPING=1
<where>
WORKER_ID in <foreach item="item" index="index" collection="array" open="(" separator="," close=")">#{item}</foreach>
</where>
</update>
<delete id="delete"> <delete id="delete">
delete from T_WORKER delete from T_WORKER
<where> <where>
......
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